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

ZarrReader: Update to support 0.4.0 datasets #8

Merged
merged 10 commits into from
Mar 14, 2022
Merged

Conversation

dgault
Copy link
Member

@dgault dgault commented Sep 29, 2021

Some minor changes to support metadata from 0.3.0 based on https://ngff.openmicroscopy.org/latest/#metadata
Also some handling of datasets that don't have a 5d shape in .zarray

This should support reading of datasets in 0.3.0 and backwards compatibility should be maintained.

@will-moore
Copy link
Member

Hi David,
If I wanted to test your changes, what are the steps I need to build this, include it into what jar, alongside other jars etc and use it to showinf or to open images in Fiji?
Thanks

@pwalczysko
Copy link
Member

Hi David, If I wanted to test your changes, what are the steps I need to build this, include it into what jar, alongside other jars etc and use it to showinf or to open images in Fiji? Thanks

The workflow is:

  1. Install maven if not have it already from https://maven.apache.org/install.html
  2. being in the top folder of this repo, run
mvn clean package
  1. cd into the target folder
cd target
  1. find in the target folder the file OMEZarrReader-0.1.0-SNAPSHOT.jar
  2. copy this file and paste it into the jars > bio-formats subfolder of your Fiji
  3. restart your Fii and click Plugins > Bio-formats > Bio-formats importer
  4. Select a file inside the 0 subfolder of your local zarr
  5. click off the B-F window
  6. in the Series chooser, choose all series
  7. click OK

@pwalczysko
Copy link
Member

Following the workflow #8 (comment) I get following error:

Exception in thread "BioFormats-ThumbLoader" java.lang.NoSuchMethodError: ucar.ma2.DataType.getType(Ljava/lang/Class;Z)Lucar/ma2/DataType;
	at com.bc.zarr.ucar.NetCDF_Util.createArrayWithGivenStorage(NetCDF_Util.java:46)
	at com.bc.zarr.ZarrArray.read(ZarrArray.java:326)
	at com.bc.zarr.ZarrArray.read(ZarrArray.java:298)
	at loci.formats.services.JZarrServiceImpl.readBytes(JZarrServiceImpl.java:239)
	at loci.formats.in.ZarrReader.openBytes(ZarrReader.java:394)
	at loci.formats.FormatReader.openBytes(FormatReader.java:897)
	at loci.formats.FormatReader.openBytes(FormatReader.java:868)
	at loci.formats.FormatTools.openThumbBytes(FormatTools.java:1308)
	at loci.formats.FormatReader.openThumbBytes(FormatReader.java:918)
	at loci.formats.ReaderWrapper.openThumbBytes(ReaderWrapper.java:360)
	at loci.formats.ChannelSeparator.openThumbBytes(ChannelSeparator.java:238)
	at loci.formats.ReaderWrapper.openThumbBytes(ReaderWrapper.java:360)
	at loci.formats.DimensionSwapper.openThumbBytes(DimensionSwapper.java:255)
	at loci.formats.ReaderWrapper.openThumbBytes(ReaderWrapper.java:360)
	at loci.formats.ReaderWrapper.openThumbBytes(ReaderWrapper.java:360)
	at loci.formats.ReaderWrapper.openThumbBytes(ReaderWrapper.java:360)
	at loci.formats.ReaderWrapper.openThumbBytes(ReaderWrapper.java:360)
	at loci.formats.gui.BufferedImageReader.openThumbImage(BufferedImageReader.java:100)
	at loci.plugins.in.ThumbLoader.loadThumb(ThumbLoader.java:147)
	at loci.plugins.in.ThumbLoader.run(ThumbLoader.java:118)
	at java.lang.Thread.run(Thread.java:748)
There was a problem with the class ucar.ma2.DataType which can be found here:
/Applications/Fiji.app/jars/cdm-4.6.13.jar
/Applications/Fiji.app/jars/netcdf-4.3.22.jar
/Applications/Fiji.app/jars/bio-formats/OMEZarrReader-0.1.0-SNAPSHOT.jar

WARNING: multiple locations found!
java.lang.NoSuchMethodError: ucar.ma2.DataType.getType(Ljava/lang/Class;Z)Lucar/ma2/DataType;
	at com.bc.zarr.ucar.NetCDF_Util.createArrayWithGivenStorage(NetCDF_Util.java:46)
	at com.bc.zarr.ZarrArray.read(ZarrArray.java:326)
	at com.bc.zarr.ZarrArray.read(ZarrArray.java:298)
	at loci.formats.services.JZarrServiceImpl.readBytes(JZarrServiceImpl.java:239)
	at loci.formats.in.ZarrReader.openBytes(ZarrReader.java:394)
	at loci.formats.ChannelFiller.openBytes(ChannelFiller.java:156)
	at loci.formats.ChannelSeparator.openBytes(ChannelSeparator.java:229)
	at loci.formats.ReaderWrapper.openBytes(ReaderWrapper.java:348)
	at loci.formats.DimensionSwapper.openBytes(DimensionSwapper.java:249)
	at loci.formats.ReaderWrapper.openBytes(ReaderWrapper.java:348)
	at loci.formats.MinMaxCalculator.openBytes(MinMaxCalculator.java:269)
	at loci.formats.MinMaxCalculator.openBytes(MinMaxCalculator.java:260)
	at loci.formats.ReaderWrapper.openBytes(ReaderWrapper.java:334)
	at loci.formats.ReaderWrapper.openBytes(ReaderWrapper.java:334)
	at loci.plugins.util.ImageProcessorReader.openProcessors(ImageProcessorReader.java:186)
	at loci.plugins.in.ImagePlusReader.readProcessors(ImagePlusReader.java:422)
	at loci.plugins.in.ImagePlusReader.readPlanes(ImagePlusReader.java:387)
	at loci.plugins.in.ImagePlusReader.readImage(ImagePlusReader.java:282)
	at loci.plugins.in.ImagePlusReader.readImages(ImagePlusReader.java:243)
	at loci.plugins.in.ImagePlusReader.readImages(ImagePlusReader.java:221)
	at loci.plugins.in.ImagePlusReader.openImagePlus(ImagePlusReader.java:116)
	at loci.plugins.in.Importer.readPixels(Importer.java:149)
	at loci.plugins.in.Importer.run(Importer.java:86)
	at loci.plugins.LociImporter.run(LociImporter.java:78)
	at ij.IJ.runUserPlugIn(IJ.java:235)
	at ij.IJ.runPlugIn(IJ.java:198)
	at ij.Executer.runCommand(Executer.java:150)
	at ij.Executer.run(Executer.java:68)
	at java.lang.Thread.run(Thread.java:748)

