# Transform from template space to subject space

**URL:** <https://community.mrtrix.org/t/transform-from-template-space-to-subject-space/4406>\
**Category:** Uncategorized\
**Tags:** preprocessing\
**Created:** [December 21, 2020, 3:45pm UTC](https://community.mrtrix.org/t/transform-from-template-space-to-subject-space/4406 "2020-12-21T15:45:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChrisvdW](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/c/d26b3c/32.png) [@ChrisvdW](https://community.mrtrix.org/u/ChrisvdW)\
**Post date:** [December 21, 2020, 3:45pm UTC](https://community.mrtrix.org/t/transform-from-template-space-to-subject-space/4406/1 "2020-12-21T15:45:52Z")

</div>

Dear all,

I generated the FD, FC, and FDC images using multi-tissue CSD according to the pipeline. [https://mrtrix.readthedocs.io/en/3.0.2/fixel\_based\_analysis/mt\_fibre\_density\_cross-section.html](https://mrtrix.readthedocs.io/en/3.0.2/fixel_based_analysis/mt_fibre_density_cross-section.html)

However, I would like to transform the data from template space to subject space, so I can compare the results with other images using VOIs in subject space. Therefore, in step 10, I added the -nl\_warp\_full option to get the full warping.

Now, I tried the following commands, but sadly without success:  
• mrtransform –warp\_full Subj001\_1\_full\_warp\_FOD.mih -template …/template/wmfod\_template.nii –from 2 Subj001\_1\_FD.nii Subj001\_1\_FD\_native.nii  
• mrtransform –warp\_full Subj001\_1\_full\_warp\_FOD.mih -template …/template/wmfod\_template.nii –inverse Subj001\_1\_FD.nii Subj001\_1\_FD\_native.nii

Does anyone has some suggestions what I am doing wrong here?

Greetings,  
Chris

---

<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:** [January 4, 2021, 12:49pm UTC](https://community.mrtrix.org/t/transform-from-template-space-to-subject-space/4406/2 "2021-01-04T12:49:08Z")

</div>

Hi Chris,

> [@ChrisvdW](#):
>
> Now, I tried the following commands, but sadly without success:

Could you be more specific about what ‘without success’ looks like? Does the command fail to run, or does it run but produce unusable results?

Looking at your commands, the first thing that jumps out at me is the use of a non-ASCII long dash in the `–warp_full` option. This has caused lots of problems in the past, see e.g. [this post](https://community.mrtrix.org/t/trouble-with-mrmath/4158/2). If that’s the issue, I’d expect to see an error related to an invalid number of arguments or something like that. But it’s at least easy to fix…

---

<div class="post-metadata">

**Author:** ![maxpietsch](https://community.mrtrix.org/user_avatar/community.mrtrix.org/maxpietsch/32/25_2.png) [@maxpietsch](https://community.mrtrix.org/u/maxpietsch)\
**Post date:** [January 4, 2021, 1:23pm UTC](https://community.mrtrix.org/t/transform-from-template-space-to-subject-space/4406/3 "2021-01-04T13:23:04Z")

</div>

Are the data you are transforming images in template space or fixel contrast files?

> [@ChrisvdW](#):
>
> I would like to transform the data from template space to subject space

Starting with

```auto
mrregister subj_odf.mif template_odf.mif -mask1 subj_mask.mif -nl_warp_full warp_full_s2t.mih

```

you’d transform the template ODF image to subject space with

```auto
mrtransform template_odf.mif -warp_full warp_full_s2t.mih -from 2 -template subj_odf.mif template_odf_in_subj_space.mif -reorient yes

```

---

<div class="post-metadata">

**Author:** ![ChrisvdW](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/c/d26b3c/32.png) [@ChrisvdW](https://community.mrtrix.org/u/ChrisvdW)\
**Post date:** [January 4, 2021, 4:13pm UTC](https://community.mrtrix.org/t/transform-from-template-space-to-subject-space/4406/4 "2021-01-04T16:13:39Z")

</div>

Dear Daniel,

With without success, I meant having images devoid of any information. I did not get any errors while producing the images.  
I checked whether the long dash infront “warp\_full” was the problem, but it seems to be correct on my Linux desktop. Probably it got changed when copying from my Linux desktop to my Windows desktop.  
I attached a screenshot that displays the result of the transformation.

Greetings,  
Chris

 ![image](https://community.mrtrix.org/uploads/default/original/2X/0/0ba1c318764ad5e0c2701220d5f2be1195f8b3d0.png)

---

<div class="post-metadata">

**Author:** ![ChrisvdW](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/c/d26b3c/32.png) [@ChrisvdW](https://community.mrtrix.org/u/ChrisvdW)\
**Post date:** [January 4, 2021, 4:36pm UTC](https://community.mrtrix.org/t/transform-from-template-space-to-subject-space/4406/5 "2021-01-04T16:36:52Z")

</div>

Dear Max,

The data that I want to transform, the FD, FC, and FDC, are indeed in template space. With fixel contrast files, do you mean the data format? I produced the images in nifty, since I planned to open them in other software packages to do VOI comparisons with other images. I was planning to re-do the analysis using the images in .mif format. Does that maybe solve the problem? And then in the end converting from .mif to .nii.

According to your example for transforming the template ODF image to subject space, I adjusted it to the following:  
mrtransform ./Subj001\_1\_fixel\_in\_template\_space/Subj001\_1\_fd.nii –warp\_full Subj001\_1\_full\_warp\_FOD.mih –from 2 –template Subj001\_1\_wmfod\_norm.nii Subj001\_1\_FD\_native4.nii –reorient yes

However, then, I received the following error:  
[error] Apodised PSF reorrientation requires SH series images

Removing the -reorient option, produced an image without error, but again devoid of any information.

Greetings,  
Chris

---

<div class="post-metadata">

**Author:** ![maxpietsch](https://community.mrtrix.org/user_avatar/community.mrtrix.org/maxpietsch/32/25_2.png) [@maxpietsch](https://community.mrtrix.org/u/maxpietsch)\
**Post date:** [January 4, 2021, 6:06pm UTC](https://community.mrtrix.org/t/transform-from-template-space-to-subject-space/4406/6 "2021-01-04T18:06:10Z")

</div>

I think it’d be best if you could elaborate on what you want to achieve with the template fixel contrasts in subject-space. AFAIK, warping fixel files directly is not possible due to [their nature](https://mrtrix.readthedocs.io/en/3.0.2/fixel_based_analysis/fixel_directory_format.html) but there might be other ways to do what you want to achieve.

You can for instance convert the template fixel files to volumetric files with [fixel2voxel](https://mrtrix.readthedocs.io/en/3.0.2/reference/commands/fixel2voxel.html) and warp those as demonstrated above. You’d lose the fixel resolution but it is the most straight-forward.

Or you could warp the subject-specific VOIs (`-interp linear` or `nearest`) and images to template space and perform the analysis there.

---

<div class="post-metadata">

**Author:** ![ChrisvdW](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/c/d26b3c/32.png) [@ChrisvdW](https://community.mrtrix.org/u/ChrisvdW)\
**Post date:** [January 8, 2021, 5:50pm UTC](https://community.mrtrix.org/t/transform-from-template-space-to-subject-space/4406/7 "2021-01-08T17:50:29Z")

</div>

Dear Max,

Many thanks for your reply!!! Together with your suggestion for fixel2voxel and discovering a mix-up in the used files, I managed to creat the images in subject space and voxel space.

Greetings,  
Chris
