run("Restore Selection"); bug?

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

run("Restore Selection"); bug?

Michael Cammer
I wrote a simple macro to measure the proportion of myelin to axon in
tol blue stained cross sections of CNS but found that sometimes and
unpredictably the results didn't make sense.  Therefore, I drew black
circles of known size containing white circles of known size.  I
found that the Restore Selection command didn't always place the ROI
in the center of a cropped field.

For an example, please see http://www.aecom.yu.edu/aif/temp/restore_roi_bug.jpg
where I ran the macro repeatedly stopping it at the //exit(); command.

Thanks.


macro "Measure manually traced axon [q]"{

   roiManager("Add");

   run("Set Scale...", "distance=1 known=1 pixel=1 unit=");
   run("Set Measurements...", "area fit circularity feret's
redirect=None decimal=5");
   run("Clear Results");
   run("Measure");

    area = getResult("Area",0);
    feret = getResult("Feret",0);
    circularity = getResult("Circ.",0);
    minor = getResult("Minor",0);

    run("Duplicate...", "title=temp");
    run("Restore Selection");
    setAutoThreshold();
    run("Convert to Mask");
    run("Restore Selection");
    getHistogram(values, counts, 256);
    run("Select None");
//exit();
    close();
    axon = counts[255];
    myelin = counts[0];
    rstructure = sqrt( (axon+myelin)/3.1415 );        // radius of
the entire structure
    raxon = sqrt(axon/3.1415);                               //
radius axon only
    areacheck = axon + myelin;
____________________________________________________________________________
Michael Cammer   Analytical Imaging Facility   Albert Einstein Coll. of Med.
URL:  http://www.aecom.yu.edu/aif/ 
Reply | Threaded
Open this post in threaded view
|

Re: run("Restore Selection"); bug?

Martin du Saire
If your selection is the same for each image or for a series of
images consider saving it to disk.  Then instead of run("Restore
Selection"), use open()

      run("Selection...", "path="+path+"compositeMask.roi");
      run("Select None");

      selectImage('Next image');
      open(path+"compositeMask.roi"); // replaces run("Restore Selection");


M


At 01:34 PM 2/27/2007, you wrote:

>I wrote a simple macro to measure the proportion of myelin to axon
>in tol blue stained cross sections of CNS but found that sometimes
>and unpredictably the results didn't make sense.  Therefore, I drew
>black circles of known size containing white circles of known
>size.  I found that the Restore Selection command didn't always
>place the ROI in the center of a cropped field.
>
>For an example, please see
>http://www.aecom.yu.edu/aif/temp/restore_roi_bug.jpg
>where I ran the macro repeatedly stopping it at the //exit(); command.
>
>Thanks.
>
>
>macro "Measure manually traced axon [q]"{
>
>   roiManager("Add");
>
>   run("Set Scale...", "distance=1 known=1 pixel=1 unit=");
>   run("Set Measurements...", "area fit circularity feret's
> redirect=None decimal=5");
>   run("Clear Results");
>   run("Measure");
>
>    area = getResult("Area",0);
>    feret = getResult("Feret",0);
>    circularity = getResult("Circ.",0);
>    minor = getResult("Minor",0);
>
>    run("Duplicate...", "title=temp");
>    run("Restore Selection");
>    setAutoThreshold();
>    run("Convert to Mask");
>    run("Restore Selection");
>    getHistogram(values, counts, 256);
>    run("Select None");
>//exit();
>    close();
>    axon = counts[255];
>    myelin = counts[0];
>    rstructure = sqrt( (axon+myelin)/3.1415 );        // radius of
> the entire structure
>    raxon = sqrt(axon/3.1415);                               //
> radius axon only
>    areacheck = axon + myelin;
>____________________________________________________________________________
>Michael Cammer   Analytical Imaging Facility   Albert Einstein Coll. of Med.
>URL:  http://www.aecom.yu.edu/aif/
Reply | Threaded
Open this post in threaded view
|

Re: run("Restore Selection"); bug?

Wayne Rasband
In reply to this post by Michael Cammer
ImageJ 1.38k, available at <http://rsb.info.nih.gov/ij/notes.html>,  
fixes a bug that sometimes caused the Restore Selection command to fail  
if the selection was the same size as the destination image.

-wayne

On Feb 27, 2007, at 2:34 PM, Michael Cammer wrote:

> I wrote a simple macro to measure the proportion of myelin to axon in  
> tol blue stained cross sections of CNS but found that sometimes and  
> unpredictably the results didn't make sense.  Therefore, I drew black  
> circles of known size containing white circles of known size.  I found  
> that the Restore Selection command didn't always place the ROI in the  
> center of a cropped field.
>
> For an example, please see  
> http://www.aecom.yu.edu/aif/temp/restore_roi_bug.jpg
> where I ran the macro repeatedly stopping it at the //exit(); command.
>
> Thanks.
>
>
> macro "Measure manually traced axon [q]"{
>
>   roiManager("Add");
>
>   run("Set Scale...", "distance=1 known=1 pixel=1 unit=");
>   run("Set Measurements...", "area fit circularity feret's  
> redirect=None decimal=5");
>   run("Clear Results");
>   run("Measure");
>
>    area = getResult("Area",0);
>    feret = getResult("Feret",0);
>    circularity = getResult("Circ.",0);
>    minor = getResult("Minor",0);
>
>    run("Duplicate...", "title=temp");
>    run("Restore Selection");
>    setAutoThreshold();
>    run("Convert to Mask");
>    run("Restore Selection");
>    getHistogram(values, counts, 256);
>    run("Select None");
> //exit();
>    close();
>    axon = counts[255];
>    myelin = counts[0];
>    rstructure = sqrt( (axon+myelin)/3.1415 );        // radius of the  
> entire structure
>    raxon = sqrt(axon/3.1415);                               // radius  
> axon only
>    areacheck = axon + myelin;
> _______________________________________________________________________
> _____
> Michael Cammer   Analytical Imaging Facility   Albert Einstein Coll.  
> of Med.
> URL:  http://www.aecom.yu.edu/aif/