<div dir="ltr">Hi Kuan-Tsen,<div><br></div><div>Yes, you are using the Image::Interp class properly, and it's doing what it's designed to do: tri-linear interpolation. It sounds like what you want to do is <i>nearest-neighbour</i> interpolation. The simplest way to do this is probably by transforming the vertices to the image space as you've done, but then round these indices to the nearest integer, and fetch the value using the Image::Position class (which does no interpolation). So this would look like this (changes highlighted in red):</div><div><br></div><div><font face="monospace, monospace">===<br></font><div><font face="monospace, monospace">std::vector<MR::Point> tck; <font color="#6aa84f">// one track got from tck file</font></font></div><div><font face="monospace, monospace">MR::Image::Object image_object;<br>image_object.open(ROI.nii); <font color="#6aa84f">// which is coregistered to DWI</font></font></div><div><div><font face="monospace, monospace">MR::Image::Interp interp (image_object);</font></div><div><font face="monospace, monospace" color="#ff0000">MR::Image::Position pos (image_object);</font></div><div><font face="monospace, monospace">MR::Point <strike style="margin:0px;padding:0px;border:0px;line-height:19.5px"><font color="#ff0000">track_point, </font></strike>voxel_position;</font></div><div><font face="monospace, monospace"><div>for (std::vector< MR::Point>::iterator i = tck.begin(); i != tck.end(); ++i)</div><div> {</div><div><font color="#ff0000"><span style="line-height:19.5px"><strike> float *p = i->get();</strike></span></font></div><div><strike style="margin:0px;padding:0px;border:0px"><font color="#ff0000"><span style="line-height:19.5px"> track_point.set(p);</span></font></strike><br></div><div> voxel_position = interp.R2P (*i);<br></div></font><div style><strike style="font-family:monospace,monospace;margin:0px;padding:0px;border:0px"><font color="#ff0000"><span style="line-height:19.5px"> </span></font></strike><font color="#ff0000" face="monospace, monospace"><span style="line-height:19.5px"><strike>interp.P (voxel_position);</strike></span></font></div><div><span style="font-family:monospace,monospace"><font color="#ff0000"> pos.set (0, round (voxel_position[0]));</font></span></div><div><span style="font-family:monospace,monospace"><font color="#ff0000"> pos.set (1, round (voxel_position[1]));</font></span></div><div><span style="font-family:monospace,monospace"><font color="#ff0000"> pos.set (2, round (voxel_position[2]));</font></span></div><div style><span style="font-family:monospace,monospace"> value = </span><font color="#ff0000" style="font-family:monospace,monospace">pos</font><span style="font-family:monospace,monospace">.value();</span><br></div><font face="monospace, monospace"><div> if(value != 0)</div><div> {</div><div> cout << value << endl ; </div><div> }</div><div> }</div><div>===</div><div><br></div></font><font face="arial, helvetica, sans-serif">Hopefully this'll work as-is, but I have to admit I haven't looked at code from this version of MRtrix for a long time... All our efforts are currently going into the MRtrix3 release, which we'll hopefully have polished enough for a full release by the ISMRM meeting.</font></div></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Cheers,</font></div><div><font face="arial, helvetica, sans-serif">Donald.</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><div class="gmail_extra"><br><div class="gmail_quote">On 7 April 2015 at 04:27, Kuan-Tsen Kuo <span dir="ltr"><<a href="mailto:fixcankuo@gmail.com" target="_blank">fixcankuo@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div dir="ltr"><div class="gmail_quote"><div dir="ltr"><div><span style="font-family:monospace,monospace">Dear all:</span><br></div><font face="monospace, monospace"><br>I would like to transforming the tracks to the ROI space which image valve is integer from 0 to 490,<br>but not sure how to apply the transformation matrix.</font><div><font face="monospace, monospace">So I use MR::Image::Interp to access the voxel intensity of ROI image.<br><br>Here is how I use,<br>===<br></font><div><span style="font-family:monospace,monospace">std::vector<MR::Point> tck; <span style="background-color:rgb(255,255,255)"><font color="#6aa84f">// one track got from tck file</font></span></span></div><div><font face="monospace, monospace">MR::Image::Object image_object;<br>image_object.open(ROI.nii); <font color="#6aa84f">// which is coregistered to DWI</font></font></div><div><div><font face="monospace, monospace">MR::Image::Interp interp (image_object);</font></div><div><span style="font-family:monospace,monospace">MR::Point track_point, </span><span style="font-family:monospace,monospace">voxel_position;</span><font face="monospace, monospace"><br></font><div><font face="monospace, monospace"><div>for (std::vector< MR::Point>::iterator i = tck.begin(); i != tck.end(); ++i)</div><div> {</div><div> float *p = i->get();</div><div> track_point.set(p);</div><div> voxel_position = interp.R2P(track_point);</div><div> interp.P (voxel_position);</div><div> value = interp.value();</div><div> if(value != 0)</div><div> {</div><div> cout << value << endl ; </div><div> }</div><div> }</div><div>===</div>Is this a correct method to using Interp? </font><span style="font-family:monospace,monospace">Cause I get a float value.</span></div><div><font face="monospace, monospace">I hope I can get a integer value show that fiber is passing through the specific region.</font></div><div><span style="font-family:monospace,monospace"><br></span></div><div><font face="monospace, monospace">Should I round down, up or nearest to the point of track(track_point) to access right voxel intensity?</font></div><div><font face="monospace, monospace"><br></font></div><div><span style="font-family:monospace,monospace">Thank you for your help!</span><span><font color="#888888"><br></font></span></div></div></div></div><span><font color="#888888"><span><font color="#888888"><span><div><span style="color:rgb(0,0,0);font-family:monospace,monospace">Kuo, Kuan-Tsen</span><br></div></span></font></span></font></span></div>
</div></div></div><br></div>
<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>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div><div dir="ltr"><b><font color="#990000">Dr J-Donald Tournier (PhD)</font></b><br><div><font color="#990000"><br></font></div><i><font color="#990000">Senior Lecturer, </font></i><i><font color="#990000">Biomedical Engineering</font></i><div><i><font color="#990000">Division of Imaging Sciences & Biomedical Engineering<br>King's College London</font></i><div><i><font color="#990000"><br></font></i></div><div><i><font color="#990000"><b style="font-family:Calibri,sans-serif;font-size:15px"><span style="font-size:10pt">A:</span></b><span style="font-family:Calibri,sans-serif;font-size:10pt"> Department of Perinatal Imaging & Health, 1<sup>st</sup> Floor South Wing, St Thomas' Hospital, London. SE1 7EH</span><br></font></i></div><div><i><font color="#990000"><b>T:</b> +44 (0)20 7188 7118 ext 53613</font></i></div></div><div><i><font color="#990000"><b>W:</b> <a href="http://www.kcl.ac.uk/medicine/research/divisions/imaging/departments/biomedengineering" target="_blank">http://www.kcl.ac.uk/medicine/research/divisions/imaging/departments/biomedengineering</a></font></i><br></div></div></div>
</div></div></div></div>