Run macro

Run a specific ImageJ macro once (as opposed to the "Run macro on objects" module, which runs once per object).

Description

Run a specific ImageJ macro once (as opposed to the "Run macro on objects" module, which runs once per object). This module can optionally open an image into ImageJ for the macro to run on. It can also intercept the output image and store it in the MIA workspace. Variables assigned during the macro can be extracted and stored as measurements associated with the input image.

Note: ImageJ can only run one macro at a time, so by using this module the "Simultaneous jobs" parameter of the "Input control" module must be set to 1.

Note: When this module runs, all windows currently open in ImageJ will be automatically hidden, then re-opened upon macro completion. This is to prevent accidental interference while the macro is running. It also allows the macro to run much faster (batch mode). To keep images open while the macro is running (for example, during debugging) start the macro with the command "setBatchMode(false)".

Parameters

ParameterDescription
Add variablePre-define variables, which will be immediately accessible within the macro. These can be used to provide user-controllable values to file-based macros or to prevent the need for editing macro code via the "Run macro" panel.
Variable typeControls the data type of the variable that will be assigned within the macro:
  • "Boolean" Variable will be assigned a true/false value depending on whether the checkbox was selected/deselected (respectively).
  • .
  • "Number" Variable will be assigned a numeric value to which mathematical operations can be applied.
  • .
  • "Text" Variable will be assigned a text value. Irrespective of whether the value contains only numeric characters this will be interpreted as text.
.
Variable nameThe variable value can be accessed from within the macro by using this variable name.
Variable checkboxBoolean (true/false) value assigned to this variable if "Variable type" is set to "Boolean".
Variable numeric valueNumeric value assigned to this variable if "Variable type" is set to "Number".
Variable text valueText value assigned to this variable if "Variable type" is set to "Text".
Provide input imageWhen selected, a specified image from the workspace will be opened prior to running the macro. This image will be the "active" image the macro runs on.
Input imageIf "Provide input image" is selected, this is the image that will be loaded into the macro. A duplicate of this image is made, so the image stored in the workspace will not be affected by any processing in the macro. The final active image once the macro has completed can be stored in the workspace using the "Intercept output image" parameter.
Macro modeSelect the source for the macro code:
  • "Macro file" Load the macro from the file specified by the "Macro file" parameter.
  • "Macro text" Macro code is written directly into the "Macro text" box.
Macro textMacro code to be executed. MIA macro commands are enabled using the "run("Enable MIA Extensions");" command which is included by default. This should always be the first line of a macro if these commands are needed.
Macro fileSelect a macro file (.ijm) to run once, after all analysis runs have completed.
Intercept output imageWhen selected, the image currently active in ImageJ at completion of the macro can be stored into the workspace. This can either overwrite the input image in the workspace or be stored as a new image (controlled by "Apply to input image").
Apply to input imageWhen this and "Intercept output image" are selected, the image active in ImageJ at completion of the macro will update the input image in the MIA workspace. Otherwise, the actie image will be stored as a new image in the workspace with the name specified by "Output image".
Output imageWhen "Intercept output image" is selected, but not updating the input image, the image active in ImageJ at completion of the macro will be stored in the MIA workspace with this name. This image will be accessible to other modules using this name.
Intercept variable as measurementThis allows variables assigned in the macro to be stored as measurements associated with the input image.
VariableVariable assigned in the macro to be stored as a measurement associated with the input image. This name must exactly match (including case) the name as written in the macro.