switch a ROI in javascript

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

switch a ROI in javascript

lechristophe
Hi,

I'm writing a script (js) that takes a ROI in the ROI manager, process it,
and generates a new ROI. I'd like to replace the input ROI by the output
ROI in the ROI manager at the same place, but with a modified name. Do you
know what is the easiest way to do that?

Thanks for your help,

Christophe

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

Re: switch a ROI in javascript

Jan Eglinger
Hi Christophe,

On 28/02/2017 21:53, Christophe Leterrier wrote:
> I'm writing a script (js) that takes a ROI in the ROI manager, process it,
> and generates a new ROI. I'd like to replace the input ROI by the output
> ROI in the ROI manager at the same place, but with a modified name. Do you
> know what is the easiest way to do that?

The Javascript below should get you started. Hope that helps.
Jan

********************

// @ImagePlus imp
// @LogService log

importClass(Packages.ij.plugin.frame.RoiManager)
var rm = RoiManager.getInstance()
roi = rm.getRoi(rm.getSelectedIndex())

// printing some output to the Console window
log.info("Now replacing ROI '" + roi.getName() +
                        "' with index " + rm.getSelectedIndex())

imp.setRoi(71,201,32,20)
rm.runCommand("Update")

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