Assembling a proper ImageJ macro

Peter Sobolewski (he/him)
Systems Analyst, Imaging Applications - Research IT

Use to advance the slide

Acknowledgements

Script Parameters

#@ at the top of a macro define script parameters for declaring inputs/output dialogs (Fiji, ImageJ2 only)

  • Input parameters are defined by their type and variable name, 1 per line
    • #@ Type variable_name
    • Listing of types: https://imagej.net/scripting/parameters#parameter-types
    • Dialog elements are determined by the type, but can be customized by passing settings in () after the type, e.g. (label="File to open")
    • #@ output Type variable_namecan be used to generate output

Warmup

Run the template macro on the data folder. Does it do what you expect?

Running & Installing macros

  • Drag-n-drop the .ijm macro file onto the Fiji bar OR use [Plugins > Macros > Edit...]
    Both will launch the Script Editor so you can use run
    Note: [Plugins > Macros > Run...] won't work for macros with Script Parameters
  • Use [Plugins > Install...] to install a macro into the Plugins menu (bottom section)
    This will copy the macro to the plugins folder inside your Fiji installation
  • Make a folder in Fiji/plugins, e.g. "ZZ My Macros" to collect your macros and have easy access
  • Copy your macro file to Fiji/plugins/Macros (or make a folder there) to make it appear at bottom of [Plugins > Macros]

Note: For the menus, the file name must have an _ e.g. Process_Folder.ijm or _MyMacro.ijm