This repository contains an IJM script designed to automatically detect and analyze objects in images using the PTBIOP-Cellpose wrapper and the MorphoLibJ plugin. As published in A deep learning-based automated image analysis for histological evaluation of broiler pectoral muscle
- Daniel Waiger
- Faculty of Agriculture, Food and Environment, Hebrew University of Jerusalem (HUJI)
- Contact: [email protected] / [email protected]
- Image.sc ID: Daniel_Waiger
- Noam Goldman
- Faculty of Agriculture, Food and Environment, HUJI
- Zehava Uni Lab
This IJM script provides a comprehensive workflow for detecting and analyzing star-convex shapes in biological images. The workflow includes:
- Image and Output Folder Selection: User selects the input image and output directory.
- Image Name Collection: The script collects the original image name and generates a new name for output files.
- Parameter Selection: The script sets measurement parameters (e.g., area, fit).
- Object Detection with Cellpose: User inputs the estimated diameter of objects, and the script sets the necessary parameters for object detection using Cellpose with GPU acceleration.
- MorphoLibJ Processing: The script processes Cellpose results using various MorphoLibJ commands.
- Equivalent Ellipse Creation: The script creates equivalent ellipses for detected objects and overlays them on the original image.
- Demo Image Creation: The script generates a flat image with ROIs and axes for demonstration purposes.
- Cleanup: The script closes all open windows and saves the results.
- Fiji (ImageJ) with the PTBIOP-Cellpose wrapper and MorphoLibJ plugin installed.
- A suitable GPU for acceleration (optional but recommended).
-
Select Image and Output Folder
- Run the script and select the input image and output folder when prompted.
-
Collect Image Name
- The script will automatically collect the name of the original image.
-
Select Parameters to Measure
- The script will set the measurement parameters.
-
Cellpose Parameters for Object Detection with GPU
- Enter the estimated diameter of the objects in the image when prompted.
-
MorphoLibJ Processing
- The script will process the Cellpose results using various commands.
-
Equivalent Ellipse Creation
- The script will create and overlay equivalent ellipses on the original image.
-
Demo Image Creation
- The script will generate a flat image with ROIs and axes for demonstration.
-
Cleanup
- The script will close all open windows and save the results.
Below is an example of how the code is structured within the script:
// Example of selecting an image and output folder
run("Open...");
outputDir = getDirectory("Output Folder Selection");
// Collecting the image name
orgName = getTitle();
newName = File.getNameWithoutExtension(orgName);
// Setting measurement parameters
run("Set Measurements...", "area fit display redirect=None decimal=3");
// Object detection with Cellpose
shapeDiameter = getNumber("What is the estimated diameter of your objects?", 150);
run("Cellpose Advanced", "diameter=" + shapeDiameter + " cellproba_threshold=0.0 flow_threshold=0.4 anisotropy=1.0 diam_threshold=12.0 model=cyto2_omni nuclei_channel=0 cyto_channel=0 dimensionmode=2D stitch_threshold=-1.0 omni=false cluster=false additional_flags= ");
// Processing with MorphoLibJ
run("Extend Image Borders", "left=-6 right=-6 top=-6 bottom=-6 fill=Replicate");
run("Remove Border Labels", "left right top bottom");
run("Label image to ROIs", "rm=[RoiManager[size=766, visible=true]]");
run("Set Measurements...", "area fit display add redirect=None decimal=3");
run("Set Scale...", "distance=330 known=50 unit=um");
roiManager("Show None");
roiManager("Show All");
roiManager("Measure");
run("3-3-2 RGB");
saveAs("Results", outputDir + newName + "_Results.csv");
roiManager("Save", outputDir + newName + "_ROIs.zip");
print(orgName + " analysis is done!");
// Creating equivalent ellipses
run("Equivalent Ellipse", "label=" + newName + "-cellpose-ext overlay overlay_0 image=" + orgName);
// Creating a flat image for demo
selectImage(orgName);
run("Duplicate...", "title=" + newName + "_with_ROIs_and_axes");
run("Show Overlay");
run("From ROI Manager");
run("Flatten");
flatImage = getTitle();
saveAs("Tiff", outputDir + flatImage + ".tif");
// Closing all windows
run("Close All");
close("ROI Manager");
close("Results");