[ERROR] java.lang.NoSuchMethodException: Could not find method ucar.ma2.DataType.getType(Ljava/lang/Class;Z)Lucar/ma2/DataType;
There was a problem with the class ucar.ma2.DataType which can be found here:
/Applications/Fiji.app/jars/cdm-4.6.13.jar
/Applications/Fiji.app/jars/netcdf-4.3.22.jar
/Applications/Fiji.app/jars/bio-formats/OMEZarrReader-0.1.0-SNAPSHOT.jar

WARNING: multiple locations found!
java.lang.NoSuchMethodError: ucar.ma2.DataType.getType(Ljava/lang/Class;Z)Lucar/ma2/DataType;
	at com.bc.zarr.ucar.NetCDF_Util.createArrayWithGivenStorage(NetCDF_Util.java:46)
	at com.bc.zarr.ZarrArray.read(ZarrArray.java:326)
	at com.bc.zarr.ZarrArray.read(ZarrArray.java:298)
	at loci.formats.services.JZarrServiceImpl.readBytes(JZarrServiceImpl.java:239)
	at loci.formats.in.ZarrReader.openBytes(ZarrReader.java:394)
	at loci.formats.ChannelFiller.openBytes(ChannelFiller.java:156)
	at loci.formats.ChannelSeparator.openBytes(ChannelSeparator.java:229)
	at loci.formats.ReaderWrapper.openBytes(ReaderWrapper.java:348)
	at loci.formats.DimensionSwapper.openBytes(DimensionSwapper.java:249)
	at loci.formats.ReaderWrapper.openBytes(ReaderWrapper.java:348)
	at loci.formats.MinMaxCalculator.openBytes(MinMaxCalculator.java:269)
	at loci.formats.MinMaxCalculator.openBytes(MinMaxCalculator.java:260)
	at loci.formats.ReaderWrapper.openBytes(ReaderWrapper.java:334)
	at loci.formats.ReaderWrapper.openBytes(ReaderWrapper.java:334)
	at loci.plugins.util.ImageProcessorReader.openProcessors(ImageProcessorReader.java:186)
	at loci.plugins.in.ImagePlusReader.readProcessors(ImagePlusReader.java:422)
	at loci.plugins.in.ImagePlusReader.readPlanes(ImagePlusReader.java:387)
	at loci.plugins.in.ImagePlusReader.readImage(ImagePlusReader.java:282)
	at loci.plugins.in.ImagePlusReader.readImages(ImagePlusReader.java:243)
	at loci.plugins.in.ImagePlusReader.readImages(ImagePlusReader.java:221)
	at loci.plugins.in.ImagePlusReader.openImagePlus(ImagePlusReader.java:116)
	at loci.plugins.in.Importer.readPixels(Importer.java:149)
	at loci.plugins.in.Importer.run(Importer.java:86)
	at loci.plugins.LociImporter.run(LociImporter.java:78)
	at ij.IJ.runUserPlugIn(IJ.java:235)
	at ij.IJ.runPlugIn(IJ.java:198)
	at ij.Executer.runCommand(Executer.java:150)
	at ij.Executer.run(Executer.java:68)
	at java.lang.Thread.run(Thread.java:748)

	at com.bc.zarr.ucar.NetCDF_Util.createArrayWithGivenStorage(NetCDF_Util.java:46)
	at com.bc.zarr.ZarrArray.read(ZarrArray.java:326)
	at com.bc.zarr.ZarrArray.read(ZarrArray.java:298)
	at loci.formats.services.JZarrServiceImpl.readBytes(JZarrServiceImpl.java:239)
	at loci.formats.in.ZarrReader.openBytes(ZarrReader.java:394)
	at loci.formats.ChannelFiller.openBytes(ChannelFiller.java:156)
	at loci.formats.ChannelSeparator.openBytes(ChannelSeparator.java:229)
	at loci.formats.ReaderWrapper.openBytes(ReaderWrapper.java:348)
	at loci.formats.DimensionSwapper.openBytes(DimensionSwapper.java:249)
	at loci.formats.ReaderWrapper.openBytes(ReaderWrapper.java:348)
	at loci.formats.MinMaxCalculator.openBytes(MinMaxCalculator.java:269)
	at loci.formats.MinMaxCalculator.openBytes(MinMaxCalculator.java:260)
	at loci.formats.ReaderWrapper.openBytes(ReaderWrapper.java:334)
	at loci.formats.ReaderWrapper.openBytes(ReaderWrapper.java:334)
	at loci.plugins.util.ImageProcessorReader.openProcessors(ImageProcessorReader.java:186)
	at loci.plugins.in.ImagePlusReader.readProcessors(ImagePlusReader.java:422)
	at loci.plugins.in.ImagePlusReader.readPlanes(ImagePlusReader.java:387)
	at loci.plugins.in.ImagePlusReader.readImage(ImagePlusReader.java:282)
	at loci.plugins.in.ImagePlusReader.readImages(ImagePlusReader.java:243)
	at loci.plugins.in.ImagePlusReader.readImages(ImagePlusReader.java:221)
	at loci.plugins.in.ImagePlusReader.openImagePlus(ImagePlusReader.java:116)
	at loci.plugins.in.Importer.readPixels(Importer.java:149)
	at loci.plugins.in.Importer.run(Importer.java:86)
	at loci.plugins.LociImporter.run(LociImporter.java:78)
	at ij.IJ.runUserPlugIn(IJ.java:235)
	at ij.IJ.runPlugIn(IJ.java:198)
	at ij.Executer.runCommand(Executer.java:150)
	at ij.Executer.run(Executer.java:68)
	at java.lang.Thread.run(Thread.java:748)

This error I get after I have already removed the OMERO plugin and the simple Macro plugin. Previously, the report about the conflicting files had five lines (now it has only 3, but the conflict still persists)

@pwalczysko
Copy link
Member

pwalczysko commented Oct 6, 2021

With freshly downloaded Fiji:

  1. Upgrade the downloaded Fiji, as the BF seems outdated and does not recognize the format at open, reporting unknown format albeit the jar is present.
  2. Try the workflow ZarrReader: Update to support 0.4.0 datasets #8 (comment)
  3. The images successfully open, see screenshot - two of those images have discernible features after contrast was adjusted, and make sense. The smaller images are black, not sure why.
    Screenshot 2021-10-06 at 18 02 23

@pwalczysko
Copy link
Member

In summary, seems to work, but questions

  1. conflict with the OMERO plugin (and possibly the simple... jar) in Fiji is probably not what we want
  2. not sure what I am getting as per the screenshot in ZarrReader: Update to support 0.4.0 datasets #8 (comment) - is that expected ?

@dominikl
Copy link
Member

dominikl commented Oct 8, 2021

I don't know how to test this. Followed #8 (comment) . You can't select a directory, I guess that's why "Select a file inside the 0 subfolder of your local zarr", i.e. you'd have to go down the whole directory tree 0/0/0/0/... until you can select a file. How is bioformats supposed to open that? And it doesn't work. The same with showinf, can't select directory and if I go down the whole directory tree: UnknownFormatException: Unknown file format: 6001247.zarr/0/0/0/0/0

@joshmoore
Copy link
Member

@pwalczysko : I've merged #9 into this PR which means that we should have a testable jar if we want to try to improve/capture new testing instructions.

@pwalczysko
Copy link
Member

Can try tomorrow. This requires a newly downloaded Fiji, which would take very long from home.

@pwalczysko
Copy link
Member

pwalczysko commented Nov 10, 2021

Whilst retesting with the github actions workflow, encountered probs:

  1. Had to remove cdm-4.6.13.jar from the jars folder, otherwise the reader reported error
  2. Opened 6001247.zarr. The label images (4 of them) seem to have zeros all over - no other values can be detected by simple mousing over
    Screenshot 2021-11-10 at 11 55 17

@pwalczysko
Copy link
Member

pwalczysko commented Nov 10, 2021

@joshmoore see updated workflow

  1. Being in the https://github.com/ome/ZarrReader repo, find on the top the Actions tab

  2. Click on it

  3. Click on the most recent workfkow (first row)

  4. Scroll down to find the Artifacts section

  5. Click on the ZarrReader next to the box icon to download the artifacts locally Screenshot 2021-11-10 at 12 04 00

  6. unzip the downloaded artifacts and find inside the file OMEZarrReader-0.1.0-SNAPSHOT.jar

  7. copy this file and paste it into the jars > bio-formats subfolder of your Fiji

  8. restart your Fii and click Plugins > Bio-formats > Bio-formats importer
    9 Select a file inside the 0 subfolder of your local zarr

  9. click off the B-F window

  10. in the Series chooser, choose all series

  11. click OK

Copy link
Member

@pwalczysko pwalczysko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address #8 (comment)

joshmoore added a commit to joshmoore/ZarrReader that referenced this pull request Nov 26, 2021
By adding the testSourceDirectory, the `mvn test`
target can be used in intellij to run tests. This
detected an NPE on `axes` that I've fixed here
though it would be more appropriate for omegh-8.
joshmoore added a commit to joshmoore/ZarrReader that referenced this pull request Nov 26, 2021
By adding the testSourceDirectory, the `mvn test`
target can be used in intellij to run tests. This
detected an NPE on `axes` that I've fixed here
though it would be more appropriate for omegh-8.
@joshmoore joshmoore mentioned this pull request Nov 26, 2021
@joshmoore
Copy link
Member

@pwalczysko : do you remember where you got your 6001247 from?

@pwalczysko
Copy link
Member

@pwalczysko : do you remember where you got your 6001247 from?

From local, certainly downloaded as a part of other testing, see below.

(base) pwalczysko@ls31618~/Work/ome-zarr-py$ pwd
/Users/pwalczysko/Work/ome-zarr-py
(base) pwalczysko@ls31618~/Work/ome-zarr-py$ ls -lah | grep 6001247
drwxr-xr-x   9 pwalczysko  DUNDEE\Domain Users   288B Oct  6 12:17 6001247.zarr

@joshmoore
Copy link
Member

Downloaded from where? Which NGFF version 0.2? Is there a "dimension_separator" flag in the .zarray files?

I created a new one using the latest omero-cli-zarr and the file loads in napari correctly. The current ZarrReader test passes with these changes:

***************
*** 163,167 ****
      }
      assertEquals(3, reader.getResolutionCount());
!     assertEquals(1, reader.getSeriesCount());
      try {
        reader.close();
--- 55,59 ----
      }
      assertEquals(3, reader.getResolutionCount());
!     assertEquals(2, reader.getSeriesCount());
      try {
        reader.close();
***************
*** 172,176 ****
      }
      assertEquals(1, reader.getResolutionCount());
!     assertEquals(3, reader.getSeriesCount());
    }
    
--- 64,68 ----
      }
      assertEquals(1, reader.getResolutionCount());
!     assertEquals(7, reader.getSeriesCount());
    }
    

