Hi Chris,<div><br></div><div>I&#39;ve found the bug that was causing your NaNs in the response function - due to floating-point rounding errors causing values just outside the range (-1,1) to be passed to acos(). I&#39;ve attached the patch for that, install as for previous patches (edit as appropriate):</div>

<div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px">$ cd mrtrix-0.2.10<br>$ tar xvfj mrtrix_patch_nan_in_response.tar.bz2<br>$ ./build<br>$ sudo ./build install</blockquote><div><br></div><div>On a different note: in the process of looking at the data you sent over, I had a quick look through your script. There&#39;s a few things I&#39;d like to mention, which I think others might also want/need to hear. Here goes:</div>

<div><br></div><div><b>Using NIfTI to store the DWI data:</b></div><div><b><br></b></div>I notice you&#39;re supplying a NIfTI image for the DWI, and a separate gradient encoding file. While there&#39;s nothing wrong with that per se, you need to make double-sure that your encoding file is correct <i>for each scan</i>. MRtrix assumes gradients are in the scanner coordinate system (also typically assumed in DICOM data - exception being GE), whereas FSL expects assumes they are in the image axes coordinate system. These two won&#39;t match if the images are acquired in a non-axial or oblique plane, and in general won&#39;t match between scans even if acquired using the same protocol. This rotation needs to be accounted for when converting between bvecs/bvals and the MRtrix encoding file. I assume you&#39;ve probably already sorted that out, but thought I&#39;d flag this issue again just in case. <div>

<br></div><div>I would strongly recommend that everyone convert their data directly from the raw DICOM images to .mif (or .mih) format, since the gradient information will then be read directly by MRtrix and stored in the appropriate format within the image header - no need to supply the encoding file separately, which gets rid of a potential source of user error. </div>

<div><br></div><div><b>Use of -normalise option in csdeconv:</b></div><div><br></div><div>I strongly advise <i>against</i> the use of the -normalise option of estimate_response. Although the response function might be normalised, the FODs derived using csdeconv will not be (unless also processed using -normalised, but that introduces other issues with CSF contamination, <a href="http://www.nitrc.org/pipermail/mrtrix-discussion/2012-July/000472.html">as discussed previously in this thread</a>). Using a non-normalised response function and non-normalised csdeconv actually produces relatively well normalised FODs, since the response is then scaled appropriately for the DW signal.</div>

<div><br></div><div><b>Use of gen_WM_mask:</b></div><div><br></div><div>I also strongly advise against the use of gen_WM_mask. It&#39;s a bit of a Heath Robinson hack job, using fairly arbitrary heuristics to kinda identify voxels that ought to correspond to white matter - not really based on sound principles. I included it in the original release as I thought it would provide a good rough mask of WM to seed from, but it&#39;s since become clear that it doesn&#39;t work all that well, and produces variable results depending on the SNR, b-value, and number of directions. In hindsight, I shouldn&#39;t have included in the release, and it won&#39;t be available in future major releases.</div>

<div><br></div><div><br></div><div><b>Creating the mask:</b></div><div><br><div>The command you use creates a mask from a single b=0 image. A more robust approach, now recommended in the documentation, is to use the average of all volumes in the DWI run - basically improves the SNR:</div>

<div><br></div><div><div>$ average dwi.mif -axis 3 - | threshold - - | median3D - - | median3D - mask.mif</div></div><div><br></div><div><br></div><div><b>Getting the single-fibre mask:</b></div><div><br></div><div>This is another command that has changed in recent versions. No big deal, but the current recommended command is:</div>

<div><br></div><div> $ erode mask.mif -npass 3 - | mrmult fa.mif - - | threshold - -abs 0.7 sf.mif</div><div><br></div><div><br></div><div><br></div><div>That&#39;s all I had to say. Just thought I&#39;d take the opportunity to clarify a few things...</div>

