[Mrtrix-discussion] Tracks2prob code question

Thijs Dhollander thijs.dhollander at uzleuven.be
Wed Jan 18 09:13:50 PST 2012


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


More information about the Mrtrix-discussion mailing list