Login  Register

Re: switch a ROI in javascript

Posted by Jan Eglinger on Feb 28, 2017; 9:36pm
URL: http://imagej.273.s1.nabble.com/switch-a-ROI-in-javascript-tp5018205p5018206.html

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