Create average measure along a tract

Dear Rob,

I have extracted a tract from the connectome and then used tck sample to generate a mean value along the tract. However the output mean.csv file has 79 values, not one mean value as I expected. The code I used is below;

extract tract

connectome2tck 200K.tck assignment_200.csv edge_ -nodes 8,366 -exclusive -files per_edge -force

#Calculate average value of tract
tcksample edge_8-188.tck image.nii.gz edge_8_188_mean.csv -stat_tck mean

Am i doing something wrong, where does the 79 values come from?



[EDIT] This is all wrong – please ignore…

By default, tcksample writes the value of the underlying image at each point along the track is to file. You get one sample per vertex along the streamline. If you want the mean value along the streamline, you’d need to do that manually (e.g. in python or matlab).

Alternatively, depending on exactly what you’re trying to do, you might be better off using tck2connectome in some way, @rsmith may have some suggestions on that front…

OK, my mistake, I hadn’t spotted the -stat_tck mean option in there… I’m assuming your 79 values come from 79 streamlines in your edge_8-188.tck file – one per streamline. You should be able to confirm with tckinfo edge_8-188.tck.

Yep, key’s in the name of the command-line option: -stat_tck computes some statistic from the values along each track, and therefore outputs a single scalar value per track. If you want to apply some other mathematical operation to combine the values from across all tracks into a single scalar value for a set of tracks, that can be done explicitly after tcksample has been run; but it’s important to recognise that doing such would involve two reduction operations (e.g. mean value along each streamline, followed by mean of these values across streamlines).