Posted by
Jeremy Adler on
URL: http://imagej.273.s1.nabble.com/Help-with-macro-iterating-slices-of-a-stack-tp5023279p5023280.html
Hi Pedro,
Line 10, multi measure
Uses all ROIs to measure all images in your stack.
Delete it, Line 8 makes the measurements and generates the ROIs.
Line 8, analyse particles - the "clear" will empty the results window each in each iteration, so you delete the results from the previous slice.
Try removing the "clear".
Line 7, set measurements does not need to be in the loop, run it before the loop.
It doesn't do any harm in the loop, but is neater.
Best wishes
Jeremy Adler
BioVis
-----Original Message-----
From: ImageJ Interest Group <
[hidden email]> On Behalf Of Pedro J Camello
Sent: Sunday, May 3, 2020 5:19 PM
To:
[hidden email]
Subject: Help with macro iterating slices of a stack
Hi all,
I´m stuck with a macro written to iterate on all the slices of a binary stack.
In each slice, the code below should run Analyze particles, place the particles in the ROI Manager and Measure all of them.
The problem is that, after the first iteration, once i=2 the code does not generate a set of ROIs in the ROI Manager (line 8).
I can´t understand why the Analyze particles command runs in the first instance and fails afterwards…
I don´t want the Analyze particles command to run all the slices because I want to Measure each slice separately (maybe I could arrange it using the labels column of the Results table, but I would prefer to avoid it)
Any help will be welcome
Code:
1 // Up to this point I have a binary stack with all the nuclei (watershed) ready to be counted;
2 for (i=1; i<nSlices+1;i++) {
3 Stack.setSlice(i);
4 Stack.getPosition(channel, slice, frame);
5 print("Slice number = "+slice); //Just to check the slice number
6 //waitForUser("Check i and slice", "i = "+i+" Slice = "+slice);
7 run("Set Measurements...", "area display redirect=None decimal=2");
8 run("Analyze Particles...", "size=150-Infinity pixel clear include add slice");
9 //waitForUser("Check rois OK", "Ther are "+roiManager("count")+" ROIs");
10 roiManager("multi-measure");
12 print("Slice num = " +slice+"Cells = "+roiManager("count")); roiManager("reset");
13 }
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.htmlNär du har kontakt med oss på Uppsala universitet med e-post så innebär det att vi behandlar dina personuppgifter. För att läsa mer om hur vi gör det kan du läsa här:
http://www.uu.se/om-uu/dataskydd-personuppgifter/E-mailing Uppsala University means that we will process your personal data. For more information on how this is performed, please read here:
http://www.uu.se/en/about-uu/data-protection-policy--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html