Closed ctrueden closed 3 years ago
This is a bug on the Java side. With 01a85190e7df9321beeb674a3914435df9bf5035, one can now dump the Java stack traces by setting DEBUG=1
environment variable. Here is the trace:
java.lang.ClassCastException: net.imglib2.python.ReferenceGuardingRandomAccessibleInterval cannot be cast to net.imglib2.IterableInterval
at net.imagej.ops.map.MapUnaryComputers$IIToIIParallel.compute(MapUnaryComputers.java:87)
at net.imagej.ops.copy.CopyRAI.compute(CopyRAI.java:90)
at net.imagej.ops.copy.CopyRAI.compute(CopyRAI.java:54)
at net.imagej.ops.special.hybrid.UnaryHybridCF.run(UnaryHybridCF.java:75)
at net.imagej.ops.special.hybrid.UnaryHybridCF.run(UnaryHybridCF.java:97)
at org.scijava.command.CommandModule.run(CommandModule.java:199)
at net.imagej.ops.OpEnvironment.run(OpEnvironment.java:950)
at net.imagej.ops.OpEnvironment.run(OpEnvironment.java:136)
Still investigating why this happens, though.
Hopefully this will be fixed by addressing #46 to behave differently. Then we will not trigger this bug in the copy.rai
op.
@ctrueden I'm doing some cleanup on these old issues...I just tried this issue out again on pyimagej=1.0.0
and this no longer seems to be a problem since our move to JPype
. I haven't looked into it but my guess is https://github.com/imagej/pyimagej/issues/46 resolved this for us. My output:
>>> import imagej
>>> ij = imagej.init()
log4j:WARN No appenders could be found for logger (org.bushe.swing.event.EventService).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
>>> ij.getVersion()
2.1.0/1.53c
>>> import numpy as np
>>> z = np.zeros([5, 7])
>>> jz = ij.py.to_java(z)
>>> jz
>>> <java object 'net.imglib2.python.ReferenceGuardingRandomAccessibleInterval'>
>>> ij.py.from_java(z)
array([[0., 0., 0., 0., 0., 0., 0.],
[0., 0., 0., 0., 0., 0., 0.],
[0., 0., 0., 0., 0., 0., 0.],
[0., 0., 0., 0., 0., 0., 0.],
[0., 0., 0., 0., 0., 0., 0.]])
@elevans Thanks. Note that #46 is still open—all that's needed is to use the Images.copy
method from imagej-common in PyImageJ for the rai_to_numpy
function. Someone just needs to test it. It's very likely faster than the current code.
@ctrueden I just pushed a branch to pyimagej testing this: rai-copy-speed
. Images.copy
is faster! I'll post the relevant details on issue #46.
Noticed by @thewtex.