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
293 stars 180 forks source link

Mask affine is not respected in dwi2fod #87

Closed samuelstjean closed 10 years ago

samuelstjean commented 10 years ago

I just cloned the master branch for the 0.3 version and tested a strange behavior from csdeconv in mrtrix 0.2

From my understanding, mrtrix always use the information from the affine matrix at every step. For example, tracking on fodf inside a mask with another affine will produce wrong tracts, since the two volume won't be overlaid correctly.

Although, when using csdeconv (and also dwi2fod), the -mask option does not use the affine information from the mask. Using a different affine on the dwi and on the mask seems to not consider the affine in the mask.

Either the affine in the mask is discarded/not used, or it uses the same affine as in the dwi. If the two volumes are overlaid without considering the affine, then everything works. Is this the intended behavior for the mask? What seems strange is the fact that streamtrack uses the affine from the mask while csdeconv does not seem to use it.

jdtournier commented 10 years ago

This is indeed the case, and is exactly the same as it was in the 0.2.X branch. Basically, the ability to use a mask with a different transform comes for free when tracking since each new streamline vertex is represented as a point in continuous scanner space - mapping to the equivalent position in the mask always involves transforming into the mask's voxel space, whether that space is the same as the DWIs or not.

This is different from masking operations applied to images, as is the case in dwi2fod or any other voxel-wise application. In such cases, using a mask with a different transform essentially requires regridding the mask to the voxel space of the DWIs before it can be used, which is a bit of a waste of time given how seldom this would be needed, and also a little ill defined when voxel sizes, orientations, etc of the mask and DWIs have nothing to do with each other.

I have wondered in the past whether this would be something worth supporting, but I've yet to come across a situation where I thought this would be useful in practice - certainly not to the extent that it would warrant the additional code complexity.

One thing that might be worth adding to the code in cases where a mask is applied voxel-wise is a check to ensure the two image transforms match (to within some tolerance), so that either processing is terminated, or preferably a warning is issued to alert the user to fact that the transform of their mask is being ignored.

samuelstjean commented 10 years ago

Ok, I hadn't though about issues of track space vs image space per se. Well, I guess this can be closed as a false issue then, my mistake.

I stumbled upon this when realizing that my dwi had a strange affine by mistake, the csd model was good, but the tracking was destroyed of course, even though the mask was the same image space-wise.

So it's an intended behavior after all, thank you for the explanation.