-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make original ImageJ commands work as SciJava modules #134
Comments
Before working on this automation, I suggest wrapping a couple of commands manually, to make sure that the result delivers on our requirements. (What are our requirements? We should list them.) |
@ctrueden and I worked on this more earlier today and made some good progress on this. Instead of hacking
In each of these methods we generate the "script line" that we want as the command creates the GUI and passes all the options. For example in java.util.List<String> choices = Arrays.asList(items).stream().map(item -> "\"" + item + "\"").collect(Collectors.toList()); // convert item array to list
String label2 = label;
if (label2.indexOf('_')!=-1)
label2 = label2.replace('_', ' ');
scriptLines.add(String.format("#@ String (label=%s, choices={%s}, value=%s) %s", label2, String.join(", ", choices), defaultItem, labelToName(label))); // create script string
... Now when I run the Analyze Particles command the console outputs all the info we want (without even running the recorder):
From here we just need to grab |
Notes from talk with @ctrueden:
|
One other note about the menu structure for scripts, which I forgot to mention: scripts are indeed placed in the menu structure at a position matching their folder structure. So e.g.
at the top of a script and the declaration there would override the menu path. The relevant issues are scijava/scijava-common#294 and scijava/scijava-common#344. It is past time we finish this work, and I had discussed having a pair programming session some time in September with him to do so anyway. If this work gets finished in time, then you could group all the ImageJ 1.x script wrappers in the same folder e.g. |
@gselzer Since this issue was written, you also explored wrapping the ImageJ commands as scripts, no? How far did you get? Is any work pushed anywhere? Any comments on the issue here? |
@ctrueden I don't think I ever really tried, sorry. |
@gselzer No worries, I must have misremembered! We can circle back to this issue again in another 5 years or so 😅 |
[@ctrueden Edit] If we create a script wrapper for each original ImageJ command, they will be easier to use in SciJava-friendly contexts, such as napari-imagej's search bar, because the types of inputs and outputs will be properly declared. Once the script wrappers exist, we could also customize each command as needed, such as checking if headless and failing fast for commands that don't support it. The write-up below describes one possible path to automating the generation of these scripts, so that we can get an initial version of them all in existence as quickly as possible with a minimum of human error.
Goal: create a
RecorderPlus
object in ImageJA that operates in parallel to the IJ1Recorder
. This class would be a static singleton. This work can live on a branch in IJA as it's not meant for distribution, just a simple workflow to generate scripts.This object should have a number of fields based on the strings that we are harvesting (e.g. a list of
String
s corresponding toGenericDialog#getNextString()
).We will need to modify
GenericDialog
to populate ourRecorderPlus
object since not all information is being passed to the IJ1Recorder
.Points of modification:
Each of these methods should be updated to populate a field of
RecorderPlus
with the information that would be sent to theRecorder
.Then in Recorder.saveCommand we would call into RecorderPlus to write a
*.py
script based on its current state (and also noting the ImagePlus parameter if present). Then we will create a new repository to house these scripts (or add it toimagej-legacy
, or something..)Finally, I think tapping into Recorder.resetCommandOptions to also clear
RecorderPlus
would be sufficient.Code skeleton:
The text was updated successfully, but these errors were encountered: