ROI intersection

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

ROI intersection

Lenk, Sandor
Hi all,

Has anybody an idea how to create a ROI intersection in a macro easily?

If I wanted to realize it with 2 subtractions (intersection=
roi2-(roi1-roi2)) using the Alt shortcut I had problems. (For example:
if the difference is more than 1 roi, or if the two ROIs are the
same...)


Best regards,

Sandor.
Reply | Threaded
Open this post in threaded view
|

Re: ROI intersection

dscho
Hi,

On Fri, 7 Jul 2006, Lenk, Sandor wrote:

> Has anybody an idea how to create a ROI intersection in a macro easily?

If you'd could use a plugin instead of a macro, it should be easy: just
use the and() method of ShapeRoi. As far as macros are concerned, I doubt
you can do it, since they really can operate on one Roi at a time only.

Ciao,
Dscho
Reply | Threaded
Open this post in threaded view
|

Re: ROI intersection

Gabriel Landini
In reply to this post by Lenk, Sandor
On Fri, 7 Jul 2006, Lenk, Sandor wrote:
> Has anybody an idea how to create a ROI intersection in a macro easily?

You can use logical operations on the filled ROIs:

1. Duplicate image, subtract 1
2. Create ROI 1, fill it and threshold (call it Binary 1)
3. Go to original image
4. Duplicate image, subtract 1
5. Create ROI 2, fill it and threshold (call it Binary 2)
6. AND Binary 1 &  Binary 2
7. Create ROI from the result using the new Create Selection and store in ROI
Manager
8. Go to original image and recall ROI from ROI Manager

I hope it helps.

Gabriel
Reply | Threaded
Open this post in threaded view
|

Re: ROI intersection

Wayne Rasband
>> Has anybody an idea how to create a ROI intersection in a macro  
>> easily?

Here is a macro that creates the intersection of two ROI Manager  
selections. It requires ImageJ 1.37j, which adds the  
Edit>Selection>Create Selection command.

   requires("1.37j");
   orig = getImageID();
   setBatchMode(true);
   if (roiManager("Count")!=2)
       exit("Two ROIs in ROI Manager required");
   roiManager("Select", 0);
   run("Create Mask");
   rename("Mask1");
   mask1 = getImageID();
   roiManager("Select", 1);
   run("Create Mask");
   mask2 = getImageID();
   imageCalculator("AND", mask2, mask1);
   run("Create Selection");
   roiManager("Add");
   selectImage(orig);
   roiManager("Select", 2);
   roiManager("Rename", "Intersection");

-wayne
Reply | Threaded
Open this post in threaded view
|

AW: ROI intersection

Trevor DeVaney
How can I rename a file without opening it ?

Dr. T.T.J DeVaney Ph.D.,BSc. Hons., MIBiol

Institut für Biophysik
Zentrum für Physiologische Medizin

Medizinische Universität Graz
Harrachgasse 21/IV
A-8010 Graz
Österreich

Tel. +43 664 1518571 od. +43 316 380 7759
Fax +43 316 380 9660
email [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: AW: ROI intersection

Wayne Rasband
> How can I rename a file without opening it ?

The macro language in v1.38b, due later this week, has a File.rename()
function. This example changes the name of the file "map.tif" on my
desktop to "map2.tif".

    File.getAbsolutePath("");
    dir = "/Users/wayne/Desktop/";
    File.exists(dir+"map.tif");
    File.length(dir+"map.tif");
    File.isDirectory(dir+"map.tif");
    File.rename(dir+"map.tif", dir+"stack/map2.tif");

Here is the "Log" window output:

     /Users/wayne/java/source  [default directory]
    1  [exists() returns true]
    307968  [length in bytes]
    0  [isDirectory() returns false]
    1  [rename() returns true]

-wayne