and found non-zero values in all images:

   for (int s=0; s<2; s++) {
      for (int r=0; r<3; r++) {

        reader.setSeries(s);
        reader.setResolution(r);
        byte[] plane = new byte[FormatTools.getPlaneSize(reader)];

        int nonZero = 0;
        int zero = 0;
        for (int i=0; i<reader.getImageCount(); i++) {

@pwalczysko
Copy link
Member

pwalczysko commented Dec 7, 2021

I think the version is to be gleaned from my git log in my local clone of the ome-zarr-py repo, where the zarr folder sits locally. The commit e658922459e8af2ac4e5d68a186302df42 says Bump version: 0.2.0 → 0.2.1.dev0. As I did not fetch in between, I would assume this is my zarr version.
Please advise on how to ascertain a version of my zarr more authoritatively.
Yes, there are
"dimension_separator": "/",
lines in the zarray files.
Btw, also in my hands and with the file I mentioned, it opens fine in napari (including the labels). Thus, I am not expecting the zarr version to be a problem here. Rather, I can see a discrepancy between the reader in this PR and napari when unleashed on the same file.

@joshmoore
Copy link
Member

Could you attach here the output of:

zip metadata.zip $(find . -name ".z*")

Also, which version of napari and the napari-ome-zarr plugin?

@pwalczysko
Copy link
Member

pwalczysko commented Dec 7, 2021

base) pwalczysko@ls31618~/Work/ome-zarr-py$ ls
6001240.zarr		coinsdata		setup.py
6001247.zarr		environment.yml		test-zarr-cr.py
CHANGELOG.md		image_dir		test_ngff_image
LICENSE			ome_zarr		tests
MANIFEST.in		ome_zarr.egg-info	tox.ini
README.rst		pytest.ini
codecov.yml		requirements
(base) pwalczysko@ls31618~/Work/ome-zarr-py$ zip metadata.zip $(find . -name ".z*")
  adding: tests/data/v1/.zattrs (deflated 57%)
  adding: tests/data/v1/.zgroup (stored 0%)
  adding: tests/data/v1/0/.zarray (deflated 55%)
  adding: tests/data/v2/.zattrs (deflated 57%)
  adding: tests/data/v2/.zgroup (stored 0%)
  adding: tests/data/v2/0/.zarray (deflated 55%)
  adding: coinsdata/.zattrs (deflated 73%)
  adding: coinsdata/.zgroup (stored 0%)
  adding: coinsdata/labels/.zattrs (deflated 22%)
  adding: coinsdata/labels/.zgroup (stored 0%)
  adding: coinsdata/labels/coins/.zattrs (deflated 87%)
  adding: coinsdata/labels/coins/.zgroup (stored 0%)
  adding: coinsdata/labels/coins/0/.zarray (deflated 47%)
  adding: coinsdata/labels/coins/1/.zarray (deflated 47%)
  adding: coinsdata/labels/coins/3/.zarray (deflated 50%)
  adding: coinsdata/labels/coins/2/.zarray (deflated 48%)
  adding: coinsdata/0/.zarray (deflated 48%)
  adding: coinsdata/1/.zarray (deflated 48%)
  adding: coinsdata/3/.zarray (deflated 50%)
  adding: coinsdata/2/.zarray (deflated 48%)
  adding: 6001247.zarr/.zattrs (deflated 77%)
  adding: 6001247.zarr/.zgroup (stored 0%)
  adding: 6001247.zarr/labels/.zattrs (deflated 24%)
  adding: 6001247.zarr/labels/.zgroup (stored 0%)
  adding: 6001247.zarr/labels/0/.zattrs (deflated 95%)
  adding: 6001247.zarr/labels/0/.zgroup (stored 0%)
  adding: 6001247.zarr/labels/0/0/.zarray (deflated 52%)
  adding: 6001247.zarr/labels/0/1/.zarray (deflated 51%)
  adding: 6001247.zarr/labels/0/3/.zarray (deflated 52%)
  adding: 6001247.zarr/labels/0/2/.zarray (deflated 51%)
  adding: 6001247.zarr/0/.zarray (deflated 53%)
  adding: 6001247.zarr/1/.zarray (deflated 53%)
  adding: 6001247.zarr/2/.zarray (deflated 52%)
  adding: 6001240.zarr/.zattrs (deflated 56%)
  adding: 6001240.zarr/.zgroup (stored 0%)
  adding: 6001240.zarr/labels/.zattrs (stored 0%)
  adding: 6001240.zarr/labels/.zgroup (stored 0%)
  adding: 6001240.zarr/labels/masks/.zattrs (deflated 89%)
  adding: 6001240.zarr/labels/masks/.zgroup (stored 0%)
  adding: 6001240.zarr/labels/masks/0/.zarray (deflated 54%)
  adding: 6001240.zarr/labels/masks/1/.zarray (deflated 53%)
  adding: 6001240.zarr/labels/masks/3/.zarray (deflated 54%)
  adding: 6001240.zarr/labels/masks/2/.zarray (deflated 53%)
  adding: 6001240.zarr/0/.zarray (deflated 55%)
  adding: 6001240.zarr/1/.zarray (deflated 55%)
  adding: 6001240.zarr/2/.zarray (deflated 55%)
  adding: image_dir/6001240.zarr/.zattrs (deflated 56%)
  adding: image_dir/6001240.zarr/.zgroup (stored 0%)
  adding: image_dir/6001240.zarr/labels/.zattrs (stored 0%)
  adding: image_dir/6001240.zarr/labels/.zgroup (stored 0%)
  adding: image_dir/6001240.zarr/labels/masks/.zattrs (deflated 89%)
  adding: image_dir/6001240.zarr/labels/masks/.zgroup (stored 0%)
  adding: image_dir/6001240.zarr/labels/masks/0/.zarray (deflated 54%)
  adding: image_dir/6001240.zarr/labels/masks/1/.zarray (deflated 53%)
  adding: image_dir/6001240.zarr/labels/masks/3/.zarray (deflated 54%)
  adding: image_dir/6001240.zarr/labels/masks/2/.zarray (deflated 53%)
  adding: image_dir/6001240.zarr/0/.zarray (deflated 55%)
  adding: image_dir/6001240.zarr/1/.zarray (deflated 55%)
  adding: image_dir/6001240.zarr/2/.zarray (deflated 55%)
  adding: test_ngff_image/.zattrs (deflated 76%)
  adding: test_ngff_image/.zgroup (stored 0%)
  adding: test_ngff_image/labels/.zattrs (deflated 22%)
  adding: test_ngff_image/labels/.zgroup (stored 0%)
  adding: test_ngff_image/labels/blobs/.zattrs (deflated 80%)
  adding: test_ngff_image/labels/blobs/.zgroup (stored 0%)
  adding: test_ngff_image/labels/blobs/0/.zarray (deflated 53%)
  adding: test_ngff_image/0/.zarray (deflated 51%)
  adding: test_ngff_image/1/.zarray (deflated 51%)
  adding: test_ngff_image/4/.zarray (deflated 51%)
  adding: test_ngff_image/3/.zarray (deflated 51%)
  adding: test_ngff_image/2/.zarray (deflated 51%)

@joshmoore see above as well as my exact testing setup is actually described in the header of ome/omero-cli-zarr#82 (comment)
I think the relevant bit for this discussion from there is

Screenshot 2021-12-07 at 14 51 21

Edit: To answer the question about napari version more explicitly

napari was tested with QT library `>=5.12.3`.
The version installed is 5.9.7. Please report any issues with
this specific QT version at https://github.com/Napari/napari/issues.

@joshmoore
Copy link
Member

With the --depth flag, I could finally try out import to OMERO. It looks like the top-level directory is showing up on usedFiles list:

(omero) ~ $ omero import -f /tmp/v3-6001240.zarr/ --depth=8 2>&1 | head
2022-01-21 11:31:20,672 282        [      main] INFO          ome.formats.importer.ImportConfig - OMERO.blitz Version: 5.5.9-SNAPSHOT
2022-01-21 11:31:20,698 308        [      main] INFO          ome.formats.importer.ImportConfig - Bioformats version: 6.9.0-SNAPSHOT revision: 4d060ec155f1bc4c255e5ae2cea69b88ad240df8 date: 20 January 2022
2022-01-21 11:31:20,753 363        [      main] INFO   formats.importer.cli.CommandLineImporter - Log levels -- Bio-Formats: ERROR OMERO.importer: INFO
2022-01-21 11:31:21,537 1147       [      main] INFO      ome.formats.importer.ImportCandidates - Depth: 8 Metadata Level: MINIMUM
2022-01-21 11:31:23,559 3169       [      main] INFO      ome.formats.importer.ImportCandidates - 1421 file(s) parsed into 1 group(s) with 1 call(s) to setId in 1506ms. (2022ms total) [0 unknowns]
#======================================
# Group: /tmp/v3-6001240.zarr/0/0/135/0/0 SPW: false Reader: loci.formats.in.ZarrReader
/tmp/v3-6001240.zarr/0/0/135/0/0
/tmp/v3-6001240.zarr
/tmp/v3-6001240.zarr/.zattrs

which leads to this exception in OMERO:

(omero) ~ $ omero import /tmp/v3-6001240.zarr/ --depth=8
Using OMERO.java-5.6.3-181-d0a4e7c-ice36-b1075
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
2022-01-21 11:22:06,793 293        [      main] INFO          ome.formats.importer.ImportConfig - OMERO.blitz Version: 5.5.9-SNAPSHOT
2022-01-21 11:22:06,817 317        [      main] INFO          ome.formats.importer.ImportConfig - Bioformats version: 6.9.0-SNAPSHOT revision: 4d060ec155f1bc4c255e5ae2cea69b88ad240df8 date: 20 January 2022
2022-01-21 11:22:06,872 372        [      main] INFO   formats.importer.cli.CommandLineImporter - Log levels -- Bio-Formats: ERROR OMERO.importer: INFO
2022-01-21 11:22:07,552 1052       [      main] INFO      ome.formats.importer.ImportCandidates - Depth: 8 Metadata Level: MINIMUM
2022-01-21 11:22:09,566 3066       [      main] INFO      ome.formats.importer.ImportCandidates - 1421 file(s) parsed into 1 group(s) with 1 call(s) to setId in 1457ms. (2013ms total) [0 unknowns]
...
2022-01-21 11:22:13,622 7122       [2-thread-1] INFO   ormats.importer.cli.LoggingImportMonitor - FILESET_UPLOAD_PREPARATION
2022-01-21 11:26:36,740 270240     [2-thread-1] INFO   ormats.importer.cli.LoggingImportMonitor - FILESET_UPLOAD_START
2022-01-21 11:26:36,839 270339     [3-thread-1] INFO   ts.importer.transfers.UploadFileTransfer - Transferring /tmp/v3-6001240.zarr/0/0/135/0/0...
2022-01-21 11:26:36,934 270434     [3-thread-1] INFO   ormats.importer.cli.LoggingImportMonitor - FILE_UPLOAD_STARTED: /tmp/v3-6001240.zarr/0/0/135/0/0
2022-01-21 11:26:37,188 270688     [3-thread-1] INFO   ormats.importer.cli.LoggingImportMonitor - FILE_UPLOAD_COMPLETE: /tmp/v3-6001240.zarr/0/0/135/0/0
2022-01-21 11:26:37,281 270781     [3-thread-1] INFO   ts.importer.transfers.UploadFileTransfer - Transferring /tmp/v3-6001240.zarr...
2022-01-21 11:26:37,495 270995     [3-thread-1] ERROR     ome.formats.importer.cli.ErrorHandler - FILE_EXCEPTION: /tmp/v3-6001240.zarr
java.io.FileNotFoundException: /tmp/v3-6001240.zarr (Is a directory)
	at java.io.FileInputStream.open0(Native Method)
	at java.io.FileInputStream.open(FileInputStream.java:195)
	at java.io.FileInputStream.<init>(FileInputStream.java:138)
	at ome.formats.importer.transfers.UploadFileTransfer.transfer(UploadFileTransfer.java:54)
	at ome.formats.importer.ImportLibrary.uploadFile(ImportLibrary.java:531)
	at ome.formats.importer.ImportLibrary$3.call(ImportLibrary.java:634)
	at ome.formats.importer.ImportLibrary$3.call(ImportLibrary.java:631)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	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)
2022-01-21 11:26:37,497 270997     [2-thread-1] ERROR        ome.formats.importer.ImportLibrary - Error on import
java.io.FileNotFoundException: /tmp/v3-6001240.zarr (Is a directory)
	at java.io.FileInputStream.open0(Native Method)
	at java.io.FileInputStream.open(FileInputStream.java:195)
	at java.io.FileInputStream.<init>(FileInputStream.java:138)
	at ome.formats.importer.transfers.UploadFileTransfer.transfer(UploadFileTransfer.java:54)
	at ome.formats.importer.ImportLibrary.uploadFile(ImportLibrary.java:531)
	at ome.formats.importer.ImportLibrary$3.call(ImportLibrary.java:634)
	at ome.formats.importer.ImportLibrary$3.call(ImportLibrary.java:631)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	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)
