Restore a ROI from coordinate data

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

Restore a ROI from coordinate data

maupertius
I've made a macro that saves the coordinates of a freeform that was drawn by the user on a given image. To do that, I use the command:

Roi.getCoordinates(x, y);

I then save my coordinates on a text file. Is there a way to restore my freeform by looking at the coordinates on this text file?
Reply | Threaded
Open this post in threaded view
|

Re: Restore a ROI from coordinate data

Rasband, Wayne (NIH/NIMH) [E]
On Mar 26, 2014, at 6:47 AM, maupertius wrote:

> I've made a macro that saves the coordinates of a freeform that was drawn by
> the user on a given image. To do that, I use the command:
>
> Roi.getCoordinates(x, y);
>
> I then save my coordinates on a text file. Is there a way to restore my
> freeform by looking at the coordinates on this text file?

It is easier to restore a selection that has been saved as a .roi file. For example, use

   path = getDirectory("home")+"test.roi";
   saveAs("Selection", path);

to save the current selection in your home directory and use open(path) to restore it.

-wayne

--
> View this message in context: http://imagej.1557.x6.nabble.com/Restore-a-ROI-from-coordinate-data-tp5007086.html
> Sent from the ImageJ mailing list archive at Nabble.com.

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

Re: Restore a ROI from coordinate data

maupertius
Thank you, that is what I was after!
Reply | Threaded
Open this post in threaded view
|

Re: Restore a ROI from coordinate data

dscho
Hi,

On Wed, 26 Mar 2014, maupertius wrote:

> Thank you, that is what I was after!

If you have too many ROIs saved as text files to realistically recreate as
.roi files, you can easily write a macro that reads those text files and
uses the split() and makeSelection() functions:

http://imagej.nih.gov/ij/developer/macro/functions.html#split
http://imagej.nih.gov/ij/developer/macro/functions.html#makeSelection

Ciao,
Johannes

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

Re: Restore a ROI from coordinate data

maupertius
<quote author="Johannes Schindelin">

If you have too many ROIs saved as text files to realistically recreate as
.roi files, you can easily write a macro that reads those text files and
uses the split() and makeSelection() functions:

http://imagej.nih.gov/ij/developer/macro/functions.html#split
http://imagej.nih.gov/ij/developer/macro/functions.html#makeSelection

Ciao,
Johannes

--
That is very useful. As you pointed out, my coordinates are saved on a text file so I'm better off doing what you suggest instead.

Tanks a million