[Mrtrix-discussion] Question about converting tracks
J-Donald Tournier
jdtournier at gmail.com
Tue Apr 7 13:51:54 PDT 2015
Hi Kuan-Tsen,
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 *nearest-neighbour* 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):
===
std::vector<MR::Point> tck; // one track got from tck file
MR::Image::Object image_object;
image_object.open(ROI.nii); // which is coregistered to DWI
MR::Image::Interp interp (image_object);
MR::Image::Position pos (image_object);
MR::Point track_point, voxel_position;
for (std::vector< MR::Point>::iterator i = tck.begin(); i != tck.end(); ++i)
{
float *p = i->get();
track_point.set(p);
voxel_position = interp.R2P (*i);
interp.P (voxel_position);
pos.set (0, round (voxel_position[0]));
pos.set (1, round (voxel_position[1]));
pos.set (2, round (voxel_position[2]));
value = pos.value();
if(value != 0)
{
cout << value << endl ;
}
}
===
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.
Cheers,
Donald.
On 7 April 2015 at 04:27, Kuan-Tsen Kuo <fixcankuo at gmail.com> wrote:
> Dear all:
>
> I would like to transforming the tracks to the ROI space which image valve
> is integer from 0 to 490,
> but not sure how to apply the transformation matrix.
> So I use MR::Image::Interp to access the voxel intensity of ROI image.
>
> Here is how I use,
> ===
> std::vector<MR::Point> tck; // one track got from tck file
> MR::Image::Object image_object;
> image_object.open(ROI.nii); // which is coregistered to DWI
> MR::Image::Interp interp (image_object);
> MR::Point track_point, voxel_position;
> for (std::vector< MR::Point>::iterator i = tck.begin(); i != tck.end();
> ++i)
> {
> float *p = i->get();
> track_point.set(p);
> voxel_position = interp.R2P(track_point);
> interp.P (voxel_position);
> value = interp.value();
> if(value != 0)
> {
> cout << value << endl ;
> }
> }
> ===
> Is this a correct method to using Interp? Cause I get a float value.
> I hope I can get a integer value show that fiber is passing through the
> specific region.
>
> Should I round down, up or nearest to the point of track(track_point) to
> access right voxel intensity?
>
> Thank you for your help!
> Kuo, Kuan-Tsen
>
>
> _______________________________________________
> Mrtrix-discussion mailing list
> Mrtrix-discussion at www.nitrc.org
> http://www.nitrc.org/mailman/listinfo/mrtrix-discussion
>
>
--
*Dr J-Donald Tournier (PhD)*
*Senior Lecturer, **Biomedical Engineering*
*Division of Imaging Sciences & Biomedical EngineeringKing's College London*
*A: Department of Perinatal Imaging & Health, 1st Floor South Wing, St
Thomas' Hospital, London. SE1 7EH*
*T: +44 (0)20 7188 7118 ext 53613*
*W: http://www.kcl.ac.uk/medicine/research/divisions/imaging/departments/biomedengineering
<http://www.kcl.ac.uk/medicine/research/divisions/imaging/departments/biomedengineering>*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.nitrc.org/pipermail/mrtrix-discussion/attachments/20150407/e665d8ed/attachment.html>
More information about the Mrtrix-discussion
mailing list