Multi tissue multi shell FOD and response function

Hi Everyone,

I am interested in performing multi-tissue multi-shell response function and FOD estimate.

My DWI data has following b-values

0 500 1500 2500 3500 
6 12   24  36    48 

So far I am able to generate the multi-shell and multi-response function for this data using both msmt_5tt and dhollander

Example with msmt_5tt is as follows

dwi2response msmt_5tt dwi.mif my_5tt.mif wm.txt gm.txt csf.txt -mask mask.mif -lmax 8,8,8 -shell 1500,2500,3500

But when I use the output ‘.txt’ files to estimate FOD using

dwi2fod msmt_csd dwi.mif wm.txt wm.mif gm.txt gm.mif csf.txt csf.mif -mask mask.mif -lmax 8,8,8 -shell     
1500,2500,3500

I keep getting this error message

number of rows in response function must match number of b-value shells

I have clearly mentioned the number of b-value shells I would like to use.

I have also checked the output of my response function file which is as follows

wm.txt

547.6313646948724 -250.4303894385871 77.24787996362932 -21.02773826429539 4.452842227018421
408.1771414782189 -228.0468978985773 95.04913213703126 -30.26671117660446 6.540515497931798
342.7939470360482 -211.9949568120197 106.6607799792834 -43.86963236424042 10.40864653012106

gm.txt

518.7236152758325
289.0359035526531
180.7231015595339

csf.txt

331.7212514289619
160.0963098878259
116.6095692952874

I am not sure, why I am getting this error.

Could some please shed some light on this.

Thanks.

The problem is that the dwi2fod command does not honor the -shells option when using the msmt_csd algorithm, so it tries to use a three-shell response on 5 shell data. I suppose this is something that should be fixed in the future.

However, there is no reason to leave out the bottom shells when estimating the responses. If you rerun dwi2response as:

dwi2response msmt_5tt dwi.mif my_5tt.mif wm.txt gm.txt csf.txt -mask mask.mif

then

dwi2fod msmt_csd dwi.mif wm.txt wm.mif gm.txt gm.mif csf.txt csf.mif -mask mask.mif

should work. Note also, that you had the -lmax option wrong: lmax for csf and gm should be 0, but you could also omit the option and have the command figure out appropriate lmaxes.

I was a bit surprised too, but this explains indeed what happens.

Yes, agreed. I may be mistaken, @isAarya, but I have the feeling you did this consciously for some specific experiment? If it were for a practical scenario (and not a more technically experimental setting), I’d certainly advise to not get rid of the b=0 data (“shell”) specifically: there is a lot of important information specifically in the contrast of b=0 versus the higher b-values that contributes significantly to distinguishing the 3 typical tissue types (WM, GM, CSF).

@isAarya: you can also see this makes sense, because the GM and CSF responses don’t have any higher order terms (see what you copy-pasted there: it’s only a single column, not multiple values per row as with the WM one). But as @bjeurissen also said, you could simply omit the -lmax option. For the data you’re working with here, it would’ve defaulted to lmax=8 for WM and lmax=0 for GM and CSF, which is what you’d want.

All that said, if you do want to consciously try MSMT-CSD using only those 3 b-values, and on purpose not use the b=0 and b=500 data, you can use dwiextract with the -shell option to select your b-values, and use the output of that as the input of dwi2fod (or pipe it straight in there). But I have the feeling (correct me if I’m wrong) your intention was maybe only to exclude the b=500 data…? In that case, don’t forget to explicitly include 0 as a b-value in your -shell list: it’s not included automatically! I know this is a bit confusing, but the MRtrix “logic” and terminology regards b=0 also as a “shell” (which is indeed debatable, but it’s in practice more convenient for the design of the software).

@bjeurissen

Alright I will try this option. But then doesn’t it include all the b-value shells ?

@ThijsDhollander. Yes you are right ( I wanted to exclude only 500 shell), I wanted to very specifically use the b-values mentioned. But as suggested by @bjeurissen will the response function and csd assume the b=0 shell ?

I will include the b=0 value as you have suggested.

