Login  Register

Re: Jython: moveRoisToOverlay unexpected number of args?

Posted by Jim Passmore-2 on May 05, 2016; 5:38pm
URL: http://imagej.273.s1.nabble.com/Jython-need-help-with-moveRoisToOverlay-tp5016320p5016322.html

jswalker,
Pasting your method call in from Nabble (it doesn't get copied to the email
list...), I assume your error message occurs when you run this line:

if RoiManager.moveRoisToOverlay(imp3):

From the API documentation (you already referenced, but for others who
don't know, go to http://rsb.info.nih.gov/ij/developer/api/, then select
the RoiManager class in lower left pane, and finally find the
moveRoisToOverlay method in right-hand pane), you'll see it is an instance
method, *not* a static method.  That means you need to call it with an
instance of RoiManager, not the class name as you called it.  Something
more like

r = RoiManager.getInstance()  # getInstance() *is* a static method
r.moveRoisToOverlay(imp3)     # now you have 2 arguments--"r", the
RoiManager instance and "imp3".

Your if statement can then be something like

if r is not None:

I just took your snippets of code, and suggested other snippets without
seeing the whole thing, so I hope this works, and gets you started.



*-- Jim Passmore*
Principal Scientist
Sealed Air Corporation



On Thu, May 5, 2016 at 10:34 AM, jswalker <[hidden email]> wrote:

> Hi all,
>
> I'm trying to move all (several hundred) ROIs from a processed/mask image
> onto the original (well, a duplicate of one) 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
> *from ij.plugin.frame import RoiManager*
> 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):
>
>
>
> Any suggestions would be much appreciated. Thanks in advance!
>
>
>
> --
> View this message in context:
> http://imagej.1557.x6.nabble.com/Jython-moveRoisToOverlay-unexpected-number-of-args-tp5016320.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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