Reslicing volumes to a template

Dear MRTrix community,

I have a question about reslicing volumes to the exact voxel space of a template.

For volumes of the same orientation the command:

mrtransform <volume_to_reslice> -template <template_volume> resliced_volume

works fine for me

When volumes are with different orientation (let say sagitall vs axial), such as typical 3D T1 and DWI

mrtransform <volume_to_reslice_sag> -template <template_volume_ax> resliced_volume

returns a resliced volume with the original sagittal orientation; therefore to get the desired axial orientation I have to workaround by playing with the “-stride” option of mrconvert command:

mrconvert <resliced_volume> -stride <strides read from mrinfo <volume_to_reslice_sag>> <resliced_volumeOK>

Do you have any suggestion to automatically get reslice with the actual template orientation?

Thanks,

Marco

Yes, I can see that it would seem sensible to have the strides default to those of the template. Unfortunately as things stand, what you’ve got is about the easiest it’s going to be - without us making modifications to the code, at any rate.

In the meantime, you could script this up a bit with a one-liner like this:

$ mrtransform in.mif -template ref.mif - | mrconvert - -stride $(mrinfo ref.mif -stride | tr ' ' ',') out.mif

Going forwards, we can look at doing something about this for the next release. A simple addition would be to add the -stride option to mrtransform, which would make the final mrconvert call redundant. We could also set the strides according to the template, but I’m not completely sure that it’s the best approach in all cases. The main case I’m concerned with is when 4D images are transformed with a 3D template. If the 4D images were stored volume-contiguous (i.e. strides like 2,3,4,1), defaulting to the template’s strides would revert them to spatially-contiguous, which might not be ideal performance-wise. I guess we could offer smarter defaults, but we’d need to think about that…