Converting and image to an ImagepPlus body using the wrap function


I’m new to the community and am trying to use imagej in Python. I encounter the following error when trying to process my images using imagej commands:

1st arg can't be coerced to ij.ImagePlus, ij.macro.Interpreter

A previous post on this forum indicated that I needed to use the following to convert my file to an ImagePlus body first:

from net.imglib2.img.display.imagej import ImageJFunctions as IJF
myImagePlus = IJF.wrap( myArrayImg, "myArrayImgTitle" )

I was able to locate an imglib2 jar file and connect it to intellij, but I cannot locate the wrap function. Has there been an update to the imglib2 structure? Any help is greatly appreciated.

-Christopher Brown

Hi @Chbr4046, and welcome to the community!

Are you implying that you use pyimagej?

Or are you using Python as a scripting language inside the Fiji script editor?

The ImageJFunctions class (with the wrap methods) is contained in the imglib2-ij component.

1 Like

Hi, @imagejan.

You are correct, I am trying to use pyimagej.
I was able to find the wrap function, thank you. I am now receiving the same error (wrap(): 1st arg can’t be coerced to ij.ImagePlus), but for the wrap function. Is this possibly due to the images originally being .gif files?

Out of curiosity, what is the difference between imglib2 and imglib2-ij? All of the examples I saw in the imagej documentation implied using just an imglib2 jar file and don’t mention other versions such as the imglib2-ij. Is this a recent development?