When running an IJ2 command, if I get it right, output objects which cannot be displayed are discarded. Thus FIJI keeps images, tables, and a few other things in memory and accessible for Commands, put otherwise objects are discarded. However there are many types of Object which could benefit from being kept in memory and reused. It would be useful for instance, to keep the result of a registration (RealTransform, AffineTransform, YourPerfectTransform), or image display settings parameters, or whatever object your particular use case need, like a …
The usual workaround to deal with this is to write a file to store these objects, and then reopen the file to retrieve them. I think it would be nice to modify the behaviour of FIJI in order to allow for a more direct and convenient way of using such objects.
The problem in the default behaviour of how a Command deals with a object consists of two parts:
- The object is discarded, even when declared as
@Parameter(type = ItemIO.OUTPUT)
- FIJI does not know how to display it
@maarzt came up with a possible solution that addresses these two points (see this repo (https://github.com/maarzt/example-imagej-display)). In practice, being able to use and display a in a a
Command would require:
>class which, if I understand correctly, is just notifying that a certain class of Object can be displayed
- a class extending
>, which contains a method providing a Swing JPanel to display the object
The example repo also shows how to update the display when the bird is renamed and how to retrieve the scijava context (https://github.com/maarzt/example-imagej-display/tree/master/src/main/java/com/mycompany/imagej).
There’s a common essential class
EasySwingDisplayViewer<T> , which enables all of this. Currently it is located in the example repository, but it would be nice to move it somewhere into scijava-ui-swing repo.
PS : There’s a related question which is how to use BigDataViewer windows with FIJI Commands, see forum post here (https://forum.image.sc/t/getting-bigdataviewer-instance-in-an-imagej-command).