I'd like to make batch processing (with SciJava scripts, commands or ops) even easier.
The current options for batch processing files in ImageJ are outlined on the batch processing page. There are mainly two options:
Process > Batch > Macro..., the ImageJ 1.x
- Use one of the Process folder templates (currently available in IJ1 macro and Python) and write your own script.
While setting up a script is easy with the use of templates (i.e. option 2), it still results in a lot of code duplication if you create a lot of scripts this way, thereby increasing the maintenance burden when those scripts need to be adapted to different use cases, e.g. changing input parameters etc.
I therefore would like to improve option 1 from above: create a Scijava Batch Processor that is aware of the
@INPUT parameters of a script and performs batch processing over a list of files, recursively from one or many folders. Basically, it should do the following:
Choose any script, command or op that has at least one
If multiple compatible inputs exist (file and/or image), offer a choice to either:
- have them filled by a constant value (e.g. subtract the same shading reference image from all images in a folder), or
- populate them from the list of files (batch processing input)
Ask for an input (and an optional output) directory, and harvest all other input parameters of the script by creating a dialog (usual
Run the given command for each input file/image with the provided (constant) additional parameters.
I realize this is pretty similar to how ImageJ2 plugins currently work in KNIME, with the column binding option in the advanced settings:
So I think something similar would be nice to have in ImageJ (as not every batch workflow is suitable to be run from KNIME (yet) ). I have some ideas how I would go about creating a small Java wrapper that runs a command for every file in a folder, but I'd need some pointers on:
How do I get the inputs of a given script/command? I guess I need
ModuleInfo.inputs(), but I'd be grateful if someone had a small illustrative example at hand.
Also, I can possibly use
ModuleService.getSingleInput() to ask for compatible file/image input parameters, right?
How do I add the inputs of the script/command to the current instance of my batch processor, so that a new dialog can be created that asks for those parameters as well as the target folders?
Before I start: does that make sense at all? Do you have comments or objections? (/cc @ctrueden)