Tck2connectome nodes_in problem


I am trying to use the connectome2tck function to extract certain streamlines based on their assignment to parcellated nodes. Ultimately, I want to be able to define 4-5 cortical nodes I am interested in and select the streamlines that connect between these in each participant.
To get started I thought I would just try using a whole parcellated brain to understand how the function works, I can then refine my nodes.

To start with I used the tck2connectome function to generate the .csv file required.

tck2connectome /pathtofile/subjID_wholebrain.tck /pathtofile/subjID_aparc.a2009s+aseg.nii.gz /pathtofile/subjIDnodes_a2009s.csv -force

The .csv contains a lot of zeros, so I don’t know if that is part of the problem – the streamlines just aren’t being assigned to many parcels? Warning error: tck2connectome: [WARNING] The following nodes are missing from the parcellation image: long list of nodes!
[WARNING] (This may indicate poor parcellation image preparation, use of incorrect or incomplete LUT file(s) in labelconvert, or very poor registration)

I checked registration and it is fine. Maybe I am inputting the wrong nodes_in image, what should this be? I have been using an image parcellated in freesurfer.

When I then use the .csv I have generated into the connectome2tck I get the following error.

connectome2tck /pathtofile/subjID_wholebrain.tck /pathtofile/subjIDnodes_a2009s.csv /pathtofile/subjID_output

connectome2tck: [ERROR] Assignments file contains 12175 entries; track file contains 200000 tracks

Any guidance would be great. I think the error lies with what I am selecting as the input for the parcellation image. In the documentation the tck2connectome nodes_in argument just sates ‘the input node parcellation image’.

Thanks for any suggestions!!


Welcome Izzy!

To start with I used the tck2connectome function to generate the .csv file required.
tck2connectome /pathtofile/subjID_wholebrain.tck /pathtofile/subjID_aparc.a2009s+aseg.nii.gz /pathtofile/subjIDnodes_a2009s.csv -force

You’re not actually generating the file that you need. :upside_down_face:

The compulsory output of tck2connectome is the connectome matrix, which provides just one scalar value for every edge in the connectome. That is not enough information to then go back to the track file and select which files were assigned to which edge.

tck2connectome has an additional option -out_assignments, which writes to a text file, for every streamline, which nodes that streamline was assigned to. This is the information that connectome2tck needs in order to write different streamlines to different files based on their node assignments.


Hi Rob,

Brilliant - thank you so much for getting back to me! I can’t believe I missed that optional argument. It has all been working now and I am managing to use the output for the connectome2tck and select the -nodes I am interested in.

On a related note - would I be able to combine nodes of interest from my cortical parcellation with regions of interest derived from fMRI data? This way when I create my connectome I will connect all these regions together (albeit some GM regions defined structurally and some functionally?)


would I be able to combine nodes of interest from my cortical parcellation with regions of interest derived from fMRI data?

Assuming that within your conceptualisation of the experiment it makes sense for there to be a single discrete parcellation image, regardless of the source(s) of information of the various region labels, then yes, you can do this. There’s two implicit requirements here:

  • All parcels need to be defined on the same image voxel grid (which can just be done by regridding);

  • You cannot have multiple parcels labelled within a single voxel.

To actually pull this off, there isn’t a dedicated command, it’s just a matter of understanding the underlying fundamental data manipulation operations and leveraging the various basic image processing tools available. So for instance: you can generate for any particular node label a binary mask image containing just the voxels of that parcel by using the -eq operation in mrcalc; you can look for overlapping voxels between binary mask images using -mult in mrcalc; you can multiply a binary mask by an integer to add it to a parcellation image using mrcalc -mult -add.


Kind of related, but is there an option to input an Index file for your nodes_in image?

For instance i was trying to use the same set of nodes provided by xcpEngine, which are not indexed from 1 : ###. This particular atlas is 2001 : 9170, not in a contiguous order, therefore i end up with a 9170 x 9170 matrix of mostly zeroes as my output connectome.

Currently doing this after the fact:

#read in indices
inds = pd.read_table('/aal116NodeIndex.1D',names=['ind'],index_col=None)
#zero index
df2 = inds - 1

#read in csv
df = pd.read_csv('aal116_count.csv',header=None,names=range(9170))

#extract valid rows/cols
conn = df.loc[df2.ind.values,df2.ind.values]