2022-01-21 11:26:37,498 270998     [2-thread-1] INFO         ome.formats.importer.ImportLibrary - Exiting on error

==> Summary
1 file uploaded, 0 filesets created, 0 images imported, 1 error in 0:04:23.884

@joshmoore
Copy link
Member

I assume this comes from listFiles returning the folder variable it itself, @dgault:

      File folder = new File(zarrRootPath);
      Collection<File> libs = FileUtils.listFiles(folder, null, true);
      for (File file : libs) {
        usedFiles.add(file.getAbsolutePath());
      }

@sbesson
Copy link
Member

sbesson commented Feb 2, 2022

What's the next step here? As discussed on Monday, adding support for the imminent 0.4 specification is high on the priority list. Should we get this merged and open a follow-up PR for adding support and we can carry-out with the OMERO cross-version testing? Or are there some outstanding blockers that should be resolved first?

@joshmoore
Copy link
Member

Happy to get this in if that unblocks other things but import is still failing with a NPE on today's build:

2022-02-03 08:44:09,331 7823       [3-thread-1] INFO   ts.importer.transfers.UploadFileTransfer - Transferring /tmp/fake.zarr...
2022-02-03 08:44:09,545 8037       [3-thread-1] ERROR     ome.formats.importer.cli.ErrorHandler - FILE_EXCEPTION: /tmp/fake.zarr
java.io.FileNotFoundException: /tmp/fake.zarr (Is a directory)
	at java.io.FileInputStream.open0(Native Method)
	at java.io.FileInputStream.open(FileInputStream.java:195)
	at java.io.FileInputStream.<init>(FileInputStream.java:138)
	at ome.formats.importer.transfers.UploadFileTransfer.transfer(UploadFileTransfer.java:54)
	at ome.formats.importer.ImportLibrary.uploadFile(ImportLibrary.java:531)
	at ome.formats.importer.ImportLibrary$3.call(ImportLibrary.java:634)
	at ome.formats.importer.ImportLibrary$3.call(ImportLibrary.java:631)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	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)
2022-02-03 08:44:09,547 8039       [2-thread-1] ERROR        ome.formats.importer.ImportLibrary - Error on import
java.io.FileNotFoundException: /tmp/fake.zarr (Is a directory)
	at java.io.FileInputStream.open0(Native Method)
	at java.io.FileInputStream.open(FileInputStream.java:195)
	at java.io.FileInputStream.<init>(FileInputStream.java:138)
	at ome.formats.importer.transfers.UploadFileTransfer.transfer(UploadFileTransfer.java:54)
	at ome.formats.importer.ImportLibrary.uploadFile(ImportLibrary.java:531)
	at ome.formats.importer.ImportLibrary$3.call(ImportLibrary.java:634)
	at ome.formats.importer.ImportLibrary$3.call(ImportLibrary.java:631)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	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)
2022-02-03 08:44:09,547 8039       [2-thread-1] INFO         ome.formats.importer.ImportLibrary - Exiting on error

and

