Skip to content

Instantly share code, notes, and snippets.

@tinevez
Last active December 28, 2017 16:32
Show Gist options
  • Save tinevez/e5e941fbc2f5ed8b41beec36552100a3 to your computer and use it in GitHub Desktop.
Save tinevez/e5e941fbc2f5ed8b41beec36552100a3 to your computer and use it in GitHub Desktop.
Example of a two way export - reimport of a Model via MaMuT.
public static void main( final String[] args ) throws IOException, JDOMException, SpimDataException
{
/*
* 1. Load a regular Mastodon project.
*/
final String bdvFile = "samples/datasethdf5.xml";
final String modelFile = "samples/model_revised.raw";
final MamutProject project = new MamutProject( new File( "." ), new File( bdvFile ), new File( modelFile ) );
final Model model = new Model();
model.loadRaw( project.getRawModelFile() );
/*
* 2. Export it to a MaMuT file.
*
* This will export also setup assignments and bookmarks, as well as
* feature values when possible. Of course, we loose the ellipsoid
* information, and the MaMuT spots have a radius equal to the mean of
* the ellipsoid semi-axes.
*/
final File target = new File( "samples/mamutExport.xml" );
MamutExporter.export( target, model, project );
/*
* 3. Re-import it using the TrackMate importer.
*/
final Model trackMateModel = TrackMateImporter.importModel( target ).model;
/*
* 4. Display the re-imported model.
*/
final InputTriggerConfig keyconf =Mastodon.getInputTriggerConfig();
final KeyPressedManager keyPressedManager = new KeyPressedManager();
final TrackSchemeStyleManager trackSchemeStyleManager = new TrackSchemeStyleManager( false );
final RenderSettingsManager renderSettingsManager = new RenderSettingsManager( false );
final ViewerOptions options = ViewerOptions.options()
.inputTriggerConfig( keyconf )
.shareKeyPressedEvents( keyPressedManager );
final SpimDataMinimal spimData = new XmlIoSpimDataMinimal().load( project.getDatasetXmlFile().getAbsolutePath() );
final SharedBigDataViewerData sharedBdvData = new SharedBigDataViewerData(
project.getDatasetXmlFile().getAbsolutePath(),
spimData,
options,
() -> System.out.println( "repaint.") );
final MamutAppModel appModel = new MamutAppModel( trackMateModel, sharedBdvData, keyconf, keyPressedManager, trackSchemeStyleManager, renderSettingsManager );
new MamutViewBdv( appModel );
new MamutViewTrackScheme( appModel );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment