Add waitForUser and wand to macro

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Add waitForUser and wand to macro

Mark Matsche
I have the following macro (below) to analyze a batch of images in a folder.
Initially, I was using a higher magnification and tissues filled the field
of view.  Now I'm using a lower magnification and need to select the tissue
in the field of view before thresholding and doing the analysis.  The wand
tool works well (50% tolerance) to quickly select tissue.  

What I would like is for an additional step to this macro to allow me to use
the wand tool to select the tissue before converting to 8 bit and
thresholding.  Such as
1)ask for folder (choose directory)
2)open image from folder
3)allow the operator use the wand tool (waitforuser)
4)8-bit
5)threshold (waitforuser)
6)analyze particles
7)store results
8)continue loop until all images have been processed

Can someone help by adapting this macro script to accomplish this? I added a
sample image at the end.

macro "mac agg" {dir = getDirectory("Choose Source Directory");
  list = getFileList(dir);
  for (i=0; i<list.length; i++) {
     open(dir+list[i]);
run(&quot;8-bit&quot;);
  setAutoThreshold(&quot;Default&quot;);
run(&quot;Threshold...&quot;);
     waitForUser(&quot;Adjust threshold, then click 'OK' &quot;);
  run(&quot;Analyze Particles...&quot;, &quot;size=50-Infinity display
exclude include summarize&quot;);
  run(&quot;Set Measurements...&quot;, &quot;area mean min
display&quot;);close();}
  if (nResults != 0){
        for (i=0; i&lt;nResults; i++){
                resLabel = getResultLabel(i);
                if (indexOf(resLabel, &quot;.tif&quot;) > 0) {
                        resLabel = substring (resLabel, 0,
lastIndexOf(resLabel,".tif")); // remove the ".tif" in the text string
                        n = lengthOf(resLabel); // number of characters in
the text string
                        LBL = substring (resLabel, 0, n-2); // remove the
last 2 characters to get the label
                        section = substring (resLabel, n-1, n); // remove
all text in label except last character
                        setResult("Label", i, LBL); // set the text string
for new label
                        setResult("Section", i, section); // set the text
string for section
                }
} } else {
        showMessage("No Result found in result table");
}
  selectWindow("Results");
  saveAs("Measurements", "C:\\Documents and
Settings\\jshaner\\Desktop\\test.xls");
close();close();close();
};

<http://imagej.1557.x6.nabble.com/file/t380219/16wp318_sm.jpg>




--
Sent from: http://imagej.1557.x6.nabble.com/

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Add waitForUser and wand to macro

Mark Matsche
As a follow up, I'm not interested in the area of individual particle sizes.
I need the %area of all particles primarily but it would be useful to know
the.  Summary results gives me the total area of all particles and %area but
not the area of the tissue.  Since I now need to select the tissue section
(using wand tool) can I get the summary results to include the area of the
tissue now defined by the wand?  I know it can be calculated from the given
information, but was curious if it can be added to the summary results.

Thanks!



--
Sent from: http://imagej.1557.x6.nabble.com/

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html