(omero) ~ $omero import --depth=10 -f /tmp/fake.zarr/
Using OMERO.java-5.6.3-196-438a45f-ice36-b1093
2022-02-03 08:44:43,414 176        [      main] INFO          ome.formats.importer.ImportConfig - OMERO.blitz Version: 5.5.9-SNAPSHOT
2022-02-03 08:44:43,430 192        [      main] INFO          ome.formats.importer.ImportConfig - Bioformats version: 6.9.0-SNAPSHOT revision: f3b7e47322324534a78c8cc74a914bdb6259d6b7 date: 3 February 2022
2022-02-03 08:44:43,465 227        [      main] INFO   formats.importer.cli.CommandLineImporter - Log levels -- Bio-Formats: ERROR OMERO.importer: INFO
2022-02-03 08:44:43,865 627        [      main] INFO      ome.formats.importer.ImportCandidates - Depth: 10 Metadata Level: MINIMUM
2022-02-03 08:44:44,247 1009       [      main] INFO      ome.formats.importer.ImportCandidates - 6 file(s) parsed into 1 group(s) with 1 call(s) to setId in 379ms. (382ms total) [0 unknowns]
#======================================
# Group: /tmp/fake.zarr/0/0/0/0 SPW: false Reader: loci.formats.in.ZarrReader
/tmp/fake.zarr/0/0/0/0
/tmp/fake.zarr
/tmp/fake.zarr/.zattrs
/tmp/fake.zarr/.zgroup
/tmp/fake.zarr/0/.zattrs
/tmp/fake.zarr/0/.zgroup
/tmp/fake.zarr/0/0/.zarray

