TractSeg
TractSeg copied to clipboard
[Question] Cropping TractSeg streamlines
Hi,
I have a goal of making TractSeg streamlines that are cropped at the gray-matter-white-matter-interface. I was curious how streamlines are currently terminated. Is this based on the masks in the bundle_segmentations
and endings_segmentations
folders? If so, I could imagine something easy to achieve my goals would be to subtract the GMWMI from the bundles mask (and then set any negative numbers to zero). Is there something more complicated going on behind the scenes?
Another approach that is likely less complicated would be to use one of the tckgen
commands (e.g. FACT/iFOD2 on TOMs or FODs) to include the GMWMI image (-act
argument) and the --crop-at-gmwmi
+backtrack
flags, which are natively included in MRTrix. In this case, how should one decide between these different tckgen
options? Would you have a preference for one over the other?
Thanks, Steven
The logic for tracking is the following: All streamlines have to start and end inside of the masks in endings_segmentations
and they have to be completely inside of mask of bundle_segmentations
.
You could subtract the graymatter mask from the bundle masks. Then no streamline would go into the gray matter. However, the endings mask will also contain some parts of the white matter. So some streamlines will end in the white matter and not exactly at the GMWMI.
Using tckgen is also possible, but to make it work with the TOMs needs 2 additional steps. You can check out the code here: https://github.com/MIC-DKFZ/TractSeg/blob/master/tractseg/libs/tracking.py#L148
This uses tckgen iFOD2 tracking on TOMs. Probably the easiest would be to locally install tractseg (git clone tractseg and then pip install -e .) and edit the code to add the additional arguments when tckgen is called.
Another easy solution if you are familiar with python: Simply write a script which iterates over all streamlines and check when they enter your gray matter mask. At this point you simply crop the streamline. If the streamline ends early before reaching the gray matter you simply remove it completely. This should be quite easy to implement.
Got it, thanks! I’ll start with a modified iFOD2 on the TOMs and see how that works.