# Dwi2fod error - cannot open .txt image (group response)

**URL:** <https://community.mrtrix.org/t/dwi2fod-error-cannot-open-txt-image-group-response/559>\
**Category:** Uncategorized\
**Created:** [November 8, 2016, 5:02pm UTC](https://community.mrtrix.org/t/dwi2fod-error-cannot-open-txt-image-group-response/559 "2016-11-08T17:02:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbishop](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/j/f05b48/32.png) [@jbishop](https://community.mrtrix.org/u/jbishop)\
**Post date:** [November 8, 2016, 5:02pm UTC](https://community.mrtrix.org/t/dwi2fod-error-cannot-open-txt-image-group-response/559/1 "2016-11-08T17:02:46Z")

</div>

Dear Experts,

I’m running into trouble getting the dwi2fod script to open my group (or individual) FOD .txt files. I am using the following commands:

First for each individual subject:  
dwi2response tournier -fslgrad ${currentsubject}\_1\_mrtrix\_new\_bvecs ${currentsubject}\_1\_mrtrix\_new\_bvals ${currentsubject}\_1\_Bias\_Field\_Corrected\_dwi.nii.gz ${currentsubject}\_1\_response\_function\_tournier.txt -force

Secondly, I then create a group response function:  
average\_response \*.txt Group\_average\_response.txt

I have subsequently opened the text files with shview and all seems great, however, when I attempt to use the group response with the dwi2fod command it errors out and cannot open the .txt file. (see screenshot for error)

 ![](https://community.mrtrix.org/uploads/default/original/1X/c8234895a3a539d30855c1c65bc362f8dd1402fa.png)

I have low b value data (b=1000) and only 56 directions but the response function seems correct (see screenshot)

 ![](https://community.mrtrix.org/uploads/default/original/1X/eb97943e05931d868c7b252b1bb65286b296e6a4.png)

Thank you in advance for the help,

James

---

<div class="post-metadata">

**Author:** ![jdtournier](https://community.mrtrix.org/user_avatar/community.mrtrix.org/jdtournier/32/2594_2.png) [@jdtournier](https://community.mrtrix.org/u/jdtournier)\
**Post date:** [November 8, 2016, 5:28pm UTC](https://community.mrtrix.org/t/dwi2fod-error-cannot-open-txt-image-group-response/559/2 "2016-11-08T17:28:50Z")

</div>

It looks like you’re missing a lone `-` after `dwi2fod msmt_csd`… This is the [expected syntax](http://mrtrix.readthedocs.io/en/latest/reference/commands/dwi2fod.html) for a single shell analysis:

```
dwi2fod msmt_csd input response output 

```

Without the dash in place of `input`, `dwi2fod` thinks argument 2 (your response) is the input image. What I don’t understand is why the error message isn’t that it’s got too few arguments though…

---

<div class="post-metadata">

**Author:** ![jbishop](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/j/f05b48/32.png) [@jbishop](https://community.mrtrix.org/u/jbishop)\
**Post date:** [November 8, 2016, 6:08pm UTC](https://community.mrtrix.org/t/dwi2fod-error-cannot-open-txt-image-group-response/559/3 "2016-11-08T18:08:53Z")

</div>

I think I had that flag when I ran it originally but just in case I reran it with it and i’m still generating this error. I’ve highlighted the flag in purple:

 ![](https://community.mrtrix.org/uploads/default/original/1X/d13c1055861ea02692b82069457b2b77d3fbad0e.png)

---

<div class="post-metadata">

**Author:** ![jbishop](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/j/f05b48/32.png) [@jbishop](https://community.mrtrix.org/u/jbishop)\
**Post date:** [November 8, 2016, 6:13pm UTC](https://community.mrtrix.org/t/dwi2fod-error-cannot-open-txt-image-group-response/559/4 "2016-11-08T18:13:48Z")

</div>

Scrap this message. I was missing a “-” at the end of the flag. My apologies.

James

---

<div class="post-metadata">

**Author:** ![rsmith](https://community.mrtrix.org/user_avatar/community.mrtrix.org/rsmith/32/2672_2.png) [@rsmith](https://community.mrtrix.org/u/rsmith)\
**Post date:** [November 9, 2016, 12:31am UTC](https://community.mrtrix.org/t/dwi2fod-error-cannot-open-txt-image-group-response/559/5 "2016-11-09T00:31:58Z")

</div>

> What I don’t understand is why the error message isn’t that it’s got too few arguments though…

This all got reworked when `msdwi2fod` was merged into `dwi2fod`. Can no longer rely on the parser to check the number of arguments since it’s algorithm-specific, but some common tasks are still performed before branching out depending on the algorithm choice. So input image is opened [here](https://github.com/MRtrix3/mrtrix3/blob/master/cmd/dwi2fod.cpp#L223), whereas number of input arguments is only checked [here](https://github.com/MRtrix3/mrtrix3/blob/master/cmd/dwi2fod.cpp#L240-L241).

One option might be to `try {} catch` the input header open, and concatenate the error message with something more useful / specific, e.g.:  
`[ERROR] expected first argument after algorithm choice to be the input DWI; instead received "..."`  
?

---

<div class="post-metadata">

**Author:** ![jdtournier](https://community.mrtrix.org/user_avatar/community.mrtrix.org/jdtournier/32/2594_2.png) [@jdtournier](https://community.mrtrix.org/u/jdtournier)\
**Post date:** [November 11, 2016, 8:27am UTC](https://community.mrtrix.org/t/dwi2fod-error-cannot-open-txt-image-group-response/559/6 "2016-11-11T08:27:58Z")

</div>

OK, makes sense. I think we can still check the numbers of arguments to make sure it’s even and \>=4. That would have caught the mistake above.

Not convinced about trying too hard to provide a more useful error message here. It’s clear enough that the command is trying to open the response as if it was an image. There’s lot of ways the command arguments could get messed up, I don’t think it’s worth the effort to try to predict them all…
