MRtrix3 / mrtrix3

MRtrix3 provides a set of tools to perform various advanced diffusion MRI analyses, including constrained spherical deconvolution (CSD), probabilistic tractography, track-density imaging, and apparent fibre density
http://www.mrtrix.org
Mozilla Public License 2.0
295 stars 182 forks source link

mrgrid: Pad via duplication #2793

Open Lestropie opened 10 months ago

Lestropie commented 10 months ago

In the origin story of dwifslpreproc, I had to deal with the scenario where the user's input DWIs had one or more spatial axes with odd size. When first released, FSL only came with a single config file for topup, and it included downsampling the image data by a factor of 2 in earlier iterations; running this on such an image would result in the command crashing. My original solution was to crop planes from the DWIs as necessary to make the size even; later I changed this to instead pad the image through duplication of planes, such that subsequent removal of those planes would return the DWIs back to the same size as the original.

Since then, FSL now provides multiple topup config files, including one that doesn't involve any downsampling. Though I'm conscious that topup already takes a long time to compute, and not downsampling in early iterations pushes this out even further. So I've not deprecated that code.

The way dwifslpreproc currently achieves this is through mrconvert to extract the plane to duplicate, and mrcat to do the padding. This also means that Header::concatenate() can do its magic with respect to things like the slice timing vector if necessary. I am however now in a context where this technique causes problems.

A better way would be to use a single mrgrid call, specifying which axes need to be padded and by how much. I however currently see two potential issues with its use in this way:

  1. Currently the padding operation only supports filling by a scalar value. In order to minimally bias the subsequent image processing operation, being susceptibility field estimation, I would prefer that the operation instead involve duplication of the planes at the edge of the image FoV.

  2. The process of concatenating two images may have consequences for metadata; in the context of dwifslpreproc, specifically slice timing. mrgrid should ideally perform the expected manipulations of such data; preferably through the actual use of Header::concatenate() so that it is all centralised and any future explicit support of new metadata fields of interest should propagate.