A few other things I noticed for anyone else who wants to test:

  • don't forget --depth=
  • v0.2 datasets fail with a NPE on the "axes" field
  • .zarr is required in the path (e.g. with the fake

@dgault dgault changed the title ZarrReader: Update to support 0.3.0 datasets ZarrReader: Update to support 0.4.0 datasets Feb 10, 2022
@dgault
Copy link
Member Author

dgault commented Feb 10, 2022

Updated with parsing metadata for the new axes and coordinateTransformations. The axes parsing should also be backwards compatible with v0.3

Ive also removed the top level zarr folder from usedFiles to address FileNotFoundException: /tmp/fake.zarr (Is a directory). The NPE with axes for v0.2 files should also be resolved.

@sbesson sbesson self-requested a review February 11, 2022 21:05
@joshmoore
Copy link
Member

So (fun never ceases) without the top-level directory in the setId, the upload in OMERO drops the .zarr name:

m[jamoore@idr2-slot3 merge-ci]$ docker-compose exec omero bash
bash-4.2$ cd  /home/omero/omero-server-data/ManagedRepository/root_0/Blitz-0-Ice.ThreadPool.Server-495/2022-02/22/18-06-17.818/
bash-4.2$ ls -ltra
total 4
drwxr-xr-x 3 omero omero 4096 Feb 22 18:06 ..
-rw-r--r-- 1 omero omero   34 Feb 22 18:06 .zattrs
drwxr-xr-x 3 omero omero 4096 Feb 22 18:06 .
-rw-r--r-- 1 omero omero   24 Feb 22 18:06 .zgroup
drwxr-xr-x 3 omero omero 4096 Feb 22 18:06 0

which leads to:

java.lang.RuntimeException: Failure response on import!
Category: ::omero::grid::ImportRequest
Name: error-on-init
Parameters: {stacktrace=loci.formats.UnknownFormatException: Unknown file format: /home/omero/omero-server-data/ManagedRepository/root_0/Blitz-0-Ice.ThreadPool.Server-495/2022-02/22/18-06-17.818/0/0/0/0
	at loci.formats.ImageReader.getReader(ImageReader.java:202)
	at loci.formats.ImageReader.setId(ImageReader.java:844)
	at ome.formats.importer.OMEROWrapper$4.setId(OMEROWrapper.java:167)
	at loci.formats.ReaderWrapper.setId(ReaderWrapper.java:650)
	at loci.formats.ChannelFiller.setId(ChannelFiller.java:234)
	at loci.formats.ReaderWrapper.setId(ReaderWrapper.java:650)
	at loci.formats.ChannelSeparator.setId(ChannelSeparator.java:293)
	at loci.formats.ReaderWrapper.setId(ReaderWrapper.java:650)
	at loci.formats.Memoizer.setId(Memoizer.java:690)
	at loci.formats.ReaderWrapper.setId(ReaderWrapper.java:650)
	at ome.services.blitz.repo.CheckedPath.bfSetId(CheckedPath.java:412)
	at ome.services.blitz.repo.ManagedImportRequestI.open(ManagedImportRequestI.java:763)
	at ome.services.blitz.repo.ManagedImportRequestI.init(ManagedImportRequestI.java:245)

I think Bio-Formats is doing what it can to have the paths all correct:

(omero) ~/opt/ome_zarr_test_suite/data $omero import -f --depth=8 64x64-fake-v0.1.ome.zarr
Using OMERO.java-5.6.3-192-d4217f9-ice36-b1114
2022-02-22 12:08:10,323 173        [      main] INFO          ome.formats.importer.ImportConfig - OMERO.blitz Version: 5.5.9-SNAPSHOT
2022-02-22 12:08:10,338 188        [      main] INFO          ome.formats.importer.ImportConfig - Bioformats version: 6.9.0-SNAPSHOT revision: b9d087d3d89c47c5c4029058c4175eeeee689c89 date: 22 February 2022
2022-02-22 12:08:10,370 220        [      main] INFO   formats.importer.cli.CommandLineImporter - Log levels -- Bio-Formats: ERROR OMERO.importer: INFO
2022-02-22 12:08:10,851 701        [      main] INFO      ome.formats.importer.ImportCandidates - Depth: 8 Metadata Level: MINIMUM
2022-02-22 12:08:11,225 1075       [      main] INFO      ome.formats.importer.ImportCandidates - 8 file(s) parsed into 1 group(s) with 1 call(s) to setId in 370ms. (374ms total) [0 unknowns]
#======================================
# Group: /Users/jamoore/opt/ome_zarr_test_suite/data/64x64-fake-v0.1.ome.zarr/0/0/0.0.0.0.0 SPW: false Reader: loci.formats.in.ZarrReader
/Users/jamoore/opt/ome_zarr_test_suite/data/64x64-fake-v0.1.ome.zarr/0/0/0.0.0.0.0
/Users/jamoore/opt/ome_zarr_test_suite/data/64x64-fake-v0.1.ome.zarr/.zattrs
/Users/jamoore/opt/ome_zarr_test_suite/data/64x64-fake-v0.1.ome.zarr/.zgroup
/Users/jamoore/opt/ome_zarr_test_suite/data/64x64-fake-v0.1.ome.zarr/0/.zattrs
/Users/jamoore/opt/ome_zarr_test_suite/data/64x64-fake-v0.1.ome.zarr/0/.zgroup
/Users/jamoore/opt/ome_zarr_test_suite/data/64x64-fake-v0.1.ome.zarr/0/0/.zarray
/Users/jamoore/opt/ome_zarr_test_suite/data/64x64-fake-v0.1.ome.zarr/OME/METADATA.ome.xml
/Users/jamoore/opt/ome_zarr_test_suite/data/64x64-fake-v0.1.ome.zarr/.bioformats
(omero) ~/opt/ome_zarr_test_suite/data $omero import -f --depth=8 64x64-fake-v0.1.ome.zarr/0/0/0.0.0.0.0

but OMERO's logic is to remove all paths which are redundant. Options I can think of include:

  • add back in the directory but fix OMERO to accept that
  • add in special logic to OMERO to not strip off .zarr paths
  • add in some form of dummy file one level up to bypass OMERO's logic (e.g. 64x64-fake-v0.1.ome.zarr.ini)

@joshmoore
Copy link
Member

@melissalinkert reminded me of another option getRequiredDirectories. Pushed and rebuilding.

@sbesson
Copy link
Member

sbesson commented Mar 1, 2022

I tested this reader against different datasets:

  • successfully imported the minimal OME-NGFF examples from ome_zarr_test_suite - same remark as Add v0.4 sample data ome_zarr_test_suite#34 (comment) i.e. there is a current dependency on a .zarr suffix for the folder which we might want to review lift
  • The images import but return black planes - I will test using a separate client but I am unsure this is expected

Screenshot 2022-03-01 at 16 07 04

  • the import of a sample plate generated from omero-cli-zarr using omero import --transfer=ln_s --skip=checksum --parallel-upload 8 --depth 8 failed with a parsing exception
  • importing the OME-NGFF samples generated using https://github.com/ome/ome-ngff-prototypes results either in ArrayIndexOutOfBoundsException when calling openBytes for some datasets or in black planes like above e.g. zyx.ome.zarr post-import

What is the easiest way to collect these and prioritize the fixes? Happy to see this merged and start collecting the failures as separate issues to review. Or have a more verbose digest of the samples and the exceptions on this PR.

In the meantime, I will start working on combining a collection of reference OME-NGFF 0.4 samples.

@dgault
Copy link
Member Author

dgault commented Mar 4, 2022

Tested locally and with FIJI/QuPath for all the datasets in inbox/ome-ngff and https://github.com/ome/ome-ngff-prototypes
The only dataset that was showing issues was the idr dataset and the first of the 2 recent commits should fix that.

The issue with blank planes seems to be limited to OMERO and Im still not entirely sure of the cause. My assumption is that it is likely related to the paths being stored, so the second commit aims to ensure only the zarr paths are being stored.

@sbesson sbesson removed the request for review from dominikl March 4, 2022 17:59
@sbesson
Copy link
Member

sbesson commented Mar 8, 2022

Retested a full OMERO import workflow and loading of sample data like the ones of https://www.openmicroscopy.org/2021/12/16/ome-ngff.html still fails post metadata import with the following exception of openBytes

Created session for user-7@localhost:4064. Idle timeout: 10 min. Current group: private-1
2022-03-08 17:06:52,486 545        [      main] INFO          ome.formats.importer.ImportConfig - OMERO.blitz Version: 5.5.9-SNAPSHOT
2022-03-08 17:06:52,535 594        [      main] INFO          ome.formats.importer.ImportConfig - Bioformats version: 6.9.1-SNAPSHOT revision: 9ef39501032d840124ff07832eec44ac7c910acf date: 8 March 2022
2022-03-08 17:06:52,668 727        [      main] INFO   formats.importer.cli.CommandLineImporter - Setting checksum algorithm to File-Size-64
2022-03-08 17:06:52,671 730        [      main] INFO   formats.importer.cli.CommandLineImporter - Setting transfer to ln_s
2022-03-08 17:06:52,676 735        [      main] INFO   formats.importer.cli.CommandLineImporter - Setting parallel upload: 8
2022-03-08 17:06:52,677 736        [      main] INFO   formats.importer.cli.CommandLineImporter - Log levels -- Bio-Formats: ERROR OMERO.importer: INFO
2022-03-08 17:06:53,373 1432       [      main] INFO      ome.formats.importer.ImportCandidates - Depth: 8 Metadata Level: MINIMUM
2022-03-08 17:06:56,020 4079       [      main] INFO      ome.formats.importer.ImportCandidates - 370 file(s) parsed into 1 group(s) with 1 call(s) to setId in 1316ms. (2647ms total) [0 unknowns]
2022-03-08 17:06:56,170 4229       [      main] INFO       ome.formats.OMEROMetadataStoreClient - Attempting initial SSL connection to localhost:4064
2022-03-08 17:06:56,947 5006       [      main] INFO       ome.formats.OMEROMetadataStoreClient - Insecure connection requested, falling back
2022-03-08 17:06:57,356 5415       [      main] INFO       ome.formats.OMEROMetadataStoreClient - Pinging session every 300s.
2022-03-08 17:06:57,367 5426       [      main] INFO       ome.formats.OMEROMetadataStoreClient - Server: 5.6.3
2022-03-08 17:06:57,367 5426       [      main] INFO       ome.formats.OMEROMetadataStoreClient - Client: 5.5.9-SNAPSHOT
2022-03-08 17:06:57,368 5427       [      main] INFO       ome.formats.OMEROMetadataStoreClient - Java Version: 1.8.0_212
2022-03-08 17:06:57,368 5427       [      main] INFO       ome.formats.OMEROMetadataStoreClient - OS Name: Linux
2022-03-08 17:06:57,368 5427       [      main] INFO       ome.formats.OMEROMetadataStoreClient - OS Arch: amd64
2022-03-08 17:06:57,368 5427       [      main] INFO       ome.formats.OMEROMetadataStoreClient - OS Version: 3.10.0-1160.15.2.el7.x86_64
2022-03-08 17:06:57,701 5760       [      main] WARN                    ome.system.UpgradeCheck - UPGRADE AVAILABLE:Please upgrade to 5.6.1. See http://downloads.openmicroscopy.org/latest/omero for the latest version.
2022-03-08 17:06:57,715 5774       [2-thread-1] INFO   ormats.importer.cli.LoggingImportMonitor - FILESET_UPLOAD_PREPARATION
2022-03-08 17:07:36,579 44638      [2-thread-1] INFO   ormats.importer.cli.LoggingImportMonitor - FILESET_UPLOAD_START
...
2022-03-08 17:07:45,469 53528      [2-thread-1] INFO   ormats.importer.cli.LoggingImportMonitor - FILESET_UPLOAD_END
2022-03-08 17:07:45,626 53685      [2-thread-1] INFO   ormats.importer.cli.LoggingImportMonitor - IMPORT_STARTED Logfile: 952787
2022-03-08 17:07:47,231 55290      [l.Client-1] INFO   ormats.importer.cli.LoggingImportMonitor - METADATA_IMPORTED Step: 1 of 5  Logfile: 952787
2022-03-08 17:07:47,390 55449      [l.Client-3] ERROR     ome.formats.importer.cli.ErrorHandler - INTERNAL_EXCEPTION: /uod/idr/repos/curated/unsupported/ome-ngff/0.3/idr/idr0075A/9528933.zarr/3/69/0/0
java.lang.RuntimeException: Failure response on import!
Category: ::omero::grid::ImportRequest
Name: import-request-failure
Parameters: {stacktrace=java.lang.ArrayIndexOutOfBoundsException: 512
	at loci.formats.in.ZarrReader.openBytes(ZarrReader.java:422)
	at loci.formats.ImageReader.openBytes(ImageReader.java:465)
	at loci.formats.ChannelFiller.openBytes(ChannelFiller.java:167)
	at loci.formats.ChannelSeparator.openBytes(ChannelSeparator.java:229)
	at loci.formats.ReaderWrapper.openBytes(ReaderWrapper.java:348)
	at loci.formats.ReaderWrapper.openBytes(ReaderWrapper.java:348)
	at loci.formats.MinMaxCalculator.openBytes(MinMaxCalculator.java:269)
	at ome.services.blitz.repo.ManagedImportRequestI.parseDataByPlane(ManagedImportRequestI.java:872)
...

I separately worked on testing the same datasets locally using the new reader. On my M1 system, I had to work around an issue with the JNA library support for ARM64 following the instructions of Philippus/sbt-dotenv#91 (comment) and setting JAVA_OPTS.

Running a simple command-line showinf command with:

BF_CP=/Users/sbesson/Downloads/bftools/OMEZarrReader-0.1.1-SNAPSHOT-jar-with-dependencies.jar ./showinf ~/Desktop/idr0075A/9528933.zarr/.zattrs -autoscale

was sufficient to open the image and display the planes without issue. Tested various combinations of arguments to reproduce the OMERO stack (-minmax, -separate) but I could not reproduce the openBytes issue.

A potential mismatch can be identified by passing the -noflat option:

(java_dev) sbesson@Sebastiens-MacBook-Pro bftools % BF_CP=/Users/sbesson/Downloads/bftools/OMEZarrReader-0.1.1-SNAPSHOT-jar-with-dependencies.jar ./showinf ~/Desktop/idr0075A/9528933.zarr/.zattrs -autoscale -noflat 
...
Series count = 1
Series #0 :
	Resolutions = 4
		sizeX[0] = 512
		sizeX[1] = 512
		sizeX[2] = 512
		sizeX[3] = 512
	Image count = 91

while in flattened resolution mode, the series are been downsampled down to 64. So there might be some issue with the sub-resolution logic?

@dgault
Copy link
Member Author

dgault commented Mar 9, 2022

Yeah, looks like the sub-resolution logic got broke somewhere along the line. Fixes in the latest commit should resolve those issues

@sbesson
Copy link
Member

sbesson commented Mar 10, 2022

Thanks, with the last commit, running

BF_CP=/Users/sbesson/Downloads/bftools/OMEZarrReader-0.1.1-SNAPSHOT-jar-with-dependencies.jar ./showinf ~/Desktop/idr0075A/9528933.zarr/.zattrs -autoscale -noflat -resolution 3

returns the smallest resolution as expected and the metadata looks good.

Importing the image into OMERO still the same ArrayIndexOutOfBoundsException exception but looking at the import logs, I think I narrowed down where the problem lies:

2022-03-10 11:48:10,736 DEBUG [    o.s.blitz.repo.ManagedImportRequestI] (2-thread-3) Plane:0 X:0 Y:0 TileWidth:1 TileHeight:512 arrayBuf.length:1024
2022-03-10 11:48:10,795 DEBUG [    o.s.blitz.repo.ManagedImportRequestI] (2-thread-3) Plane:0 X:1 Y:0 TileWidth:1 TileHeight:512 arrayBuf.length:1024
2022-03-10 11:48:10,805 INFO  [ o.s.b.r.ManagedImportRequestI.@204b5506] (2-thread-3) Cancelled

So the issue is related to tiled reading. I can reproduce the issue in command-line

BF_CP=/Users/sbesson/Downloads/bftools/OMEZarrReader-0.1.1-SNAPSHOT-jar-with-dependencies.jar ./showinf ~/Desktop/idr0075A/9528933.zarr/.zattrs -autoscale -noflat -resolution 0 -crop 0,0,1,512

works but

BF_CP=/Users/sbesson/Downloads/bftools/OMEZarrReader-0.1.1-SNAPSHOT-jar-with-dependencies.jar ./showinf ~/Desktop/idr0075A/9528933.zarr/.zattrs -autoscale -noflat -resolution 0 -crop 1,0,1,512

throws an OutOfBoundsException.

A possibly related issue is that Bio-Formats detects 1 x 512 as the optimal tile size. This should likely be fixed to reflect the internal chunk size (in that case 512 x512).

@sbesson
Copy link
Member

sbesson commented Mar 14, 2022

Retested the last commit by importing several OME-NGFF samples into test servers with this JAR included

  • the majority of the imports completed without issues. Datasets using versions 0.2 to 0.4 were tested
  • the pixel data access seems to be fixed by be19208

Screenshot 2022-03-14 at 12 50 24

Overall, I think we have a working proof of concept and I would suggest we get this merged and tagged.

The testing also flagged several usability/performance/support issues which I would propose to capture as separate issues so that they can be addressed individually:

  • command line tools & M1 (minor): see ZarrReader: Update to support 0.4.0 datasets #8 (comment) the JNA dependency should be reviewed
  • command line tools & cdm dependency: I had to patch bf.sh to load OMEZarrReader before bioformats_package to ensure the right unidata dependency would be picked up resulting in a ClassNotFoundException exception otherwise. This probable points towards Upgrade cdm 4 to cdm-core 5 bioformats#3788 being a requirement to unify the dependency tree
  • import & depth: as highlighted in ZarrReader: Update to support 0.4.0 datasets #8 (comment), the --depth needs to be set manually to a higher value than the default one to complete certain imports
  • import & minmax: several filesets were hanging in the pixel data process
  • import & naming: by default all the images are named 0 - this brings us back to the issue of Import Plate/Image name metadata design#57 and the fact that the importer side-steps the name metadata
  • spec support: several example datasets are incorrectly imported as separate series with the pixel type of the series > 1 being incorrectly set

@sbesson sbesson merged commit eff85d6 into ome:main Mar 14, 2022
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

Successfully merging this pull request may close these issues.

6 participants