Hello,
I am trying to quantify the density of punctate fluorescent labeling in tissue slices. The end result of my routine is an set of ROIs that can contain a couple thousand individual regions (one for each possible label). I wrote the macro below to scan each ROI and remove it from the set if its mean intensity is below a threshold (vMeanCutOff). The macro works well but is VERY slow. It seems like everytime an ROI is checked, the entire set gets redrawn. If anyone has a suggestion for speeding this up (or a better way to do this to begin with) I'd greatly appreciate it! vMeanCutOff = 112.71 j = 0 run("Clear Results") while (j<roiManager("count")) { run("Clear Results"); roiManager("Select", j); roiManager("Measure"); vMean = getResult("Mean",0); if (vMean < vMeanCutOff) roiManager("Delete"); if (vMean>= vMeanCutOff) j++; } Thanks! |
> Hello,
> > I am trying to quantify the density of punctate fluorescent labeling > in tissue slices. The end result of my routine is an set of ROIs that > can contain a couple thousand individual regions (one for each > possible label). I wrote the macro below to scan each ROI and remove > it from the set if its mean intensity is below a threshold > (vMeanCutOff). The macro works well but is VERY slow. It seems like > everytime an ROI is checked, the entire set gets redrawn. If anyone > has a suggestion for speeding this up (or a better way to do this to > begin with) I'd greatly appreciate it! > > vMeanCutOff = 112.71 > j = 0 > run("Clear Results") > while (j<roiManager("count")) { > run("Clear Results"); > roiManager("Select", j); > roiManager("Measure"); > vMean = getResult("Mean",0); > if (vMean < vMeanCutOff) roiManager("Delete"); > if (vMean>= vMeanCutOff) j++; > } Run the macro in batch mode. This example macro runs ~100 times faster in batch mode: setBatchMode(true); if (isOpen("ROI Manager")) { selectWindow("ROI Manager"); run("Close"); } run("Cell Colony (31K)"); run("Subtract Background...", "rolling=25 light"); setAutoThreshold(); run("Analyze Particles...", "size=0 circularity=0.00 exclude add"); cutOff = 175; startTime = getTime; j = 0; print("Count (before): "+roiManager("count")); while (j<roiManager("count")) { roiManager("Select", j); getStatistics(area, vMean); if (vMean < cutOff) roiManager("Delete"); if (vMean>= cutOff) j++; } print("Count (after): "+roiManager("count")); print(getTime-startTime+"ms"); -wayne |
Thank you, Wayne... this is much better!
Best, Nate
|
Free forum by Nabble | Edit this page |