# Multi tissue multi shell FOD and response function

**URL:** <https://community.mrtrix.org/t/multi-tissue-multi-shell-fod-and-response-function/1091>\
**Category:** Uncategorized\
**Created:** [August 7, 2017, 11:13pm UTC](https://community.mrtrix.org/t/multi-tissue-multi-shell-fod-and-response-function/1091 "2017-08-07T23:13:12Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![isAarya](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/i/6a8cbe/32.png) [@isAarya](https://community.mrtrix.org/u/isAarya)\
**Post date:** [August 7, 2017, 11:13pm UTC](https://community.mrtrix.org/t/multi-tissue-multi-shell-fod-and-response-function/1091/1 "2017-08-07T23:13:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bjeurissen](https://community.mrtrix.org/user_avatar/community.mrtrix.org/bjeurissen/32/28_2.png) [@bjeurissen](https://community.mrtrix.org/u/bjeurissen)\
**Post date:** [August 7, 2017, 11:50pm UTC](https://community.mrtrix.org/t/multi-tissue-multi-shell-fod-and-response-function/1091/2 "2017-08-07T23:50:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ThijsDhollander](https://community.mrtrix.org/user_avatar/community.mrtrix.org/thijsdhollander/32/1617_2.png) [@ThijsDhollander](https://community.mrtrix.org/u/ThijsDhollander)\
**Post date:** [August 8, 2017, 12:03am UTC](https://community.mrtrix.org/t/multi-tissue-multi-shell-fod-and-response-function/1091/3 "2017-08-08T00:03:33Z")

</div>

> [@bjeurissen](#):
>
> 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 was a bit surprised too, but this explains indeed what happens.

> [@bjeurissen](#):
>
> However, there is no reason to leave out the bottom shells when estimating the responses.

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).

> [@bjeurissen](#):
>
> Note also, that you had the -lmax option wrong: lmax for csf and gm should be 0,

@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).

---

<div class="post-metadata">

**Author:** ![isAarya](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/i/6a8cbe/32.png) [@isAarya](https://community.mrtrix.org/u/isAarya)\
**Post date:** [August 8, 2017, 12:21am UTC](https://community.mrtrix.org/t/multi-tissue-multi-shell-fod-and-response-function/1091/4 "2017-08-08T00:21:42Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![bjeurissen](https://community.mrtrix.org/user_avatar/community.mrtrix.org/bjeurissen/32/28_2.png) [@bjeurissen](https://community.mrtrix.org/u/bjeurissen)\
**Post date:** [August 8, 2017, 12:43am UTC](https://community.mrtrix.org/t/multi-tissue-multi-shell-fod-and-response-function/1091/5 "2017-08-08T00:43:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![isAarya](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/i/6a8cbe/32.png) [@isAarya](https://community.mrtrix.org/u/isAarya)\
**Post date:** [August 8, 2017, 12:46am UTC](https://community.mrtrix.org/t/multi-tissue-multi-shell-fod-and-response-function/1091/6 "2017-08-08T00:46:14Z")

</div>

@bjeurissen and @ThijsDhollander.

Thanks both your suggestion worked.

Kind regards.

---

<div class="post-metadata">

**Author:** ![ThijsDhollander](https://community.mrtrix.org/user_avatar/community.mrtrix.org/thijsdhollander/32/1617_2.png) [@ThijsDhollander](https://community.mrtrix.org/u/ThijsDhollander)\
**Post date:** [August 8, 2017, 1:01am UTC](https://community.mrtrix.org/t/multi-tissue-multi-shell-fod-and-response-function/1091/7 "2017-08-08T01:01:59Z")

</div>

> [@isAarya](#):
>
> Yes you are right ( I wanted to exclude only 500 shell)

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:

```auto

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. 🙂

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. 😁

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. 😉

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. 🤪

---

<div class="post-metadata">

**Author:** ![ThijsDhollander](https://community.mrtrix.org/user_avatar/community.mrtrix.org/thijsdhollander/32/1617_2.png) [@ThijsDhollander](https://community.mrtrix.org/u/ThijsDhollander)\
**Post date:** [August 8, 2017, 2:29am UTC](https://community.mrtrix.org/t/multi-tissue-multi-shell-fod-and-response-function/1091/8 "2017-08-08T02:29:34Z")

</div>

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.](https://community.mrtrix.org/t/mrtrix-3-0-release-candidate-2/1065)

(there’s some kudos for you in there 😉)

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`! 😄

---

<div class="post-metadata">

**Author:** ![isAarya](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/i/6a8cbe/32.png) [@isAarya](https://community.mrtrix.org/u/isAarya)\
**Post date:** [August 8, 2017, 9:44pm UTC](https://community.mrtrix.org/t/multi-tissue-multi-shell-fod-and-response-function/1091/9 "2017-08-08T21:44:44Z")

</div>

Cool…😃

---

<div class="post-metadata">

**Author:** ![ThijsDhollander](https://community.mrtrix.org/user_avatar/community.mrtrix.org/thijsdhollander/32/1617_2.png) [@ThijsDhollander](https://community.mrtrix.org/u/ThijsDhollander)\
**Post date:** [August 10, 2017, 6:31am UTC](https://community.mrtrix.org/t/multi-tissue-multi-shell-fod-and-response-function/1091/10 "2017-08-10T06:31:55Z")

</div>

A post was split to a new topic: [Dwi2response dhollander questions](https://community.mrtrix.org/t/dwi2response-dhollander-questions/1095)