I will also try to extract some of the shells using dwiextract and see how it goes.

Thank you both for pointing out the lmax errors.

Kind regards

Using my suggestion all shells will be used (for all tissue types). If you want to exclude a specific shell, it is easiest to extract the desired shells first from the data using dwiextract and then proceed as I suggested above.

@bjeurissen and @ThijsDhollander.

Thanks both your suggestion worked.

Kind regards.

Aha, good to hear, that clarifies a lot! So to clarify from our end too: the b=0 is never assumed, but regarded just as another “shell”. The easiest way to get your mindset in the right mood when working with MRtrix is to think of “shell” as “b-value”. So you’re selecting b-values with the -shell option. The b=0 value/“shell” doesn’t have a special status (but it may be of particular value to you of course).

What @bjeurissen mentioned, is that there’s currently a bug in dwi2fod msmt_csd though: it essentially ignores the -shell option altogether. So what the msmt_csd algorithm got confronted with is a set of response functions with only 3 b-values, whereas the data had 5 b-values (and the -shell option didn’t do its work to reduce those to 3 as well). Hence mismatch, hence the error that you got. But this is definitely a bug. In the mean time, you can overcome this, by making sure you only feed in a dataset with the b-values that you need (and not the ones that you don’t need, i.e. b=500 in your scenario).

There’s 2 ways for you to proceed now (both achieve exactly the same end result, it’s just different in how you execute them). The easiest is do dwiextract before you do any other step (including dwi2response). If you do that, you don’t have to worry about a -shell option any more: that selection will have already been made “once and for all”. This would work like this:


dwiextract dwi.mif dwi_without_b500.mif -shell 0,1500,2500,3500

dwi2response dhollander dwi_without_b500.mif wm.txt gm.txt csf.txt -mask mask.mif

dwi2fod msmt_csd dwi_without_b500.mif wm.txt wm.mif gm.txt gm.mif csf.txt csf.mif -mask mask.mif

Things to note:

  • See how I included b=0 at the start in -shell 0,1500,2500,3500
  • See how both subsequent command lines become much “cleaner”. The b=500 is already safely dismissed by then, and I just use the dwi_without_b500.mif as the inputs there. You can of course give it a shorter name for convenience; my example just aims to be quite explicit with file names there. :slight_smile:

The other way would be closer to what you were trying to do, but would involve a -shell option to dwi2response but still another one to dwiextract before dwi2fod. It would work, but is unnecessarily complicated. :grin:

Finally: dwi2response doesn’t even need the -mask if you’re working on typical human data, it can automatically do a dwi2mask itself if you don’t give it the -mask. If you do supply it to dwi2response, make sure that it covers a whole brain though, and not for instance just the white matter or something. dwi2response needs regions of GM and CSF within the mask to be able to extract those response functions of course.

Finally-finally: unless you’re looking at very exotic data (from the point of view of what was scanned), the dhollander algorithm should at this stage perform at least as good, and most of the time better than the msmt_5tt algorithm to extract the responses. In cases of several “common” pathologies, it even performs much better, as the default 5tt segmentations that we offer out of the box can make significant mistakes there. If you’ve got questions specifically for your data/subject(s) at hand and you don’t mind disclosing, definitely just describe or show a few screen shots and I can reassure (if applicable) you about this. :wink:

EDIT: wow, that response took so long to type with other things happening over here in between… that I got beaten by 20 minutes with other responses. :crazy_face:

Hi again @isAarya,

Just to briefly let you know: the actual bug has been fixed by @bjeurissen in the mean time. Coincidentally, a more major MRtrix release (candidate) was scheduled to happen today, and this bug fix has just made it in in time (thanks to you drawing our attention to the bug)!

Click here for more information about the bigger update that happened minutes ago.

(there’s some kudos for you in there :wink:)

If you update your MRtrix installation via git pull and ./build, you get all the new features as well as the bug fix for the -shell option to dwi2fod msmt_csd! :smile:

Cool…:smiley:

1 Like

A post was split to a new topic: Dwi2response dhollander questions