Dear Mrtrix experts,
I am trying to convert DICOM folders containing anatomical and DWIs images using mrconvert.
Should I adjust/set the -stride and if yes how?


That will depend on exactly what you’re trying to achieve, but in general, if you’re planning on processing your images within MRtrix, there shouldn’t ever be any need to change the strides - all applications will handle the data just fine.

The only times you’ll need to worry about this is when interacting with other packages that may not handle these issues too well - or at least, handle them differently. One example is displaying an overlay on an image within FSLView - if the strides differ between the images, the overlay will generally be all wrong (at least it was the last time the issue was raised…), whereas it would be just fine in MRView. But I’ve spent quite a bit of time making sure this issue with mismatched strides / transform in NIfTI images doesn’t happen - at least not routinely: NIfTI images produced by MRtrix3 should match the strides / transform of the input image, which should avoid these types of problems.

The other time you might want to change the stride is to avoid explicit preload-to-RAM operations that might happen in some applications. For example, tckgen will preload the source data to RAM if the datatype is not native 32-bit float or the strides do not correspond to a volume-contiguous layout. This is done to allow the fastest possible access to the image data during processing, which helps quite a bit with performance during tracking. But if you do lots of small tractography jobs and you see the application is constantly preloading data, you may find that something like:

$ mrconvert data.nii -datatype float32 -stride 0,0,0,1 data_no_preload.mif

and feeding that into tckgen instead will avoid those preloads - the data will be accessed as-is via memory-mapping - no explicit loading required. Note that dwi2fod produces volume-contiguous images by default; but only if the output format is *.mif/mih - none of the other file formats support volume-contiguous storage…

And yes, that -stride option to mrconvert is how you can adjust it. It’s also available in a few other commands where it makes sense. The whole issue of strides is now discussed in a bit more detail here, if you’re interested.

?Bug in warpinit

Thanks Donald for the reply.
I also read the part that you mentioned. I think RAS should be changed to LAS in the following paragraph.

However, this is only a convention, and many other combinations are possible. For instance, it is possible to start from the right posterior inferior corner, and raster through along the left direction, then store the next row along the anterior direction, and finally the next slice in the superior direction. This scheme is what is normally used in the now deprecated Analyse format, and is commonly referred to as RAS or radiological.

Am I right?


Spot on… I’ll go fix that when I have a minute.
Thanks for the report!


I am trying to convert Gre mag/phase files to nii and I get this warning: slice gap detected (maximum gap: 0.28 mm). I wonder if this warning should be considered seriously.


Well, it should be taken seriously in that there really does seem to be a slice gap: the separation between slice centres is clearly larger than the stated slice thickness. How seriously you take this into account will depend on what you want to do with the images, and indeed whether you were expecting this…


Thanks for the response.