Bug (?): tckconvert loosing streamlines OR tckinfo counting empty lines?

Hey everyone,

after resampling a TractSeg generated bundle to equidistant planes using the -line option (Thanks again @rsmith) I want to sample diffusion metrics from it.

I now have a mismatch in streamline count:
The resulting txt file with the sampled values has a lot of empty lines (see image attached). Compatible with the streamline count of the tck file used as an input to the sampling (which according to tckinfo -count has 2000 streamlines), the txt file also has 2000 lines.

Of those only 131 hold values, the rest is just empty.
I noticed this because after loading the extracted metrics into R dataframes all the six bundles I look at have a different amount of streamlines even though the tck files used for sampling should all have 2000.

Do I do something wrong or is this possibly a bug?

Commands executed:

# Inputs: bundle.tck dwi_fa.nii
tckinfo -count bundle.tck

Tracks file: “…/…/07_tractography/01_processed_bundles_median/CST_left_equi_line_50.tck”
command_history: tckresample -line 50 ‘124.3075,110.684,55.7634’ ‘93.3927,129.438,169.824’ ./07_tractography/tractseg/tractseg_output/TOM_trackings/CST_left.tck ./07_tractography/01_processed_bundles_median/CST_left_equidistant.tck (version=3.0.3)
count: 2000
dimensions: (256, 256, 256)
mrtrix_version: 3.0.3
timestamp: 1651069544.0221230984
total_count: 2000
voxel_order: RAS
voxel_sizes: [1. 1. 1.]
tckinfo: [done] counting tracks in file
actual count in file: 2000


tcksample bundle.tck dwi_fa.nii metrics.txt

tcksample: [100%] Sampling values underlying streamlines

Counting non empty streamlines

sed -e 's/[\t ]//g;/^$/d' metrics.txt | wc -l

Hi Darius,

It’s not a bug, it’s a feature. :stuck_out_tongue: But the “problem” isn’t where you think it is.

This isn’t anything to do with tcksample, it’s all about tckresample. If, for a given streamline, there is any plane upon your specified line trajectory that that streamline does not intersect, then that streamline will be omitted from the output track file, as it is not possible to produce from that input streamline an output streamline with the number of vertices that you demand in the locations that you demand. Running tckstats should tell you that there’s a bunch of streamlines with zero vertices in there.

(If you really want to get into the esoterics: A preferable way to deal with this would be to use some form of “flag” in the track file to say “the streamline is still here, but this specific vertex along the streamline is unspecified”. The trouble is that we can’t do that, because the only reasonable flags with which to do so (infinities and NaNs) already serve functions in the .tck file format as delimiters. Solving this problem therefore requires devising a whole new format for tractography data; which is already underway…)

I would suggest being a little more conservative with where you set the endpoints of your exemplar trajectory.


1 Like