I want to use the population_template function to a) make a template (duh) and then b) also use the warp files produced by the population template function to align the DWI data from the subjects into template space.
In other words, I want to a) make a template from n subjects, b) move the DWI data from these n subject into the just generated template space.
I have been using the population_template function the following way: population_template WM/ output_WM_temp.mif GM/ output_GM_temp.mif csf/ output_CSF_temp.mif -warp_dir warps
The template looks decent, so I think the command was successful. The warps in the warps folder then have 5 dimensions i.e. 189 x 194 x 139 x 3 x 4.
To extract a single warp image I used:
While the commands work and produce proper output, it does not do a good alignment of the DWI to the template I generated. Any suggestions what I am doing wrong?
What confuses me, is that a single warp should have the dimensions 189 x 194 x 139 x 3, while the files in the warp directory have 189 x 194 x 139 x 3 x 4, indicating that they are 4 warps, but I had only 3 different image modalities, so I think the files should be 189 x 194 x 139 x 3 x 3.
Where does the extra warp come from?
All the best
P.S. I hope that was comprehensible?
…a single 5D file that stores all 4 warps image1->mid->image2, and image2->mid->image1. The 5D warp format stores x,y,z deformations in the 4th dimension, and uses the 5th dimension to index the 4 warps.
So the four warps being indexed in that fifth dimension are not for different modalities but rather
So what is image1 and what is image2? Image1 is the input image and image2 is the template?
Good question I’m not entirely sure. It’s an easy thing to get backwards so I don’t dare try to give my guess
If so, I would need to combine the first and the second transform to get a transform from input to template?
How do I combine such two transforms?
I could help with composing deformation fields if it’s needed but it’s likely not needed:
I think mrtrix tools can be configured to generate the 5D warp array as output or they can be configured to generate deformation fields img1 → img2 directly:
Warps can be saved as two deformation fields that map
directly between image1->image2 and image2->image1, or if using
-nl_warp_full as a single 5D file that stores all 4 warps
image1->mid->image2, and image2->mid->image1.
See also the -nl_warp versus -nl_warp_full options on mrregister
If you use mrtrix’s transform tool, mrtransform, then it also can ingest the 5D warp array and use it direclty; see the option -warp_full as opposed to -warp on mrtransform.
Hm, I don’t quite follow, what you cite is from the docs of mrregistermrregister — MRtrix 3.0 documentation
But I am using the commands population_template and mrtransform and I can’t find the options -nl_warp_full or not full for either of these commands.
So what you suggest is that population_template calls the mrregister using the -nl_warp_full option, while mrtransform seems to expect the non full version.
So I am in the pickle and can’t use said 5D transform, and the way out isn’t obvious to me.
So I am still stuck with 5D warp files and need to find out how to combine the two warp files.
mrtransform should be able to internally combine the image1->mid->image2 (or vice versa) warps as suggested using the -warp_full option. So from your original command, instead of deconstructing your 5D warps, feed the whole thing to mrtransform, replacing -warp with -warp_full, does that make sense?
The documentation for mrtransform explains the options in more detail, I don’t personally have experience with using the 5D warps.
Thanks, it works.
So back to question one I posed correcting all that is needed changing -warp to -warp_full and boom all works as intended. population_template WM/ output_WM_temp.mif GM/ output_GM_temp.mif csf/ output_CSF_temp.mif -warp_dir warps