Batch processing
Prerequisites
Before starting this lesson, you should be familiar with:
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
Figure
Activities
Batch analysis of nuclear shapes
- Download the input.zip containing the input images and unpack to your course directory
- In a previous module there is a workflow to measure the shapes of nuclei in one image
- Adapt this workflow for automated batch analysis of many images
-
Start by building the skeleton of the workflow without filling in the functionality;
Note that the pseudo-code below will run fine, but does not produce any results:
FUNCTION analyse(image_path, output_folder)
PRINT "Analyzing:", image_path
END FUNCTION
FOR each image_path in image_paths
CALL analyse(image_path, output_dir)
END FOR
- Make sure the loop with the (almost) empty analyse function runs without error before filling in the image analysis steps
- Inspect the analysis results in a suitable software
Show activity for:
ImageJ SciJava Macro
/**
- 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
skimage python
Assessment
Fill in the blanks
- If you have thousands of images to process you should consider using a ___ .
- Batch processing refers to __ processing many data sets.
Solution
- computer cluster (HPC)
- automatically
Follow-up material
Recommended follow-up modules:
Learn more: