Free water compartment analysis

Dear MRtrix3 team and users,

I’m interested in splitting the diffusion contribution in two: the free water compartment and the tissue compartment, as suggested by these two papers: doi 10.1002/mrm.22055 and doi 10.1016/j.jalz.2017.12.007.

I was just wondering if is there any commands related to it in MRtrix3.


Funny, I’ve just had recent conversations about precisely this…

Short answer is: I think we can do something that approximates this very well relatively easily. I’d need to work out the exact sequence of commands though, but it shouldn’t be too difficult.

Give me a minute to work this through, I’ll update once I have something.

OK, this seems to kinda work. It’s not the same approach as in the paper mentioned, but I think it’s a broadly similar idea. The main difference is it takes out the CSF contribution from the raw DWI signal, rather than computing both the CSF fraction and tensor elements jointly. In my opinion, this makes it more general since you end up with the CSF-suppressed DWI signal, which you can process however you want – but the disadvantage is that downstream processing will probably become unstable in regions where there is no longer much signal – as you’ll see from the screenshots below.

The main idea is:

  • use MSMT CSD to obtain the CSF fraction
  • forward-model the CSF fraction to generate its predicted signal in the DWI
  • subtract this from the original DWI

Here’s what the commands looks like:

# Get response function for MSMT-CSD:
dwi2response dhollander dwi.mif -mask mask.mif wm.txt gm.txt csf.txt

# Perform MSMT-CSD fit
# If data are single-shell, drop the last two arguments to omit the GM from the MSMT CSD fit:
dwi2fod msmt_csd dwi.mif -mask mask.mif wm.txt wm.mif csf.txt csf.mif gm.txt gm.mif   

# Forward-project CSF fraction onto DWI
# Here, we need to remove the DW scheme from the final CSF signal image header,
# otherwise it can mess things up later on:
shconv csf.mif csf.txt - | sh2amp - dwi.mif - | mrconvert - -clear dw_scheme dwi_csf.mif

# Subtract CSF signal from the original DWI:
mrcalc dwi.mif dwi_csf.mif -sub dwi_fwe.mif

Here’s what this produces on some test data. As you can see, the DTI fit becomes unstable in CSF regions. Not sure if that’s what you were after…

Estimated CSF fraction:


b=0 volume:

left: original; right: with free-water elimination

FA map:

left: original; right: with free-water elimination

MD map

left: original; right: with free-water elimination


Great. It might work for my purposes. Thanks a lot, Donald.


Hi @jdtournier,

I’m interested to try this approach in my dataset (neonatal data), however I don’t have the last mrtrix version (I have the version 3.0_RC3-15-g9494da8d), so I have to edit some of the commands:

mrconvert input.nii.gz dwi.mif -fslgrad bvec bval -export_grad_mrtrix grad.txt
dwi2response dhollander dwi.mif -mask mask.nii.gz wm.txt gm.txt csf.txt -fa 0.1 -voxels voxels.mif
dwi2fod msmt_csd dwi.mif -mask mask.nii.gz wm.txt wm.mif csf.txt csf.mif
shconv csf.mif csf.txt - | sh2amp - -gradient grad.txt - | mrconvert - -clear_property prior_dw_scheme dwi_csf.mif

But when I do the final step: mrcalc dwi.mif dwi_csf.mif -sub dwi_fwe.mif

It shows the following error:

mrcalc: [ERROR] dimensions of input images do not match - aborting

The dimensions are 128 x 128 x 56 x 153 (dwi.mif) and 128 x 128 x 56 x 64 (dwi_csf.mif), I think the problem is in the sh2amp command (because in this version I can not put an image to sample to the same directions), is there any work around to solve this, without updating to the most recent version? Thanks in advance.

Best regards,


Yes, unfortunately you’ll need these changes to shconv and sh2amp, which are only available in 3.0.0. The main issue is that both commands were only capable of handling single-shell data till now.

This can probably be done using older versions, but it would require a lot of scripting and massaging to handle each shell in turn and recombine into a coherent DWI data set – and the b=0 volumes will probably need to be handled separately as well. I personally wouldn’t recommend it. But you can always install 3.0.0 alongside your main installation if that helps…? Recent discussion on this topic here.


Thanks for you reply, I will do that.

Best regards,