mastodon-sc / mastodon

Mastodon – a large-scale tracking and track-editing framework for large, multi-view images.
BSD 2-Clause "Simplified" License
66 stars 20 forks source link

Support for creating a new Mastodon project directly from an image opened in Fiji. #179

Closed tinevez closed 2 years ago

tinevez commented 2 years ago

Solves #124

This PR makes it possible to create a new Mastodon project directly from an image opened in Fiji. The core code to wrap a SpimData around an ImagePlus is based on existing code by Tobias in the BDV Fiji plugins. The proper handling of this feature in Mastodon mainly requires dealing with warning the user and ultimately offering exporting the image to a BDV file.

It works like this:

The launcher "New Mastodon project" as a new option, listing the images opened in Fiji as possible source.

Screenshot 2022-07-06 at 14 02 22

Project created this way looks like classic Mastodon project, as if the image source had only 1 resolution level. The LUT and display scale are imported from the ImagePlus as well. Screenshot 2022-07-06 at 14 05 36

The image data in Mastodon wraps the ImagePlus data. If the user modify the image in the ImagePlus window, the modifications will be shown, and used, in Mastodon: Screenshot 2022-07-06 at 14 06 57

Because of this we have to be extra careful when the user closes the ImagePlus. So the ImagePlus window is modified to listen to the user closing the image, and shows this message: Screenshot 2022-07-06 at 14 11 45 If the user clicks 'Yes', both the image and all Mastodon windows are closed.

When the user wants to save such a Mastodon project, they are offered to export the image to a BDV file: Screenshot 2022-07-06 at 14 17 40

It then shows the familiar dialog of the BDV export (the code is copied from the BDV Fiji plugin): Screenshot 2022-07-06 at 14 25 26

After the export, the user is prompted to save the Mastodon project in a standard way. The Mastodon session will now run using the new BDV file as source for the image data, not on the ImagePlus anymore. The warning that appeared when trying to close the image is removed.

If the user chooses not to export to a BDV file, a standard project file will be created, but with a dataset field pointing to where the image file is saved (as inferred from the FileInfo of the ImagePlus). Such a project can now be reloaded by Mastodon normally, without warning.

TODOs: