Select specific tracts

One quick question: is it possible to select a specific subset of tracts from a .tck file?

Let’s say I have a .tck file containing 5 tracts, ideally I would like to supply an ascii-file with rows [0 0 1 1 0] to select tracts 3 & 4 and write those to a new .tck file.

cheers!

I don’t think we have a tool like this because there are no labels for each streamline in a tck file.

We don’t have this functionality in the command line tools, but you could achieve this very easily with the Matlab read/write functions for .tck files (or equivalent dipy tools).

Now that I think about it, you actually can, though in a slightly roundabout way:

Provide such an ASCII file to tckedit using the -tck_weights_in option, then additionally use the option -minweight 0.5.

Essentially it’s re-purposing code that was put there for the purpose of SIFT2, but it should get the job done as far as I can tell.

thanks a lot! yes, Matlab/Python is prob. the way to go here, you’re right!

Here is another quirky workaround in MRtrix3 if you still need it: you can convert your tracks to ASCII, which writes out one streamline per file, then reconvert back to *.tck selecting only those streamlines of interest using the MRtrix3 number selection syntax. For example:

$ mkdir tmp/     # just to store temporary ASCII output
$ tckconvert tracks.tck tmp/tracks-[].txt
$ tckconvert tmp/tracks-[3,4].txt selection.tck
$ rm -rf tmp/    # delete temporary folder once you're done

It’s not quite what you were after, given your ascii file syntax. @rsmith’s suggestion would actually be a better fit. But I just thought I’d raise this alternative in case anyone else was interested…