Closed MaximeMaW closed 5 years ago
Hello, any update regarding this issue? Many thanks!
Not yet. One guy I will not name gave me plenty of work on TrackMate - involving a CSV importer and a better overlay capture - and it is consuming all my time.
I think it is because there are some features missing required for saving. For instance you need to compute the TARGET_ID
and SOURCE_ID
of all edges to properly save them.
What I would suggest is then to add all features at once, using feature providers. Like this (this is Java, so you have to adapt to Jython):
If settings
is your Settings
object:
settings.clearSpotAnalyzerFactories();
final SpotAnalyzerProvider spotAnalyzerProvider = new SpotAnalyzerProvider();
final List< String > spotAnalyzerKeys = spotAnalyzerProvider.getKeys();
for ( final String key : spotAnalyzerKeys )
{
final SpotAnalyzerFactory< ? > spotFeatureAnalyzer = spotAnalyzerProvider.getFactory( key );
settings.addSpotAnalyzerFactory( spotFeatureAnalyzer );
}
settings.clearEdgeAnalyzers();
final EdgeAnalyzerProvider edgeAnalyzerProvider = new EdgeAnalyzerProvider();
final List< String > edgeAnalyzerKeys = edgeAnalyzerProvider.getKeys();
for ( final String key : edgeAnalyzerKeys )
{
final EdgeAnalyzer edgeAnalyzer = edgeAnalyzerProvider.getFactory( key );
settings.addEdgeAnalyzer( edgeAnalyzer );
}
settings.clearTrackAnalyzers();
final TrackAnalyzerProvider trackAnalyzerProvider = new TrackAnalyzerProvider();
final List< String > trackAnalyzerKeys = trackAnalyzerProvider.getKeys();
for ( final String key : trackAnalyzerKeys )
{
final TrackAnalyzer trackAnalyzer = trackAnalyzerProvider.getFactory( key );
settings.addTrackAnalyzer( trackAnalyzer );
}
Hi @tinevez
Thank you very much for the update. I translated your Java code to Python as follows:
from fiji.plugin.trackmate.providers import SpotAnalyzerProvider
from fiji.plugin.trackmate.providers import EdgeAnalyzerProvider
from fiji.plugin.trackmate.providers import TrackAnalyzerProvider
# Compute edge properties, following https://github.com/fiji/TrackMate/issues/120
settings.clearSpotAnalyzerFactories()
spotAnalyzerProvider = SpotAnalyzerProvider()
spotAnalyzerKeys = spotAnalyzerProvider.getKeys()
for key in spotAnalyzerKeys:
spotFeatureAnalyzer = spotAnalyzerProvider.getFactory(key)
settings.addSpotAnalyzerFactory(spotFeatureAnalyzer)
settings.clearEdgeAnalyzers()
edgeAnalyzerProvider = EdgeAnalyzerProvider()
edgeAnalyzerKeys = edgeAnalyzerProvider.getKeys()
for key in edgeAnalyzerKeys:
edgeAnalyzer = edgeAnalyzerProvider.getFactory(key)
settings.addEdgeAnalyzer(edgeAnalyzer)
settings.clearTrackAnalyzers();
trackAnalyzerProvider = TrackAnalyzerProvider()
trackAnalyzerKeys = trackAnalyzerProvider.getKeys()
for key in trackAnalyzerKeys:
trackAnalyzer = trackAnalyzerProvider.getFactory(key)
settings.addTrackAnalyzer(trackAnalyzer)
That seems to solve the problem, thank you so much! I had totally missed this in the documentation. Thanks again!
(Sorry for the long message. I tried to provide a reproducible, minimal (non)working example).
I am adapting the script provided on the Scripting TrackMate page. My goal is to perform the tracking in batch mode, and to save the result of the tracking in the TrackMate file (so that I can then use TrackMate to inspect the trajectories, etc).
To do so, I am using the
TmXmlWriter
function. However, when I do that, although the XML containing only the tracks is correct (it is the fileexportTracks.xml
generated by the script below), the XML file containing the full model -- exportModel.xml -- seems to be missing the track edges: the<Edge />
elements of the<Track ...>
appear to be empty). Here is an example:Am I doing anything wrong? Is there something that I forgot to instanciate? Or is that a bug? Any pointer would be much appreciated! Many thanks!
===================== I am attaching the following files produced by the
.py
script below:exportTracks.xml
(this one is correct and contains the edges)exportModel.xml
(this one seems not to contain the edges, and cannot be imported into TrackMate)trackmate-auto-output.txt
(the output/log produced by my Python script. There is no error and the script runs properly)(they are all provided in the zipped archive below)
Here is my modified Python code (launched with the command:
fiji TrackMate-auto.py --headless
. I am providing theexportXML
andTrackMate_auto.zip