This Fiji (ImageJ) macro script is designed for automated detection and morphometry analysis of ice crystals in merged TIF images. The script performs the following tasks:
- Prompts the user to select directories for input images and output results.
- Processes each image in the selected directory.
- Applies image processing techniques to enhance and detect ice crystals.
- Uses Cellpose Advanced for crystal detection and MorphoLibJ for morphometry analysis.
- Saves results and processed images in the specified output directory.
Short Workfllow Example - From Left to Right: Raw → Cellpose Label Image Without Border Labels → Ellipsoid Image.
- BIOP Cellpose Wrapper Manual - to use Cellpose Advanced in Fiji.
- MorphoLibJ Plugin - Wiki.
- Open Fiji (ImageJ).
- Open the script editor (Plugins > New > Macro).
- Copy and paste the provided macro code into the editor.
- Or, you can drag-and-drop the macro file onto Fiji's main toolbar, ice-crystal-morphometry-analysis-GUI.ijm.
- Run the macro (Run button in the script editor).
- The macro will prompt you to choose a directory containing the image files (input folder) and a directory to save the results (output folder).
- The macro sets measurement parameters such as area, mean, and standard deviation which will be applied in the ROI manager.
- The macro iterates through each file in the directory and processes valid '.tif' images using the processImage function.
- The image file is opened, and its properties are set based on the microscope calibration.
open(dir + fileName);
run("Properties...", "channels=1 slices=1 frames=1 unit=um pixel_width=1.118 pixel_height=1.118 voxel_depth=1");
- The script enhances the contrast of the image and uses the Cellpose Advanced plugin for crystal detection.
run("Enhance Contrast...", "saturated=0.35 normalize equalize");
run("Cellpose Advanced", "diameter=12 cellproba_threshold=0.0 flow_threshold=0.4 anisotropy=1.0 diam_threshold=12.0 model=cyto2 nuclei_channel=0 cyto_channel=1 dimensionmode=2D stitch_threshold=-1.0 omni=false cluster=false additional_flags=");
- Converts the detected labels to ROIs and removes any labels at the borders.
run("Remove Border Labels", "left right top bottom");
run("Label image to ROIs", "rm=[RoiManager[size=13, visible=true]]");
- Uses the MorphoLibJ plugin to analyze regions and save the results.
run("Analyze Regions", "pixel_count area perimeter circularity bounding_box centroid equivalent_ellipse ellipse_elong. convexity max._feret geodesic tortuosity max._inscribed_disc average_thickness geodesic_elong.");
When performing morphometry analysis, various parameters are used to quantify the geometric and structural properties of the detected objects. Below are the explanations for the key parameters used in the Ice Crystal Morphometry Macro:
Parameter | Description | Significance |
---|---|---|
Pixel Count | The total number of pixels that make up the object. | Provides a basic measure of the object's size. |
Area | The total area covered by the object in square microns. | Indicates the size of the object. |
Perimeter | The length of the boundary around the object. | |
Circularity | A measure of how close the shape of the object is to a perfect circle. | A circularity value of 1 indicates a perfect circle, while values closer to 0 indicate more elongated or irregular shapes. |
Formula: Circularity = (4 × π × Area) / (Perimeter^2) | ||
Bounding Box | The smallest rectangle (aligned with the axes) that completely encloses the object. | Useful for calculating the extent and positioning of the object. |
Centroid | The center of mass of the object. | Provides the coordinates of the object's geometric center. |
Equivalent Ellipse | An ellipse that has the same normalized second central moments as the object. | Used to describe the shape and orientation of the object. |
Ellipse Elongation | The ratio of the major axis to the minor axis of the equivalent ellipse. | Indicates how elongated the object is. |
Convexity | The ratio of the object's area to the area of its convex hull (the smallest convex shape that encloses the object). | Values close to 1 indicate the object is more convex (less concave indentations). |
Maximum Feret Diameter | The longest distance between any two points along the boundary of the object. | Provides a measure of the object's maximum dimension. |
Geodesic Tortuosity | A measure of the complexity of the object's shape, considering its internal path lengths. | Higher values indicate more complex and winding shapes. |
Maximum Inscribed Disc | The diameter of the largest circle that can fit inside the object without crossing its boundary. | Provides insight into the object's internal size and constraints. |
Average Thickness | The average distance across the object, considering all internal points. | Useful for understanding the overall "thickness" of the object. |
Geodesic Elongation | The ratio of the maximum geodesic distance (shortest path within the object) to the diameter of the maximum inscribed disc. | Indicates the elongation of the object based on its internal path lengths. |
These parameters collectively provide a comprehensive understanding of the geometric and structural properties of the detected objects, allowing for detailed analysis and comparison.
- The results of the morphometry analysis are saved in a CSV file in the output directory.
saveAs("Results", resultsPath); // Save results to a CSV file
- The equivalent ellipse image and detection label image are flattened and saved.
run("Flatten");
saveAs("Tiff", saveDir + saveName); // Save the equivalent ellipse image
- The macro includes visualization tools such as generating and saving equivalent ellipse images for better interpretation of the results.
- '.csv' File: Contains detailed morphometry analysis results.
- '.tif' Files: Include processed images with detected crystals and equivalent ellipses.