Dwi2tensor: how to quantify the goodness of the fitting?

Dear MRtrix experts,

Is there a way to retrieve some metrics (say sum of squared error) for quantifying the goodness of the fitting? If not, is there a recipe that can be used to calculate such metrics given the output of dwi2tensor?

Thanks much,

You can use the -predicted_signal option of dwi2tensor to output the diffusion weighted data set predicted from the model parameters:

dwi2tensor -mask mask.mif dwi.mif dt.mif -predicted_signal dwi_hat.mif

Using the predicted and original signal, you can then easily obtain the raw residual using mrcalc:

mrcalc dwi.mif dwi_hat.mif -subtract residual.mif

From there, it should be straightforward to calculate error metrics through further manipulation of the raw residual using mrcalc, mrmath, and/or mrstats, depending on what exactly you are after.

1 Like

is there a similar way for the fod estimation ?
I do not see a similar option for dwi2fod


So far, the -predicted_signal option is only part of the dev branch (docs) but is going to be part of the next release candidate.

Thanks Ben.

If I use >=2 iterations for iterative reweighted LLS, is it true that the weights utilized for current iteration are calculated as squares of predicted signals of previous iteration and can be approximated by using the output predicted signals (because of convergence)?


Is there a similar way for the fod estimation?

Having the -predicted_signal option in dwi2fod in the future will make this a lot more convenient, but you can in fact achieve the same currently: it’s just a matter of performing a forward convolution of the FOD(s) with the response function(s) (as opposed to deconvolution). There may be some additional gymnastics required to deal with the fact that shconv can only handle one b-value at a time, but it can be done.

I see that “-predicted_signal” is now an option for dwi2fod in the latest release. Any thoughts on best practices to use FOD residuals to detect image artefacts? Would just looking for large residuals work, or would the FODs fit most artefacts fairly well too? Would there be any benefit in reducing the lmax?

Hey Tom!

Good question. I’ve not really looked into it yet, but I think it would definitely be useful to look for large residuals (at least, larger residuals than are typical for that data set). I don’t think the FOD would fit such artefacts well, primarily because the CSD constraint is so effective. I expect residual fat sat artefacts would be very prominent in these maps.

I’m not sure about reducing the lmax though – I think the main thing is going to be the smoothness of the response function (not much you can do to the FOD, even at high lmax, that would produce non-smooth signal predictions if the response is smooth). This is something I’d like to look into for QC, but haven’t had the time for…

Also, note that I expect there to be some residual structure in the residuals. The CSD model is always going to be an approximation, so it would be quite remarkable if the residuals turned out to be pure noise…


Hi Donald,

I hope you are well, we should catch up on another channel :slight_smile:.

Sorry I missed your reply (I was overly aggressive with my notification settings). We will have a look into it and report back.



1 Like