scifio / scifio-hdf5

SCIFIO format plugins for reading and writing HDF5 data.
BSD 2-Clause "Simplified" License
0 stars 4 forks source link

Saving hyperstack as .ims fails #2

Open imagejan opened 4 years ago

imagejan commented 4 years ago

When trying the following script:

#@ DatasetIOService io
#@ Dataset img
#@ File (style="save") file

io.save(img, file.getAbsolutePath())

with the Mitosis sample image (2C x 5Z x 51T) and a file name ending on ".ims", I get the following stack trace:

java.io.IOException: io.scif.img.ImgIOException: io.scif.FormatException: SCIFIO exception when writing to file FileLocation:file:/E:/eglijan/temp-debug/testSavingSCIFIO.ims:
Channels * Frames * Z Slices must equal number of planes
    at io.scif.services.DefaultDatasetIOService.save(DefaultDatasetIOService.java:259)
    at io.scif.services.DefaultDatasetIOService.save(DefaultDatasetIOService.java:231)
    at io.scif.services.DatasetIOService$save.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:135)
    at Script3.run(Script3.groovy:5)
    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$2(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)
Caused by: io.scif.img.ImgIOException: io.scif.FormatException: SCIFIO exception when writing to file FileLocation:file:/E:/eglijan/temp-debug/testSavingSCIFIO6.ims:
Channels * Frames * Z Slices must equal number of planes
    at io.scif.img.ImgSaver.writeImg(ImgSaver.java:437)
    at io.scif.img.ImgSaver.writeImg(ImgSaver.java:414)
    at io.scif.img.ImgSaver.writeImg(ImgSaver.java:390)
    at io.scif.img.ImgSaver.saveImg(ImgSaver.java:175)
    at io.scif.img.ImgSaver.saveImg(ImgSaver.java:158)
    at io.scif.services.DefaultDatasetIOService.save(DefaultDatasetIOService.java:256)
    ... 18 more

(tested with scifio-hdf5-0.2.0 and scifio-0.38.3-SNAPSHOT on the classpath)

imagejan commented 4 years ago

After changing this line to include the actual numbers:

https://github.com/scifio/scifio-hdf5/blob/a2876689903540583a78d395c3d79dc069178be4/src/main/java/io/scif/formats/ImarisFormat.java#L107

-                   "Channels * Frames * Z Slices must equal number of planes");
+                   "Channels (" + sizeC + ") * Frames (" + sizeT + ") * Z Slices (" + sizeZ + ") must equal number of planes (" + meta.get(0).getPlaneCount() + ")");

I observed that meta.get(0).getPlaneCount() returns 255 in this case, whereas the Mitosis dataset contains 510 planes (CZT).