|
| 1 | +#@ Context context |
| 2 | + |
| 3 | +from java.io import File |
| 4 | + |
| 5 | +from org.mastodon.mamut import WindowManager |
| 6 | +from org.mastodon.mamut.project import MamutProject |
| 7 | +from org.mastodon.tracking.mamut.trackmate import TrackMate |
| 8 | +from org.mastodon.tracking.mamut.trackmate import Settings |
| 9 | +from org.mastodon.tracking.mamut.detection import DoGDetectorMamut |
| 10 | +from org.mastodon.tracking.mamut.linking import SimpleSparseLAPLinkerMamut |
| 11 | +from org.mastodon.tracking.linking import LinkingUtils |
| 12 | + |
| 13 | +bdv_file = "/Users/tinevez/Development/Mastodon/mastodon/samples/datasethdf5.xml" |
| 14 | +project = MamutProject( None, File( bdv_file ) ); |
| 15 | + |
| 16 | +# Open the project. |
| 17 | +wm = WindowManager( context ) |
| 18 | +wm.getProjectManager().open( project ) |
| 19 | +app_model = wm.getAppModel() |
| 20 | + |
| 21 | +# Get Mastodon model. |
| 22 | +model = app_model.getModel() |
| 23 | +selection_model = app_model.getSelectionModel() |
| 24 | + |
| 25 | +# Get image data. |
| 26 | +image_data = app_model.getSharedBdvData() |
| 27 | + |
| 28 | +# Configure TrackMate. |
| 29 | + |
| 30 | +# Detector settings. |
| 31 | +detector_settings = { |
| 32 | + "MIN_TIMEPOINT" : 0, |
| 33 | + "MAX_TIMEPOINT" : 1000, |
| 34 | + "SETUP" : 0, # The channel or source in the BDV data. |
| 35 | + "RADIUS" : 7., # The cell expected radius. |
| 36 | + "THRESHOLD" : 200. # Threshold on quality. |
| 37 | +} |
| 38 | + |
| 39 | +# Linker settings. There are too many, so we take the default and edit it. |
| 40 | +linker_settings = LinkingUtils.getDefaultLAPSettingsMap() |
| 41 | +linker_settings[ "MIN_TIMEPOINT" ] = 0 |
| 42 | +linker_settings[ "MAX_TIMEPOINT" ] = 1000 |
| 43 | +linker_settings[ "LINKING_MAX_DISTANCE" ] = 10. |
| 44 | +linker_settings[ "ALLOW_GAP_CLOSING" ] = True |
| 45 | +linker_settings[ "MAX_FRAME_GAP" ] = 2 |
| 46 | + |
| 47 | +# Create the settings objects. |
| 48 | +settings = Settings() \ |
| 49 | + .sources( image_data.getSources() ) \ |
| 50 | + .detector( DoGDetectorMamut ) \ |
| 51 | + .detectorSettings( detector_settings ) \ |
| 52 | + .linker( SimpleSparseLAPLinkerMamut ) \ |
| 53 | + .linkerSettings( linker_settings ) |
| 54 | + |
| 55 | +trackmate = TrackMate( settings, model, selection_model ) |
| 56 | + |
| 57 | +# We need to give a context to TrackMate. |
| 58 | +trackmate.setContext( context ) |
| 59 | + |
| 60 | +# Run TrackMate. |
| 61 | +trackmate.run() |
| 62 | +if trackmate.isCanceled(): |
| 63 | + print( "Calculation was canceled. Reason: " + trackmate.getCancelReason() ) |
| 64 | +elif not trackmate.isSuccessful(): |
| 65 | + print( "Calculation failed with error message:\n" + trackmate.getErrorMessage() ) |
| 66 | +else: |
| 67 | + print( "Calculation complete." ); |
| 68 | + |
| 69 | +wm.createTrackScheme() |
| 70 | +wm.createBigDataViewer() |
| 71 | + |
| 72 | +# Compute features. |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | + |
| 77 | +wm.createTable( False ) |
0 commit comments