# Tckedit with inclusion image

**URL:** <https://community.mrtrix.org/t/tckedit-with-inclusion-image/3654>\
**Category:** Uncategorized\
**Created:** [May 9, 2020, 7:06pm UTC](https://community.mrtrix.org/t/tckedit-with-inclusion-image/3654 "2020-05-09T19:06:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Davide\_Momi](https://community.mrtrix.org/user_avatar/community.mrtrix.org/davide_momi/32/1828_2.png) [@Davide\_Momi](https://community.mrtrix.org/u/Davide_Momi)\
**Post date:** [May 9, 2020, 7:06pm UTC](https://community.mrtrix.org/t/tckedit-with-inclusion-image/3654/1 "2020-05-09T19:06:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rsmith](https://community.mrtrix.org/user_avatar/community.mrtrix.org/rsmith/32/2672_2.png) [@rsmith](https://community.mrtrix.org/u/rsmith)\
**Post date:** [May 17, 2020, 5:31am UTC](https://community.mrtrix.org/t/tckedit-with-inclusion-image/3654/2 "2020-05-17T05:31:09Z")

</div>

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](https://mrtrix.readthedocs.io/en/latest/reference/commands/tckgen.html#streamlines-tractography-options).

Cheers  
Rob

---

<div class="post-metadata">

**Author:** ![Davide\_Momi](https://community.mrtrix.org/user_avatar/community.mrtrix.org/davide_momi/32/1828_2.png) [@Davide\_Momi](https://community.mrtrix.org/u/Davide_Momi)\
**Post date:** [May 20, 2020, 7:47pm UTC](https://community.mrtrix.org/t/tckedit-with-inclusion-image/3654/3 "2020-05-20T19:47:07Z")

</div>

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.

Thanks

D

---

<div class="post-metadata">

**Author:** ![rsmith](https://community.mrtrix.org/user_avatar/community.mrtrix.org/rsmith/32/2672_2.png) [@rsmith](https://community.mrtrix.org/u/rsmith)\
**Post date:** [May 30, 2020, 12:22pm UTC](https://community.mrtrix.org/t/tckedit-with-inclusion-image/3654/4 "2020-05-30T12:22:48Z")

</div>

> 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! 🙃

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.

Cheers  
Rob
