Batch processing

Learning Objectives

After completing this lesson, learners should be able to:
  • Automatically process a number of images

Motivation

Scientific discovery is based on reproducibility. Thus, it is very common to apply the same analysis workflow to a number of images, possibly comprising different biological conditions. To achieve this, it is very important to know how to efficiently “batch process” many images.

Concept map

graph TD I1("Image 1") --> S("Analysis workflow") I2("Image 2") --> S IN("Image ...") --> S S --> R1("Result 1") S --> R2("Result 2") S --> RN("Result ...")

Figure


Batch processing of many images, yielding many tables.



Activities


Show activity for:

ImageJ Macro Scijava

/**
 * 2D Nuclei area measurement
 * 
 * Requirements:
 *   - Update site: IJPB-Plugins (MorpholibJ)
 */

// Scijava script parameters
// Use the [ Batch ] button in the Fiji script editor to automatically analyse multiple files
#@ File (label="Input image") inputImageFile
#@ File (label="Output directory", style="directory") outputDir

// Processing parameters
threshold = 25;

// Clean up and avoid popping up of image windows during run
run("Close All");
run("Clear Results);
setBatchMode(true);

// init options
run("Options...", "iterations=1 count=1 black do=Nothing");

// open and process
//
open(inputImageFile);

// extract image name to create output file names (s.b.)
imageName = File.getNameWithoutExtension(inputImageFile);

// segment
setThreshold(threshold, 65535);
run("Convert to Mask");
run("Connected Components Labeling", "connectivity=4 type=[8 bits]");
run("glasbey_on_dark");
// save segmentation
saveAs("Tiff", outputDir + File.separator + imageName + "_labels.tif");
// measure
run("Analyze Regions", "area");
// save measurements
saveAs("Results", outputDir + File.separator + imageName + ".txt");

run("Close" ); // close results table

Exercises

Show exercise/solution for:

ImageJ Macro Scijava

  • Download the unfinished.ijm ImageJ macro script.
  • Open the script in Fiji.
  • The script will not run like this.
  • Add code to the lines where it says TODO to enable batch processing.
    • Tip: you can copy and paste code from the script in this modules activity.
    • Tip: to make it work you may also have to add code to some lines where it does not say TODO.

Solution

Assessment

Fill in the blanks

  1. If you have thousands of images to process you should consider using a ___ .
  2. Batch processing refers to __ processing many data sets.

Solution

  1. computer cluster (HPC)
  2. automatically

Follow-up material

Recommended follow-up modules:

Learn more: