[Mrtrix-discussion] Tracks2prob code question
Robert Smith
r.smith at brain.org.au
Thu Jan 19 15:46:21 PST 2012
Hi Thijs
For that code, the voxel set is interpreted slightly differently between
TDI and directionally-encoded colour (DEC) TDI, both within the MapWriter
and TrackMapper classes.
For standard greyscale TDIs, inserting a voxel into the std::set fails if
that voxel has already been traversed by that streamline (no duplicate
entries permitted in this container), so when this data is fed to
MapWriter, only one entry exists for each voxel traversed, and the "+= 1"
operation only occurs once per voxel.
For DEC processing, I had expected all std::set::insert() operations to
succeed (since the local tangent should pretty much always be different,
two elements should never be 'identical'), so each voxel would have
multiple entries in this set, corresponding to the tangent at each point
along the streamline residing within that voxel. The MapWriterColour class
is then responsible for combining these tangents, exploiting the fact that
the std::set orders the elements using the "<" operator (so all of the
entries for the same voxel occur in sequence), to ensure that the
contribution to a voxel in the buffer by a single streamline would always
be normalised to a vector of length 1.
Unfortunately the code in 0.2.9 doesn't quite work as I had intended; only
the tangent at the first point to enter the voxel contributes to the map at
that voxel, because std::set::insert() fails when contributing to a voxel
multiple times (even though the tangents are different; not quite sure why
std::set is behaving like this...). Realistically the difference to the DEC
TDIs will be minimal; colours might be ever-so-slightly off in regions of
low density and high curvature. Standard TDIs are obviously unaffected.
If you want the colour TDI mapping to behave *exactly* as intended, the
easiest fix is to change SetVoxelDir from a std::set to a std::multiset.
Alternatively you can download the latest code version
here<http://code.google.com/p/mrtrix/source/browse/trunk/cmd/tracks2prob.cpp>
.
Best regards
Rob
--
Robert Smith
Melbourne Brain Centre
245 Burgundy Street
Heidelberg VIC 3084
Telephone: (+61 3) 9035 7128
Fax: (+61 3) 9035 7301
Email: r.smith at brain.org.au
www.florey.edu.au <http://www.fni.edu.au> www.brain.org.au
On Thu, Jan 19, 2012 at 4:13 AM, Thijs Dhollander <
thijs.dhollander at uzleuven.be> wrote:
> Hi all,
>
> I have been trying to find my way around the tracks2prob sourcecode (in
> 0.2.9) in order to find out how some things are exactly defined/calculated
> in practice by the current code.
> In this process, I've stumbled upon something I don't fully seem to
> understand. It concerns a slight difference in logic between the "write"
> methods of the MapWriter class...
>
> ----------------------------------------------------------------------
> void write (const std::set<Voxel>& voxels)
> {
> for (std::set<Voxel>::const_iterator i = voxels.begin(); i !=
> voxels.end(); ++i)
> buffer[voxel_to_index(*i)] += 1;
> }
> ----------------------------------------------------------------------
>
> ...and the MapWriterColour class...
>
> ----------------------------------------------------------------------
> void write (const std::set<VoxelDir>& voxels)
> {
> std::set<VoxelDir>::const_iterator i = voxels.begin();
> while (i != voxels.end()) {
> const std::set<VoxelDir>::const_iterator this_voxel = i;
> Point this_voxel_dir(0.0, 0.0, 0.0);
> do {
> this_voxel_dir += i->dir;
> } while ((++i) != voxels.end() && *i == *this_voxel);
> buffer[voxel_to_index(*this_voxel)] += this_voxel_dir.normalise();
> }
> }
> ----------------------------------------------------------------------
>
> In MapWriter's write method, every separate entry in the "voxels" set has
> a "footprint" of exactly 1 in the buffer. So if the same entry (i.e.
> voxel) appears more than once in a row in the set, it will also result in
> the corresponding number of "+= 1" operations on the matching index in the
> buffer.
>
> In MapWriterColour's write method, however, the inner do{...}while-loop
> combined with the "this_voxel_dir.normalise()" seems to result in the fact
> that multiple concatenated entries of the same voxel in the set only get a
> total footprint of "1" (i.e. a normalised "Point") on the matching index in
> the buffer.
>
> So, why this difference? Or have I missed something (else) in the code?
> :-)
>
> Kind regards,
> Thijs
> _______________________________________________
> Mrtrix-discussion mailing list
> Mrtrix-discussion at www.nitrc.org
> http://www.nitrc.org/mailman/listinfo/mrtrix-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.nitrc.org/pipermail/mrtrix-discussion/attachments/20120120/21a1ad2b/attachment.html
More information about the Mrtrix-discussion
mailing list