Emulate Save button Trackmate in python

Dear Forum,
and moreover dear @tinevez, is there a MWE python language script that explains how to do the exact same thing that save button does from the GUI of Trackmate?

My proble is to export tracks as .xml but in the same way that save button does.
The ExportTracksToXML exports .xml file that is not suitable to be loaded back in trackmate.
Instead if I save using “save” button it will save my a nice .xml file that when I load back in trackmate open for me the GUI and the tracks overlaid.

Thank you,

1 Like

You can probably get some inspiration from the following Java code illustrating the API usage of TmXmlWriter:

It’s not Python code indeed, but as you’re calling the Java API from any scripting language anyways, it should be not too hard to adapt.

Hope that helps getting you started.


it works! :smiley:
little snippet in python:

import java.io.File as File
from fiji.plugin.trackmate.io import TmXmlWriter
from fiji.plugin.trackmate import TrackMate

writer = TmXmlWriter (outFile_TMXML) #a File path object
writer.appendModel( trackmate.getModel() ) #trackmate instantiate like this before trackmate = TrackMate(model, settings)
writer.appendSettings( trackmate.getSettings() )

thanks a lot,