# Mrresize 4D data to 3D

**URL:** https://community.mrtrix.org/t/mrresize-4d-data-to-3d/2881
**Category:** Uncategorized
**Created:** [October 3, 2019, 10:54am UTC](https://community.mrtrix.org/t/mrresize-4d-data-to-3d/2881 "2019-10-03T10:54:40Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![TR-Abir](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/t/c68b51/32.png) [@TR-Abir](https://community.mrtrix.org/u/TR-Abir)
#### Post date: [October 3, 2019, 10:54am UTC](https://community.mrtrix.org/t/mrresize-4d-data-to-3d/2881/1 "2019-10-03T10:54:40Z")

</div>

dear all,  
i need to resize a 4D diffusion data to 3D diffusion data, i used the instruction of mrresize but i have an error, i will appreciate any help, thanks.

---

<div class="post-metadata">

### Author: ![fixelator](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/f/c6cbf5/32.png) [@fixelator](https://community.mrtrix.org/u/fixelator)
#### Post date: [October 4, 2019, 9:04am UTC](https://community.mrtrix.org/t/mrresize-4d-data-to-3d/2881/2 "2019-10-04T09:04:15Z")

</div>

Have you tried [mrconvert](https://mrtrix.readthedocs.io/en/latest/reference/commands/mrconvert.html#mrconvert)?

you can trying something like this…  
mrconvert 4D\_data.mif -coord 3 0 - | mrconvert - 3D\_data.mif -axes 0,1,2

I’m sure there are other ways of converting 4D to 3D.

Cheers,  
Sam

---

<div class="post-metadata">

### Author: ![jdtournier](https://community.mrtrix.org/user_avatar/community.mrtrix.org/jdtournier/32/2594_2.png) [@jdtournier](https://community.mrtrix.org/u/jdtournier)
#### Post date: [October 4, 2019, 9:12am UTC](https://community.mrtrix.org/t/mrresize-4d-data-to-3d/2881/3 "2019-10-04T09:12:31Z")

</div>

> [@fixelator](#):
>
> mrconvert 4D\_data.mif -coord 3 0 - | mrconvert - 3D\_data.mif -axes 0,1,2

You could do this in a single `mrconvert` call if you want:

```auto
mrconvert 4D_data.mif -coord 3 0 -axes 0,1,2 3D_data.mif

```

* * *

But more to the point:

> [@TR-Abir](#):
>
> i need to resize a 4D diffusion data to 3D diffusion data

What do you mean by that exactly? If you have 4D data, converting that to 3D means extracting one volume from the 4D series (which is what the above call does), or it could refer to processing the data to generate a 3D output (e.g. DTI fit to obtain FA or MD, …). What do you mean exactly?

- If you mean to extract the _b_=0 volume, then the above will do the job _most_ of the time, but it would be safer to use `dwiextract -bzero` (potentially followed by `mrmath -axis 3 mean` if there’s more than one).

- If you mean to extract tensor metrics, then you’d need to use a combination of `dwi2tensor` and `tensor2metric` like this:

- If you mean something else, then you’ll need to be more specific as to what you’re actually trying to achieve.

---

<div class="post-metadata">

### Author: ![nayan\_wadhwani](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/n/a88e57/32.png) [@nayan\_wadhwani](https://community.mrtrix.org/u/nayan_wadhwani)
#### Post date: [October 4, 2019, 10:30am UTC](https://community.mrtrix.org/t/mrresize-4d-data-to-3d/2881/4 "2019-10-04T10:30:19Z")

</div>

when will be the right time to run this command before running dwipreproc or after that?

---

<div class="post-metadata">

### Author: ![nayan\_wadhwani](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/n/a88e57/32.png) [@nayan\_wadhwani](https://community.mrtrix.org/u/nayan_wadhwani)
#### Post date: [October 5, 2019, 3:11pm UTC](https://community.mrtrix.org/t/mrresize-4d-data-to-3d/2881/5 "2019-10-05T15:11:37Z")

</div>

I tried converting the data to 3D using the by using the above mentioned command but it is asking only for the 4D data. I don’t when to run

> mrconvert 4D\_data.mif -coord 3 0 -axes 0,1,2 3D\_data.mif

---

<div class="post-metadata">

### Author: ![jdtournier](https://community.mrtrix.org/user_avatar/community.mrtrix.org/jdtournier/32/2594_2.png) [@jdtournier](https://community.mrtrix.org/u/jdtournier)
#### Post date: [October 5, 2019, 5:26pm UTC](https://community.mrtrix.org/t/mrresize-4d-data-to-3d/2881/6 "2019-10-05T17:26:03Z")

</div>

Ok, maybe the order of operations isn’t what I thought it was… If it doesn’t work, then your suggestion should indeed do the trick… 👍

---

<div class="post-metadata">

### Author: ![nayan\_wadhwani](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/n/a88e57/32.png) [@nayan\_wadhwani](https://community.mrtrix.org/u/nayan_wadhwani)
#### Post date: [October 7, 2019, 6:07am UTC](https://community.mrtrix.org/t/mrresize-4d-data-to-3d/2881/7 "2019-10-07T06:07:52Z")

</div>

Dear Tournier,  
Tracks are still the same after running the below command

> mrconvert 4D\_data.mif -coord 3 0 -axes 0,1,2 3D\_data.mif

I tried changing the pipeline for the track generation it’s still the same. I am still searching for the reason for these types of tracks.

---

<div class="post-metadata">

### Author: ![rsmith](https://community.mrtrix.org/user_avatar/community.mrtrix.org/rsmith/32/2672_2.png) [@rsmith](https://community.mrtrix.org/u/rsmith)
#### Post date: [October 7, 2019, 1:07pm UTC](https://community.mrtrix.org/t/mrresize-4d-data-to-3d/2881/8 "2019-10-07T13:07:16Z")

</div>

> > i need to resize a 4D diffusion data to 3D diffusion data,

> What do you mean exactly?

Third option: One way to “map” four-dimensional data to 3D is to compute some _statistic_ across volumes; so for instance, if you have a few _b_=0 images in a 4D series, and compute the mean value across volumes via `mrmath -axis 3`, you end up with a 3D image.

But as it stands currently, it is entirely unclear to us based on your current description exactly what you are actually trying to achieve; hence more questions than answers. We typically wouldn’t describe producing a 3D dataset from a 4D dataset as “resizing”, as there by necessity must be some kind of explicit operation that _results_ in that change in dimensionality, rather than the change in dimensionality being the goal in and of itself.

---

<div class="post-metadata">

### Author: ![TR-Abir](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/t/c68b51/32.png) [@TR-Abir](https://community.mrtrix.org/u/TR-Abir)
#### Post date: [October 8, 2019, 1:04pm UTC](https://community.mrtrix.org/t/mrresize-4d-data-to-3d/2881/9 "2019-10-08T13:04:03Z")

</div>

Dear all,  
thanks for your responses, i have solved the problem with the command  
mrconvert 4D\_data.mif -coord 3 0 -axes 0,1,2 3D\_data.mif
