Using MRtrix for subcortical parcellation


I am trying to use MRtrix for subcortical structure parcellation (i.e.,GPi), and currently having some issues. Just wondering if anyone can kindly share their experience on the similar topic.

The way I try to obtain the functional subdivisions is by generating the streamlines (5k/voxel) for the seeding ROI (ie. GPi) and the target region (a functional cortical region). The process is repeated for each functional cortical regions of interest. Then, by converting the resulting .tck files into tdi (I also saw others use the streamline end points map), I use the winner-takes-all approach to determine the sub-regions within the nucleus.

I understand that the streamlines should really run through the white matter regions. The tdi I obtained seem to only lean near the interface of GPi and whiter matter, but the opposite side towards other subcortical nucleus is not receiving any streamlines for parcellation purposes…this accounts for about half of the GPi volume.

I am wondering if there is any step that I missed, or additional processing I should perform to deal with this issue?

Thanks a lot!

Hi Xiao,

I can’t quite follow exactly what you’re describing there; I’d need to see screenshots alongside descriptions of the specific issues you’re facing.

I will however link you to this script I shared a little while ago, which generates the connectivity fingerprints for each voxel in a seed mask, which can then be fed to e.g. a winner-takes-all algorithm.


Thanks a lot, Rob.
I will check out the script first.

Thanks for the code, Rob.
I see that in the script, each voxel is isolated from the mask and use the -select mechanism to tract to the whole brain.

Just curious, will any combination of the options in tckgen allow -seed_random_per_voxel image num_per_voxel to produce fixed number of streamlines for each voxel? So far, my trials seem to produce streamline counts mostly well under the specific number.

Just curious, will any combination of the options in tckgen allow -seed_random_per_voxel image num_per_voxel to produce fixed number of streamlines for each voxel?

This requires a little disentangling:

  1. The seeding options in tckgen can be classified into two groups: finite and infinite.

    1. A mechanism like -seed_image produces each seed independently of all other seeds, and could therefore continue for the life of the universe.

    2. -seed_random_per_voxel, on the other hand, intrinsically sets the finite number of streamline seeds to be produced.

    For the former, one must set either the maximal number of seeds (-seeds) or the total number of output streamlines (-select) in order for the command to self-terminate. For the latter, the command will intrinsically terminate once it has made an attempt to propagate from each of the finite number of seeds.

    As such, while it would be possible for the script to utilize a mechanism from class 2, it may require some code modification to make it work properly.

  2. -seed_random_per_voxel will not produce a fixed number of streamlines per voxel. That mechanism produces a fixed number of streamlines seeds per voxel; but not all of those seeds are guaranteed to produce a streamline that satisfies all other criteria.

So far, my trials seem to produce streamline counts mostly well under the specific number.

Is this with respect to the script as it is provided online, or have you modified the script based on point 1 above?

  • In its provided form, every voxel is guaranteed to contain the same number of generated streamlines; voxels are explicitly excluded if tckgen fails to reconstruct precisely this number. One potential source of confusion however would be if your calculations are excluding those streamlines that were successfully generated from a voxel, but that fail to be assigned to a parcellation node at their location of termination. I.e. The streamline count within the corresponding row of the connectivity matrix may be less than the number of generated streamlines, because not all generated streamlines are assigned to the connectome.

  • If this observation is downstream of a modification, see point 1 above.


Thank you for the reply, Rob.
Really appreciate it.

Apologies for resurrecting an old thread if it’s bad form, but could I please check with the maskconnectivity script -
input_parc - what format does this image need to be? If I want to look at connectivity of a seed subcortical region to 5 cortical areas (as an example) - do I need to combine the cortical areas into a single image (with different integer values for the voxels in each cortical image), or run the script separately for each cortical ROI?
Output_voxels/Output_data - what format should be specified (e.g. image or text file)
Thanks in advance


Hi Dan,

I’m not sure about this script, but hopefully @rsmith can correct me if I’ve got it wrong…

As far as I can tell, input_parc is a parcellation image as generated from e.g. FreeSurfer and tidied up using labelconvert and labelsgmfix. This would be an image of integer indices, one for each target ROI, with the integers arranged sequentially (you want the largest integer to be small since that dictates the size of the output connectome matrix – see the labelconvert page for details).

Based on the above, I think that’s exactly right.

Looking through the script, these will be saved as matrices, which means text format, suitable for loading in e.g. Excel, Matlab, or Python.