var helpURL = "http://dev.mri.cnrs.fr/wiki/imagej-macros/Adipocytes_Tool" var preMinSize = 80; var preMaxSize = 20000; var preThresholdMethod = "Percentile"; var preNumberOfDilates = 10; var simpleMinSize = 80; var simpleMaxSize = 20000; var simpleThresholdMethod = "Percentile"; var simpleUseBinaryWatershed = true; var simpleMaxSize = 20000; var simpleNumberOfDilates = 10; var waterMinSize = 100; var waterMaxSize = 20000; var waterSigma = 4; var waterThresholdMethod = "Percentile"; var waterNumberOfDilates = 10; var oldForeground; var oldBackground; macro "Unused Tool - C037" { } macro "Adipocytes Tools Help Action Tool - C98aD00D01D02D03D04D05D06D07D08D09D0aD4fDd0De0Df8Df9CfffD1dD29D2eD34D49D51D56D6cD85D8bD9aDa1Dc6DdaDe2CddeD14D15D16D17D18D1cD2aD2dD4aD5dD5eD62D65D66D67D68D72D75D76D77D82D83D84D8aD92D93D94D98D99Da2Da3Da7Da8Da9Db1Db7Db8Db9Dc7Dc8Dc9CfffD0bD0cD0dD0eD0fD10D1eD1fD20D24D25D26D27D28D2fD30D35D36D37D38D39D3fD40D45D46D47D48D50D57D58D5fD60D61D6dD6eD6fD70D71D7cD7dD7eD7fD80D81D8cD8dD8eD8fD90D91D95D96D9bD9cD9dD9eD9fDa0Da5Da6DaaDabDacDadDaeDafDb0Db5Db6DbaDbbDbcDbdDbeDbfDc0DcaDcbDccDcdDceDcfDdbDdcDddDdeDdfDebDecDedDeeDefDf0Df1Df2Df3Df4Df5Df6Df7DfaDfbDfcDfdDfeDffCccdD13D19D21D22D31D33D3eD42D43D4eD52D5aD5cD63D6bD73D78D7aD87Db3Dc1Dc4Dd1Dd2Dd3Dd5Dd6Dd9De4De5De6CeeeD23D3aD41D44D55D59D7bD86D97Da4Db4Dc5De1De3DeaCcbcD1aD1bD2bD2cD32D3bD4bD4dD53D54D5bD64D69D6aD74D79D88D89Db2Dc2Dc3Dd4Dd7Dd8De7De9CaabD11D12D3cD3dD4cDe8"{ run('URL...', 'url='+helpURL); } macro "Preprocessing Clear Background Action Tool - C000T4b12p" { setBatchMode(true); roiManager("reset"); storeColors(); setWhiteOnBlack(); run("Set Scale...", "distance=0 known=0 pixel=1 unit=pixel"); clearBackground(preMinSize, preMaxSize, preThresholdMethod, preNumberOfDilates, false); resetColors(); setBatchMode("exit and display"); selectWindow("Results"); run("Close"); } macro "Simple Adipocytes Segmentation Action Tool- C000T4b12s" { run("ROI Manager..."); roiManager("Show All with labels"); setBatchMode(true); roiManager("reset"); storeColors(); setWhiteOnBlack(); run("Set Scale...", "distance=0 known=0 pixel=1 unit=pixel"); if (simpleUseBinaryWatershed) clearBackground(simpleMinSize, simpleMaxSize, simpleThresholdMethod, simpleNumberOfDilates, true); run("Find Edges"); run("8-bit"); run("Smooth"); run("Invert"); setAutoThreshold(simpleThresholdMethod+ " dark"); run("Convert to Mask"); if (simpleUseBinaryWatershed) run("Watershed"); run("Clear Results"); run("Analyze Particles...", "size="+simpleMinSize+"-"+simpleMaxSize+" circularity=0.00-1.00 show=Nothing add exclude"); run("Revert"); run("Set Scale...", "distance=0 known=0 pixel=1 unit=pixel"); resetColors(); setBatchMode("exit and display"); selectWindow("Results"); run("Close"); roiManager("Show All with labels"); } macro "Watershed Adipocytes Segmentation Action Tool- C000T4b12w" { run("ROI Manager..."); roiManager("Show All with labels"); setBatchMode(true); roiManager("reset"); storeColors(); setWhiteOnBlack(); run("Set Scale...", "distance=0 known=0 pixel=1 unit=pixel"); clearBackground(waterMinSize, waterMaxSize, waterThresholdMethod, waterNumberOfDilates, false); title = getTitle(); run("Set Scale...", "distance=0 known=0 pixel=1 unit=pixel"); run("Find Edges"); run("8-bit"); run("Gaussian Blur...", "sigma=" + waterSigma); run("Watershed Algorithm"); run("Invert"); imageCalculator("AND create", title,"Watershed"); titleResult = getTitle(); selectImage("Watershed"); close(); selectImage(titleResult); setThreshold(1, 255); run("Convert to Mask"); run("Clear Results"); run("Analyze Particles...", "size="+waterMinSize+"-"+waterMaxSize+" circularity=0.00-1.00 show=Nothing add exclude"); selectImage(titleResult); close(); run("Revert"); run("Set Scale...", "distance=0 known=0 pixel=1 unit=pixel"); resetColors(); setBatchMode("exit and display"); selectWindow("Results"); run("Close"); roiManager("Show All with labels"); } macro "Preprocessing Clear Background Action Tool Options" { Dialog.create("Preprocessing Adipocytes Segmentation Options"); Dialog.addNumber("min. size", preMinSize); Dialog.addNumber("max. size", preMaxSize); Dialog.addNumber("nr. of dilates", preNumberOfDilates); Dialog.addChoice("thresholding method", newArray("Default", "Huang", "Intermodes", "IsoData", "IJ_IsoData", "Li", "MaxEntropy", "Mean", "MinError", "Minimum", "Moments", "Otsu", "Percentile", "RenyiEntropy", "Shanbhag", "Triangle", "Yen"), preThresholdMethod); Dialog.show(); preMinSize = Dialog.getNumber(); preMaxSize = Dialog.getNumber(); preNumberOfDilates = Dialog.getNumber(); preThresholdMethod = Dialog.getChoice(); } macro "Simple Adipocytes Segmentation Action Tool Options" { Dialog.create("Simple Adipocytes Segmentation Options"); Dialog.addNumber("min. size", simpleMinSize); Dialog.addNumber("max. size", simpleMaxSize); Dialog.addNumber("nr. of dilates", simpleNumberOfDilates); Dialog.addChoice("thresholding method", newArray("Default", "Huang", "Intermodes", "IsoData", "IJ_IsoData", "Li", "MaxEntropy", "Mean", "MinError", "Minimum", "Moments", "Otsu", "Percentile", "RenyiEntropy", "Shanbhag", "Triangle", "Yen"), simpleThresholdMethod); Dialog.addCheckbox("use binary watershed", simpleUseBinaryWatershed) Dialog.show(); simpleMinSize = Dialog.getNumber(); simpleMaxSize = Dialog.getNumber(); simpleNumberOfDilates = Dialog.getNumber(); simpleThresholdMethod = Dialog.getChoice(); simpleUseBinaryWatershed = Dialog.getCheckbox(); } macro "Watershed Adipocytes Segmentation Action Tool Options" { Dialog.create("Watershed Adipocytes Segmentation Options"); Dialog.addNumber("min. size", waterMinSize); Dialog.addNumber("max. size", waterMaxSize); Dialog.addNumber("sigma", waterSigma); Dialog.addNumber("nr. of dilates", waterNumberOfDilates); Dialog.addChoice("thresholding method", newArray("Default", "Huang", "Intermodes", "IsoData", "IJ_IsoData", "Li", "MaxEntropy", "Mean", "MinError", "Minimum", "Moments", "Otsu", "Percentile", "RenyiEntropy", "Shanbhag", "Triangle", "Yen"), waterThresholdMethod); Dialog.show(); waterMinSize = Dialog.getNumber(); waterMaxSize = Dialog.getNumber(); waterSigma = Dialog.getNumber(); waterNumberOfDilates = Dialog.getNumber(); waterUseBinaryWatershed = Dialog.getChoice(); } function clearBackground(minSize, maxSize, thresholdMethod, numberOfDilates, keepSelection) { title = getTitle(); run("Find Edges"); run("8-bit"); run("Smooth"); run("Invert"); setAutoThreshold(thresholdMethod + " dark"); run("Convert to Mask"); run("Analyze Particles...", "size="+minSize+"-"+maxSize+" circularity=0.00-1.00 show=Nothing add exclude"); roiManager("Deselect"); showStatus("Combining rois"); roiManager("Combine"); run("Clear Outside"); run("Select None"); for (i=0; i>16)&0xff, (oldForeground>>8)&0xff, oldForeground&0xff); setBackgroundColor((oldBackground>>16)&0xff, (oldBackground>>8)&0xff, oldBackground&0xff); } function emptyRoiManager() { roiManager("Deselect"); if (roiManager("count")>0) roiManager("Delete"); }