Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversion ImagePlus > Dataset > ImagePlus throws UnsupportedOperationException #241

Open
imagejan opened this issue Mar 25, 2020 · 2 comments

Comments

@imagejan
Copy link
Member

The following script:

#@ ConvertService cs

import ij.IJ
import ij.ImagePlus
import net.imagej.Dataset

imp1 = IJ.createImage("Test", "8-bit white", 100, 100, 1);

data1 = cs.convert(imp1, Dataset.class)
imp1converted = cs.convert(data1, ImagePlus.class)

throws:

java.lang.UnsupportedOperationException
	at java.util.AbstractList.set(AbstractList.java:132)
	at net.imglib2.img.planar.PlanarImg.setPlane(PlanarImg.java:256)
	at net.imglib2.img.planar.PlanarImg.setPlane(PlanarImg.java:66)
	at net.imglib2.img.display.imagej.PlanarImgToVirtualStack.setPlaneCastType(PlanarImgToVirtualStack.java:168)
	at net.imglib2.img.display.imagej.PlanarImgToVirtualStack.setPixelsZeroBasedIndex(PlanarImgToVirtualStack.java:163)
	at net.imglib2.img.display.imagej.AbstractVirtualStack.setPixels(AbstractVirtualStack.java:95)
	at ij.ImagePlus.setProcessor2(ImagePlus.java:645)
	at ij.ImagePlus.setStack(ImagePlus.java:709)
	at ij.ImagePlus.<init>(ImagePlus.java:155)
	at net.imglib2.img.display.imagej.PlanarImgToVirtualStack.wrap(PlanarImgToVirtualStack.java:115)
	at net.imagej.legacy.translate.ImagePlusCreator.createImagePlus(ImagePlusCreator.java:112)
	at net.imagej.legacy.translate.ImagePlusCreator.createLegacyImage(ImagePlusCreator.java:96)
	at net.imagej.legacy.translate.ImagePlusCreator.createLegacyImage(ImagePlusCreator.java:89)
	at net.imagej.legacy.translate.ImageTranslator.createLegacyImage(ImageTranslator.java:76)
	at net.imagej.legacy.LegacyImageMap.registerDataset(LegacyImageMap.java:234)
	at net.imagej.legacy.convert.DatasetToImagePlusConverter.convert(DatasetToImagePlusConverter.java:69)
	at org.scijava.convert.AbstractConvertService.convert(AbstractConvertService.java:128)
	at org.scijava.convert.ConvertService$convert.call(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
	at Script37.run(Script37.groovy:10)
	at org.scijava.plugins.scripting.groovy.GroovyScriptEngine.eval(GroovyScriptEngine.java:303)
	at org.scijava.plugins.scripting.groovy.GroovyScriptEngine.eval(GroovyScriptEngine.java:122)
	at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
	at org.scijava.script.ScriptModule.run(ScriptModule.java:160)
	at org.scijava.module.ModuleRunner.run(ModuleRunner.java:168)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
	at org.scijava.thread.DefaultThreadService.lambda$wrap$20(DefaultThreadService.java:228)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
@ctrueden
Copy link
Member

I just ran into this as well, via the following Groovy script:

#@ ConvertService cs
#@ Img img
import ij.ImagePlus
imp = cs.convert(img, ImagePlus.class);
print(imp)

After opening the Blobs image (which opens natively as an ImagePlus, and is implicitly converted to Img to fill the img parameter here).

@imagejan
Copy link
Member Author

Another way to reproduce this, with the Blobs sample image opened in the legacy UI:

#@ Dataset input
#@ UIService ui

ui.show(input)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants