Sorting tck streamlines with weights

Good morning all,
I am new to MRtrix3, have started working with .tck files recently and would like to sort streamlines by their weight. I have a .tck file with streamlines and .txt files with corresponding weights (generated with * tcksample *).
My goal is to only get the 500 streamlines with the highest weights. After sorting the streamlines, * tckedit * would allow me to select the appropriate number.
The alternative solution I am using right now is to manually adjust a minimum weight threshold in * tckedit * until I get the desired number of fibers. Is there a way to do this automatically in MRtrix3?

Welcome @Titouan!

I … would like to sort streamlines by their weight.

There’s no command currently capable of doing this. But you could load the relevant data using the MatLab functions and perform such a reordering yourself. Similarly:

My goal is to only get the 500 streamlines with the highest weights.

If the streamlines are sorted by weight, then tckedit -number would achieve this; but once you’ve got the raw data in MatLab / Octave to do the sorting, you could just perform this selection at the same time.

I used to have a command for randomising the order of streamlines; maybe if there were enough use cases we could look into implementing a command tckreorder or the like…?

… and .txt files with corresponding weights (generated with tcksample).

Per-streamline values generated through tcksample I would not refer to as “weights”. That has a certain specific implication (being cross-sectional area multipliers), whereas the interpretation of values coming from tcksample is dependent on the underlying image from which values are sampled.

Cheers
Rob