Jython: need help with moveRoisToOverlay
Posted by
jswalker on
May 05, 2016; 2:34pm
URL: http://imagej.273.s1.nabble.com/Jython-need-help-with-moveRoisToOverlay-tp5016320.html
*UPDATE*: The code still fails, BUT I got it to stop throwing the error...by calling RoiManager by the name I'd set for it earlier in the script. Ahem. Any idea why moveRoisToOverlay might still not be working?
Hi all,
I'm trying to move all (several hundred) ROIs from a processed/mask image onto the original (well, a duplicate of it) in Jython. The error I get is: TypeError: moveRoisToOverlay(): expected 2 args; got 1
But the imagej API says the usage is: moveRoisToOverlay(ImagePlus imp). What am I doing wrong?
Here are my imports:
import os
import time
from ij import IJ, ImagePlus, Prefs
from ij.gui import GenericDialog, WaitForUserDialog, PolygonRoi, Roi
from ij.plugin import Duplicator
from ij.process import ImageConverter, ImageProcessor
from ij.measure import ResultsTable, Measurements
<b>from ij.plugin.frame import RoiManager</b>
from ij.plugin.filter import Binary, MaximumFinder
from ij.plugin.filter import ParticleAnalyzer as pa
from jarray import array
import math
import csv
And here's the bit of script that fails (don't mind the sloppiness, it's in testing):
if RoiManager.moveRoisToOverlay(imp3):
print "RoiManager.moveRoisToOverlay(imp3) worked"
else:
print "RoiManager.moveRoisToOverlay(imp3) didn't work. Trying getRoisAsArray"
for roi in RoiManager.getInstance().getRoisAsArray():
imp3.setRoi(roi)
print "imp3.setRoi(roi) executed without error. Now updateAndDraw-ing."
imp3.updateAndDraw()
Any suggestions would be much appreciated. Thanks in advance!