Save a single ROI as .roi file from macro

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

Save a single ROI as .roi file from macro

ben.s.carlson
Hello,

I'd like to save an ROI as a .roi file from a macro.  I see the functionality to save as a zip, however I only have one roi in the roi manager at a time, so it would be much better to save as a .roi file.

I'm using imageJ version 1.49b.

Here is a snippet of my code.

roiManager("Select", 0); //Only one roi in ROI manager, select it
roiManager("Save Selected", dir + "\\myfile.roi"); //dir is the working directory

I've also tried the "Save" command, but both require that I save the file as .zip.  Is it possible to save just the roi?

Thank you for the help!

Ben
Reply | Threaded
Open this post in threaded view
|

Re: Save a single ROI as .roi file from macro

Aryeh Weiss
On 6/13/14, 5:13 AM, ben.s.carlson wrote:

> Hello,
>
> I'd like to save an ROI as a .roi file from a macro.  I see the
> functionality to save as a zip, however I only have one roi in the roi
> manager at a time, so it would be much better to save as a .roi file.
>
> I'm using imageJ version 1.49b.
>
> Here is a snippet of my code.
>
> roiManager("Select", 0); //Only one roi in ROI manager, select it
> roiManager("Save Selected", dir + "\\myfile.roi"); //dir is the working
> directory
>
> I've also tried the "Save" command, but both require that I save the file as
> .zip.  Is it possible to save just the roi?
>

The following saves the roi as a .roi file.


if (isOpen("ROI Manager")) {
     selectWindow("ROI Manager");
     run("Close");
}
makeRectangle(360, 151, 135, 95);
roiManager("Add");
roiManager("Select", 0);
saveAs("Selection", "/Users/amw1/Desktop/test.roi");

It saves the lone ROI as test.roi

--aryeh

--
Aryeh Weiss
Faculty of Engineering
Bar Ilan University
Ramat Gan 52900 Israel

Ph:  972-3-5317638
FAX: 972-3-7384051

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

Re: Save a single ROI as .roi file from macro

Rasband, Wayne (NIH/NIMH) [E]
In reply to this post by ben.s.carlson
On Jun 12, 2014, at 10:13 PM, ben.s.carlson wrote:

> Hello,
>
> I'd like to save an ROI as a .roi file from a macro.  I see the
> functionality to save as a zip, however I only have one roi in the roi
> manager at a time, so it would be much better to save as a .roi file.
>
> I'm using imageJ version 1.49b.
>
> Here is a snippet of my code.
>
> roiManager("Select", 0); //Only one roi in ROI manager, select it
> roiManager("Save Selected", dir + "\\myfile.roi"); //dir is the working
> directory
>
> I've also tried the "Save" command, but both require that I save the file as
> .zip.  Is it possible to save just the roi?

Use the saveAs("Selection",path) macro function. Here is an example that saves the first ROI in the ROI Manager as a .roi file in the user's home directory.

  roiManager("Select", 0);
  dir = getDirectory("home");
  saveAs("Selection", dir+"myfile.roi");

-wayne

> --
> View this message in context: http://imagej.1557.x6.nabble.com/Save-a-single-ROI-as-roi-file-from-macro-tp5008184.html
> Sent from the ImageJ mailing list archive at Nabble.com.

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