Tckgen - termination mask

Dear experts,

with tckgen, I would need to terminate my streamlines once they are leaving the specified region. In probtrackx this feature is called “termination mask”.

I could overcome that by creating whole whiter matter mask and supply it as -mask option, but that is cumbersome, since I do not want to constrain how my streamlines can enter my termination mask.

Do you have any clues how to do it with my current tckgen version (3.0_RC2-82-gbb77205e)?

Antonin Skoch

Eeek… that’s an awkward one. Let’s see if my interpretation here is correct:

  • Streamlines can propagate and terminate entirely outside the termination mask.

  • Streamlines can propagate and terminate entirely within the termination mask.

  • Streamlines can propagate from outside the termination mask into the termination mask.

  • Upon entering the termination mask, streamlines are still free to terminate at any point within that mask due to other streamlines tractography criteria.

  • If a streamline attempts to propagate from inside the termination mask to outside the termination mask, it is terminated due to the constraint imposed by having provided that termination mask.

If that’s the case, the closest thing I can suggest would be to define a 5TT image where what you define as a “termination mask” is labelled as sub-cortical grey matter. Streamlines will be forbidden from entering and then exiting that region by ACT prior #6. (They will however be truncated and so the termination may no longer be exactly at the point where the streamline attempted to exit the mask, but this is something that could be temporarily disabled short-term / controlled by a command-line option flag long-term.

Otherwise, it’s a slightly clumsy functionality to even define appropriately; so I’d be curious to know whether this is simply a feature that can be used to serve your purpose that you’re looking to duplicate in MRtrix3, as opposed to having a purpose that needs serving but could be achieved in some other manner using either existing or more appropriate methods.


Dear @rsmith,

my goal is following: I want to do FBA but I want to restrict my FBA to fixels located in the region of a specific pathway (for example acoustic pathway between Inferior colliculus and Heschl gyrus). So I need to provide streamlines connecting these two structures, but I want to restrict streamlines propagating outside the connection of these two structures (i.e. in case of acoustic pathway I do not want streamlines to continue to propagate from inferior colliculus more inferiorly to the brainstem and in cortex I do not want them to propagate outside from the heschl gyrus mask more distant to the periphery of the temporal lobe). Ideal is to crop the streamline once it enters the ROI on both sides.
As you are suggesting ACT, I am wondering, is ACT compatible with other features, such as -include, -exclude and -seed_image?
Or maybe the -stop parameter is what I am looking for. Do you think that the following could achieve my goal?

tckgen wm_fod.mif -seed_image inferior_colliculus.mif -include heschl_gyrus.mif -exclude excludion_region.mif -seed_unidirectional -stop


I want to do FBA but I want to restrict my FBA to fixels located in the region of a specific pathway

If you are specifically trying to constrain FBA to a particular pathway, this could be done using the -mask option in fixelcfestats. Since the fixel-fixel connectivity matrix is constrained to only consider pairs of fixels within this mask, and data smoothing is performed based on this connectivity matrix, use of this option will prevent smoothing from introducing values from outside your pathway of interest into the analysis. So this may be a more direct solution to your issue than attempting to restrict the trajectories or extent of the streamlines used to determine this connectivity.

Ideal is to crop the streamline once it enters the ROI on both sides.

An alternative but imperfect approach, if you really want to manipulate the streamlines in this way, is:

  • Perform whole-brain tracking on the template as per whole-brain FBA.

  • Add the two ROIs, and then take the inverse of this mask (using mrcalc 1.0 - -sub).

  • Use this as the -mask option in tckedit. This will crop out any streamline vertices within your two ROIs. Note that as a result, any streamline that passes entirely through one or both of these ROIs will be broken into multiple streamlines in the output track file.

  • Dilate each of your ROIs by one voxel.

  • Run tckedit again, providing the two dilated ROIs as separate inputs via the -include option. This will select only streamlines that intersect both of the dilated ROIs. Mostly, this will be streamlines that traversed both ROIs, but only the segment in between the two ROIs will be preserved due to the prior masking step. This may however additionally select some streamlines that pass adjacent to one of the ROIs due to the requisite dilation step; these would need to be cleaned up manually, or you could use e.g. the tckedit -minlength option.

As you are suggesting ACT, I am wondering, is ACT compatible with other features, such as -include, -exclude and -seed_image?

Yes, ACT operates more-or-less independently of such features. The exception is if you draw such regions entirely within cortical grey matter, then things may not behave as one may expect intuitively; though this will change in the future. But using ACT here would be a bush-mechanic’s fix, and would suffer from a similar problem to the -stop option described below.

Or maybe the -stop parameter is what I am looking for. Do you think that the following could achieve my goal?

The -stop option in tckgen will terminate a streamline as soon as it intersects the last include region that it encounters. So if you want the streamlines to end as soon as they enter a region, rather than as soon as they exit a region, then this approach can work; however streamlines will still fully traverse and even exit any -include region if there is at least one other -include region that it has not yet encountered. So this may or may not be adequate for what you’re trying to do, since each streamline would only be constrained from passing through one of the two ROIs, depending on the direction of propagation. But this could potentially be “solved” using the tckedit streamline cropping technique described above.


Hi all

I have noted a few discussions in the forum discussing this or similar issues but I’m still uncertain about how to obtain a fixel mask for a tract of interest that is streamlines/fixels connecting 2 ROIs.

In my case I have 2 ROIs - one subcortical and one cortical and I have tried to seed from one ROI to wholebrain and use tckedit -include for the target ROI to leave streamlines that only connect between the two. But as you note above, there is no clean option to stop the streamlines from leaving that target ROI so you still end up with propagating streamlines.

Here it is suggested to use fixelcfestats -mask option to achieve this but I am not sure how to make such a mask that only contains fixels between the 2 ROIs. I also note the discussion in [How to restrict fixelcfestats to subset of tracts] but here the user already had her defined tract, presumably using a white matter atlas. I am not using a white matter atlas and my ‘tract of interest’ is probably not represented fully by any white matter atlas so I remain unsure how to create a mask of this tract for fixelcfestats.

Would be grateful for your help about how best to generate the fixel mask here?

Thanks a lot


Hi Paul,

I’ve sent you some answers, but just in general for others: it’s important to distinguish 2 separate challenges here. The first is to get a good bundle definition. A few tricks related to your scenario are also found at Obtain tract segment using tckgen/tckedit ; but in general, it requires some playing around with various tricks to get the result you’re after. The -stop option will in most scenarios be useful here, as long as you can work with the fact that it stops streamlines upon entering the inclusion region, rather than tracking in and stopping upon attempting to exit. For most WM analyses, that can make good sense though, depending on how your inclusion regions are defined or obtained.

The second challenge is how to get a fixel mask from these streamlines. That’s generally done via tck2fixel to map the streamlines, followed by mrthreshold with a well considered -abs value to obtain a binary fixel mask. There’s a few other minor cleaning steps that can be added among these commands, but generally, that’s the gist of it.

Such a binary fixel mask can then be used via fixelcfestats, but only if you’re still after a per-fixel stat within the mask. At this stage, many people might however be after a fixel-region average metric, and stats on that across a population. mrstats can get you those averages, when supplying it via -mask with your fixel mask. In that scenario, stats can/will be done using any external software that suits you.