<div><br></div><div>Cheers,</div><div><br></div><div>Donald</div><div><br></div><div><br><div><br><div class="gmail_quote">On 27 August 2012 12:18, Donald Tournier <span dir="ltr">&lt;<a href="mailto:d.tournier@brain.org.au" target="_blank">d.tournier@brain.org.au</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Chris,<div><br></div><div>I can&#39;t think of much that could cause this problem, but the most obvious one is supplying an empty single-fibre mask at the estimate_response step. Another reason might have been if any of the single-fibre voxels has one or more zero DW intensities - but I&#39;ve just looked at the code, and there are safeguards in place to handle negative or zero DW intensities, so I can&#39;t see that it could be that either. If none of this helps, maybe you can send me one of the offending data sets so I can have look?</div>


<div><br></div><div>Cheers,</div><div><br>Donald.</div><div><div><div class="h5"><br><br><div class="gmail_quote">On 27 August 2012 11:57, Chris Adamson <span dir="ltr">&lt;<a href="mailto:chris.adamson@mcri.edu.au" target="_blank">chris.adamson@mcri.edu.au</a>&gt;</span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Donald,<br>
<br>
I am getting NaN values in the response.txt file in rare cases. How can<br>
I diagnose the problem/fix it? What should I look for in the data that<br>
would cause a failure of the ellipse fitting?<br>
<br>
Chris.<br>
--<br>
Dr Christopher Adamson, PhD (Melb.), B Software Engineering (Hons.,<br>
Monash)<br>
Research Officer<br>
Developmental Imaging, Critical Care and Neurosciences<br>
<br>
Murdoch Childrens Research Institute<br>
The Royal Children’s Hospital<br>
Flemington Road Parkville Victoria 3052 Australia<br>
T 9906 6780<br>
M XXXX XXX XXX<br>
E <a href="mailto:chris.adamson@mcri.edu.au" target="_blank">chris.adamson@mcri.edu.au</a><br>
<a href="http://www.mcri.edu.au" target="_blank">www.mcri.edu.au</a><br>
<br>
______________________________________________________________________<br>
This email has been scanned by the Symantec Email Security.cloud service.<br>
For more information please visit <a href="http://www.symanteccloud.com" target="_blank">http://www.symanteccloud.com</a><br>
______________________________________________________________________<br>
_______________________________________________<br>
Mrtrix-discussion mailing list<br>
<a href="mailto:Mrtrix-discussion@www.nitrc.org" target="_blank">Mrtrix-discussion@www.nitrc.org</a><br>
<a href="http://www.nitrc.org/mailman/listinfo/mrtrix-discussion" target="_blank">http://www.nitrc.org/mailman/listinfo/mrtrix-discussion</a><br>
</blockquote></div><br><br clear="all"><div><br></div></div></div><span class="HOEnZb"><font color="#888888">-- <br><font color="#ff6600" size="1"><b>Dr Jacques-Donald Tournier<br></b></font><div><font color="#ff6600" size="1">Research Fellow</font></div>

<div><font size="1"><br>
</font></div><div><font size="1">The Florey Institute of Neuroscience and Mental Health</font></div><div><font size="1">Melbourne Brain Centre - Austin Campus</font></div><div><font size="1">245 Burgundy Street</font></div>


<div><font size="1">Heidelberg Â Vic Â 3084</font></div><div><font size="1">Ph: Â +61 3 9035 7033</font></div><div><font size="1">Fax: Â +61 3 9035 7307</font></div><div><font size="1"><a href="http://www.florey.edu.au" target="_blank">www.florey.edu.au</a></font></div>


<br><br>
</font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><font color="#ff6600" size="1"><b>Dr Jacques-Donald Tournier<br></b></font><div><font color="#ff6600" size="1">Research Fellow</font></div><div><font size="1"><br>

</font></div><div><font size="1">The Florey Institute of Neuroscience and Mental Health</font></div><div><font size="1">Melbourne Brain Centre - Austin Campus</font></div><div><font size="1">245 Burgundy Street</font></div>

<div><font size="1">Heidelberg Â Vic Â 3084</font></div><div><font size="1">Ph: Â +61 3 9035 7033</font></div><div><font size="1">Fax: Â +61 3 9035 7307</font></div><div><font size="1"><a href="http://www.florey.edu.au">www.florey.edu.au</a></font></div>

<br><br>
</div></div></div>