ROIs from atlas to generate ROI to ROI streamlines

Hi there,

I would like to use tckgen to generate streamlines between two rois. I have the atlas (the parcellation) and I also have performed tckgen for the whole brain but I would like to just seed streamlines between two rois and use that instead of tck2connectome and then select the specific ROIs. The reasoning is that I keep having issues with rois not having assigned streamlines within the subthalamic nucleus for a number of subjects while other subjects appear to have no issues.

Is there a way to do this without generating many masks for each subject?


1 Like

Hi @Benjamin_Deck ,
You can use -include or -include_ordered option of the tckgen
command. I hope this helps.
Many Thanks,

Hi Benjamin,
Just as Suren said, -include is a suitable option.
Since you have the whole brain tractography, I recommend using tckedit which runs much faster than generating new streamlines and can save time.

The following content is quoted from the MRtrix3 docs, hope it helps. :grinning:


  • Extract streamlines based on selection criteria:
tckedit in.tck out.tck -include ROI1.mif -include ROI2.mif -minlength 25

Multiple criteria can be added in a single invocation of tckedit, and a streamline must satisfy all criteria imposed in order to be written to the output file. Note that both -include and -exclude options can be specified multiple times to provide multiple waypoints / exclusion masks.

  • Select only those streamline vertices within a mask:
tckedit in.tck cropped.tck -mask mask.mif

The -mask option is applied to each streamline vertex independently, rather than to each streamline, retaining only those streamline vertices within the mask. As such, use of this option may result in a greater number of output streamlines than input streamlines, as a single input streamline may have the vertices at either endpoint retained but some vertices at its midpoint removed, effectively cutting one long streamline into multiple shorter streamlines.

@suren @StarVolcano

Thank you both for your replies.

Hmm, I believe this would still involve generating a number of masks.

Is there something similar to connectome2tck -nodes that can be used to seed streamlines?

In other words, I don’t want to generate the masks and wondering if there is a workaround.


Hi Ben

Are you trying to avoid creating ROI masks because of the amount of effort involved, or for some other reason e.g. saving storage?

If it’s just about the effort, maybe this thread about automatically creating ROIs based on atlas parcellation indices might be useful? If you know the label values for the nodes you want connections for, it’s fairly straightforward to do what (I think?) you’re trying to achieve.

e.g. say you have a parcellation (in subject space) called parc.nii.gz and the ROIs you’re interested in are labelled 1 and 2. Then you can get streamlines between those two nodes as @StarVolcano and @suren suggested:

mrcalc parc.nii.gz 1 -eq seed.nii.gz
mrclac parc.nii.gz 2 -eq end.nii.gz
tckgen fod.mif -seed_image seed.nii.gz -include end.nii.gz -stop out.tck
# Or using existing whole brain tck file
tckedit wbt.tck -include seed.nii.gz -include end.nii.gz

But if you don’t want to retain lots of mask files you could use bash piping (on unix) to make them temporary files:

tckgen fod.mif -seed_image $(mrcalc parc.nii.gz 1 -eq -) -include $(mrclac parc.nii.gz 2 -eq -) -stop out.tck

If you’re really adamant about not using any inclusion or seed mask files, then I can’t think of an alternative workaround I’m afraid. And sorry for being the 3rd person suggesting the thing you really don’t want to do!



Hi, Ben:

As Fiona said, I tried to do something similar in the past. If you still have questions, contact me on my Uni email, and I’ll try to answer you the best I can!