How to sort the tracks spatially

I have been using trackmate to track the displacement of a discrete array of dots over a test specimen, with a view to measure its mechanical properties. When extracting the xml file using the ”ImportTrackmateTracks” function within Matlab it seems that the tracks are sorted with no particular order (i.e. track 1 is not necessarily spatially localised near track 2). Is there any logics behind the way tracks are organised ? I am trying to sort the tracks spatially so that at the first frame, tracks are arranged in ascending order from left to right and top to bottom. I have attached a picture of what it would look like:

Any idea or help would be much appreciated,

Thanks, best regards


Hi Coz,

In TrackScheme, the tracks are arranged from left to right following the alphanumerical order of their name.

Each track is a column in TrackScheme. The header of such column contains the track name. If you double-click on it, you will be able to edit its name. Pressing the Layout button after this will reorder the tracks.

1 Like

Awesome, that worked great ! thanks tinevez.
Now if I have many, many tracks, reorganising them manually in TrackScheme will be a rather tedious job. Am I right thinking that a Matlab routine that allows to sort the tracks spatially might be a good solution in that paticular case ?

I would instead directly operate in TrackMate and create an Action that would do that.

Check the manual to see how to write a custom TrackMate action, that would appear on the last panel of the GUI:

The action to write would be a track renamer that would assign to each track a name according to its spatial position.

Ok, will give that a try. thanks tinevez

Dear Coz,
Did you succeed? I would be quite interested in having a solution to sort tracks by their spatial position in TrackScheme.


Hi Rafael,
I haven’t been able to develop further this, so I went by Tinevez first suggestion,