Documenting image processing: recording interactive steps called from ijm macro

Hi,
I am writing a script in imageJ macro language to process some images that where taken in different light conditions. Some steps require require manual intervention, in particular to decide if they should be performed at all (based on the previews) and to set thresholds. I would like to document what is done with each image when they are processed and save it on a file. Namely, I would like to have something similar to the plugin Plugin>Macro>Record… when performing these operations as they are called from the macro. The probelm is that the Record… plugin seems to work only when one selects the different operations by hand, from the menus, but not when the same are called by a macro.

In the example below, e.g. I call the Brightness adjustment plugin, then I set by hand the threholds if brightness adjustment is needed, then I subtract the background and apply gamma filter (if necessary) and finally threshold. I would like to be able to do the following:

  1. storing/recovering the information on threshold for the Brightness/Contrast plugin, on method and threshold for Threshold, on the rolling ball radius (+ the other settings) for the Subtract background, on the value of the gamma, etc…
    2 storing/recovering the information that I skipped some of those steps when that is the case (e.g. if Brightness adjustment was not required), both when a ‘cancel’ button is present in the plugin interface (in the “Subtract background” plugin) and when it is not (in the “Brightness/Contrast plugin”). I know there is a java method called wasCanceled that can be used in dialog windows, but I have no idea of how this can be accessessed from a ijm macro calling these plugins (I have no experience with java at all)

//Enhance contrast if necessary
run(“Brightness/Contrast…”);
waitForUser(“Adjust brightness. Press OK to continue”);
run(“Apply LUT”, “stack”);

//Subtract background (rolling ball) if necessary
run(“Subtract Background…”);

//Gamma filter
run(“gamma…”);

//Threshold
run(“Threshold…”);

Any suggestion is more than welcome!

Hi,
you could log the min and max before and after the waitForUser:

image

Sincerely,

Jerome.

thanks!
Do you know if plugins like background subtraction, gamma, etc (namely the standard ones of imageJ) all have similar commands but each with their own syntax?

Whatever you do while waitForUser() is also recorded if the recorder is open,
and in your macro, you can even push some text in the recorder directly if you want to add info to document what was done.

if (isOpen('Recorder')) call("ij.plugin.frame.Recorder.recordString", "// what you want\n");

You can also allow recording of the macro’s own run() calls by setting the recordInMacros to true:
try the following:

done=eval("js","Recorder.recordInMacros=true;");
run("Blobs");
run("Gamma...");

This works perfectly! Thanks a lot!