Tckedit with inclusion image

Dear expert,

I am using tckedit to manipulate my track data. Specifically, I have an inclusion image and I only want to keep the streamlines that traverse the inclusion regions. For this reason, I’ve used the -include flag.

However, the final track also include regions that are far away from the inclusion mask. Am I doing something wrong? Is there a way to stop propagating a streamline once it has traversed the include regions?

Thanks in advance

Hi Davide,

It is guaranteed that every streamline included in the output file intersects the include region at some point along its length. This doesn’t place any restriction on where else that streamline may go. Apply this logic across all streamlines, with each going to some different area of the image, and it is indeed possible for it to “look like” there are unwanted pathways included in the track file.

If you specifically want each streamline to terminate as soon as it intersects the inclusion region, this can be achieved using the -stop option.


Hi @rsmith,

thanks for your reply. I knew about the -stop option for tckgen but I was wondering if there is something comparable for tckedit.



I knew about the -stop option for tckgen but I was wondering if there is something comparable for tckedit.

A -stop option wouldn’t make sense for tckedit, since by that point the streamlines are no longer “directed” through propagation. I.e. If you find a vertex in the middle of the streamline that intersects your region, do you throw out all of the streamline vertices after that point, or before it?

The closest that you will get in tckedit is the -mask option. Basically any streamline vertex that is not inside of the mask(s) will get thrown out. So e.g. if you were to take your mask image, invert it so that voxels in your ROI have value 0 and all other voxels have value 1 (mrcalc 1 ROI.mif -sub), and use that as a mask in tckedit, then there will be no streamline vertices inside of your ROI.

You have to be careful though. This is done in a purely vertex-wise fashion; it won’t find the first vertex outside of the mask and then “stop”. So if the streamline goes through your ROI and out the other side, i.e. the start of your streamline is in the mask, the middle is outside of it, and the end is also in the mask, then that one streamline will be split in two in the output track file. So you can actually get more tracks in your output file than there were in your input file! :upside_down_face:

Sometimes these sort of experiments take a bit of fiddling; but generally once you understand the actual underlying operation of the tools at your disposal, you can figure out what steps you need to produce the result you’re looking for.