From bea2216b30f8167da9a4442a21ffb6450db0c352 Mon Sep 17 00:00:00 2001 From: Elisabeth Kugler <67630046+ElisabethKugler@users.noreply.github.com> Date: Tue, 1 Mar 2022 15:28:21 +0000 Subject: [PATCH] keep largest --- AlternativeMacros/MGEndfeetCoverage.ijm | 6 ++++-- Macros/step8_QuantificationTool.ijm | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/AlternativeMacros/MGEndfeetCoverage.ijm b/AlternativeMacros/MGEndfeetCoverage.ijm index 11c7ea0..0ebd405 100644 --- a/AlternativeMacros/MGEndfeetCoverage.ijm +++ b/AlternativeMacros/MGEndfeetCoverage.ijm @@ -84,7 +84,9 @@ for (e=0; e< filelistMGs.length; e++) { saveAs("Tiff", OutDir + "MAX_" + name); // smoothen and enhance before segmenting with Threshold - run("Median...", "radius=3"); + run("Median...", "radius=2 stack"); + + run("Enhance Local Contrast (CLAHE)", "blocksize=127 histogram=256 maximum=3 mask=*None* fast_(less_accurate)"); // segmentation with Otsu Threshold run("Threshold..."); @@ -95,7 +97,7 @@ for (e=0; e< filelistMGs.length; e++) { run("Invert", "stack"); // it measures the white as MG endfeet saveAs("Tiff", OutDir + "MAX_TH_" + name); - run("Invert", "stack"); + // run("Invert", "stack"); // for timelapse - need to iterate over the individual timepoints if (frames > 1){ // if more than one timeframe it is a timelapse diff --git a/Macros/step8_QuantificationTool.ijm b/Macros/step8_QuantificationTool.ijm index e1f6c24..deb88e6 100644 --- a/Macros/step8_QuantificationTool.ijm +++ b/Macros/step8_QuantificationTool.ijm @@ -61,6 +61,7 @@ run("Set Measurements...", "area mean standard min centroid center perimeter bou var imgName=""; var shortTitle = ""; var column_label = ""; +var halfPos = 10; ///// open images from inputfolder for overall quantification, EDM, and skeletonization for (i=0; i< sortedFilelist.length; i++) { @@ -71,7 +72,17 @@ for (i=0; i< sortedFilelist.length; i++) { print("processing ... " + sortedFilelist[i]); open(path + sortedFilelist[i]); + + getDimensions(width, height, channels, slices, frames); + + halfPos = round(slices / 2); + setSlice(halfPos); + + run("Make Binary", "method=Default background=Default"); run("Keep Largest Region"); // from MorpholibJ to keep largest region and remove anything unconnected + wait(3000); + + Quantification(sortedFilelist[i]); // call function quantification close("*"); @@ -138,6 +149,8 @@ function Quantification(title){ getDimensions(width, height, channels, slices, frames); getPixelSize(unit,pixelWidth,pixelHeight,voxelDepth); volVox = pixelWidth * pixelHeight * voxelDepth; + setSlice(halfPos); + run("Histogram", "stack"); // [255] is MG Vox @@ -153,10 +166,13 @@ function Quantification(title){ // surface smoothing run("Median 3D...", "x=6 y=6 z=6"); wait(3000); + + setSlice(halfPos); run("Make Binary", "method=Default background=Default"); // binarize after smoothing // 3D EDM for thickness run("Duplicate...", "title=For3DEDM duplicate"); + wait(2000); selectWindow("For3DEDM"); run("Geometry to Distance Map", "threshold=1"); run("Green Fire Blue"); // assign LUT green-fire-blue