RBioFormats icon indicating copy to clipboard operation
RBioFormats copied to clipboard

Reading OME-Zarr (OME-NGFF)

Open lgeistlinger opened this issue 3 years ago • 2 comments

A discussion in the Bioconductor slack channel was wondering whether RBioFormats could already be used to read OME-Zarr format. It seems that with the additional https://github.com/ome/zarrreader jar, RBioFormats would be able to read OME-Zarr (i.e. OME-NGFFs)?

lgeistlinger avatar Nov 21 '22 15:11 lgeistlinger

Hi Ludwig,

many thanks for reaching out! Indeed, it seems that adding zarrreader java library to the classpath used by RBioFormats is sufficient to enable reading of OME-Zarr file format, see below. The example queries only for image metadata because when trying to read pixel data I've run into an issue described in https://github.com/ome/ZarrReader/issues/45.

library(RBioFormats)
library(rJava)
  
zarrfile = "/Users/oles/Downloads/v0.4/yx.ome.zarr/.zattrs"
zarrreader = "/Users/oles/Projects/ZarrReader/target/OMEZarrReader-0.3.1-SNAPSHOT-jar-with-dependencies.jar"
  
.jaddClassPath(zarrreader, class.loader = .jclassLoader(package="RBioFormats"))

read.metadata(zarrfile)
#> ImageMetadata list of length 3 
#> 
#>  series res sizeX sizeY sizeC sizeZ sizeT total
#>  1      1   1024  930   1     1     1     1    
#>  1      2   512   465   1     1     1     1    
#>  1      3   256   232   1     1     1     1    
#> 
#> globalMetadata:List of 4
#>  $ Axis type:0:0: chr "space"
#>  $ Axis name:0:1: chr "x"
#>  $ Axis name:0:0: chr "y"
#>  $ Axis type:0:1: chr "space"

Created on 2023-01-10 with reprex v2.0.2

AFAIU obtaining the ZarrReader jar file currently requires building it from sources. It would certainly ease things up quite a bit if ZarrReader was available already packaged. @sbesson any plans regarding this?

Cheers, Andrzej

aoles avatar Jan 10 '23 15:01 aoles

Hi @aoles! You can see how the jar is pulled into OMERO from Maven here:

https://github.com/ome/openmicroscopy/blob/develop/ivy.xml#L21

joshmoore avatar Jan 11 '23 09:01 joshmoore