Help with macro

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

Help with macro

JimmiB
Hi there,
I am wondering if there is an easy way to get the median of a ROI
I am analyzing composite image stacks.
I generate a list of ROIs and then use

 for (i=0; i<=rois-1; i++){
          roiManager("Select",i);
getStatistics(area);
Stack.setPosition(1, 1, i+1);
//print(area);
setResult("Frame", i, getSliceNumber());
setResult("Area", i, area);
 for (j=1; j<=c; j++){
Stack.setPosition(j, 1, i+1);
getStatistics(area, mean);
//print(mean);
setResult("Channel"+j, i, mean);
          }
}

I would like to modify this to also get the median (as it is less prone to
noise).
I have the feeling this will require writing the results to an alternate
"results" window and then using the measure function to get the median for
each channel and then write this to the alternate results.
If there is a simpler option I would love to hear it.

Cheers,
James
*
                       *
*Dr James Burchfield*
The Garvan Institute of Medical Research
384 Victoria Street
Darlinghurst, NSW, 2010
Australia

Email: [hidden email]
Phone:+61 2 92958229
Web: *www.garvan.org.au*

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

Re: Help with macro

George Patterson-3
Hi James,
Can you change your approach to something like the following?
The List functions might make it easier to get the information you want without doing what you'd suggested.
George


rois=roiManager("count");
for (i=0; i<rois; i++){
roiManager("Select",i);
List.setMeasurements;
//print(List.getList);  //print the list to see what the keys you need to use.
setResult("Area", i, List.getValue("Area"));
setResult("Median", i, List.getValue("Median"));
setResult("Mean", i, List.getValue("Mean"));
}
}


On May 22, 2013, at 2:56 AM, James Burchfield wrote:

> Hi there,
> I am wondering if there is an easy way to get the median of a ROI
> I am analyzing composite image stacks.
> I generate a list of ROIs and then use
>
> for (i=0; i<=rois-1; i++){
>          roiManager("Select",i);
> getStatistics(area);
> Stack.setPosition(1, 1, i+1);
> //print(area);
> setResult("Frame", i, getSliceNumber());
> setResult("Area", i, area);
> for (j=1; j<=c; j++){
> Stack.setPosition(j, 1, i+1);
> getStatistics(area, mean);
> //print(mean);
> setResult("Channel"+j, i, mean);
>          }
> }
>
> I would like to modify this to also get the median (as it is less prone to
> noise).
> I have the feeling this will require writing the results to an alternate
> "results" window and then using the measure function to get the median for
> each channel and then write this to the alternate results.
> If there is a simpler option I would love to hear it.
>
> Cheers,
> James
> *
>                       *
> *Dr James Burchfield*
> The Garvan Institute of Medical Research
> 384 Victoria Street
> Darlinghurst, NSW, 2010
> Australia
>
> Email: [hidden email]
> Phone:+61 2 92958229
> Web: *www.garvan.org.au*
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

George H. Patterson
Building 13 3E33
13 South Drive
Biophotonics Section
National Institute of Biomedical Imaging and Bioengineering
National Institutes of Health
Bethesda, MD 20892
Office: 301-443-0241
Fax: 301-496-6608
[hidden email]

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