| Title: | Minimal R 'OME-Zarr' Reader |
|---|---|
| Description: | A minimal R package to reading, writing and validating multiscale OME-Zarr images. |
| Authors: | Hugo Gruson [aut, cre] (ORCID: <https://orcid.org/0000-0002-4094-1476>), Artür Manukyan [aut] (ORCID: <https://orcid.org/0000-0002-0441-9517>), Helmholtz Association [fnd] (Funded by the Helmholtz ScienceServe Initative to improve interoperability of bioimaging, single-cell and spatial omics data, https://www.helmholtz.de, ROR: <https://ror.org/0281dp749>), German Network for Bioinformatics Infrastructure - de.NBI [fnd] (ROR: <https://ror.org/01vmpm840>) |
| Maintainer: | Hugo Gruson <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.99.1 |
| Built: | 2026-07-03 14:13:03 UTC |
| Source: | https://github.com/Huber-group-EMBL/romeo |
ome-zarr objectSubset operation is applied on all levels of the multiscale ome-zarr
object. The result is an ome-zarr object with the same number of levels,
but each level is subsetted according to the provided indices.
## S3 method for class 'ome_zarr' x[...]## S3 method for class 'ome_zarr' x[...]
x |
An |
... |
Indices to subset the |
The first image is subsetted using the provided indices, and the resulting dimensions are used to subset the remaining levels, while conserving the same scaling factor across levels
A subset of an object of ome_zarr (OME-Zarr) class representing
an image or label pyramid.
omezarrzip <- system.file("extdata", "test_ngff_image_v04.ome.zarr.zip", package = "romeo") dir.create(td <- tempfile()) unzip(omezarrzip, exdir = td) x <- ome_read(td) y <- x[1:5,1:5] plot(y, level = 2)omezarrzip <- system.file("extdata", "test_ngff_image_v04.ome.zarr.zip", package = "romeo") dir.create(td <- tempfile()) unzip(omezarrzip, exdir = td) x <- ome_read(td) y <- x[1:5,1:5] plot(y, level = 2)
ome-zarr objectExtract specific levels from a multiscale ome-zarr object
extract_levels(x, levels)extract_levels(x, levels)
x |
An |
levels |
Integer vector specifying the levels to extract. |
If levels is of length 1, an array
If levels is of length more than 1, an ome-zarr object
An object of ome_zarr (OME-Zarr) class representing an
image or label pyramid.
omezarrzip <- system.file("extdata", "test_ngff_image_v04.ome.zarr.zip", package = "romeo") dir.create(td <- tempfile()) unzip(omezarrzip, exdir = td) x <- ome_read(td) extract_levels(x, c(1, 3)) extract_levels(x, 2)omezarrzip <- system.file("extdata", "test_ngff_image_v04.ome.zarr.zip", package = "romeo") dir.create(td <- tempfile()) unzip(omezarrzip, exdir = td) x <- ome_read(td) extract_levels(x, c(1, 3)) extract_levels(x, 2)
Read a multiscale OME-Zarr file
ome_read(path, s3_client = NULL, lazy = TRUE, validate = TRUE)ome_read(path, s3_client = NULL, lazy = TRUE, validate = TRUE)
path |
Path to the OME-Zarr file. |
s3_client |
Object created by |
lazy |
Logical. If |
validate |
Logical.If |
An object of ome_zarr (OME-Zarr) class representing an
image or label pyramid.
omezarrzip <- system.file("extdata", "test_ngff_image_v04.ome.zarr.zip", package = "romeo") dir.create(td <- tempfile()) unzip(omezarrzip, exdir = td) x <- ome_read(td)omezarrzip <- system.file("extdata", "test_ngff_image_v04.ome.zarr.zip", package = "romeo") dir.create(td <- tempfile()) unzip(omezarrzip, exdir = td) x <- ome_read(td)
Validate a multiscale OME-Zarr file
ome_validate(path, s3_client = NULL)ome_validate(path, s3_client = NULL)
path |
Path to the OME-Zarr file. |
s3_client |
Object created by |
This function is used for its side-effect and will return the type of the OME-Zarr schema (image, label), otherwise will invoke an error when passed an invalid OME-Zarr file
omezarrzip <- system.file("extdata", "test_ngff_image_v04.ome.zarr.zip", package = "romeo") dir.create(td <- tempfile()) unzip(omezarrzip, exdir = td) ome_validate(td)omezarrzip <- system.file("extdata", "test_ngff_image_v04.ome.zarr.zip", package = "romeo") dir.create(td <- tempfile()) unzip(omezarrzip, exdir = td) ome_validate(td)
Writes an ome image to the zarr path according to ome-zarr specification
ome_write( image, path = "/", axes = NULL, scalefactors = c(2, 2, 2, 2), version = c("0.5", "0.4"), storage_options = NULL, type = c("image", "label"), label_name = NULL, label_metadata = NULL ) ## S4 method for signature 'array' ome_write( image, path = "/", axes = NULL, scalefactors = c(2, 2, 2, 2), version = c("0.5", "0.4"), storage_options = NULL, type = c("image", "label"), label_name = NULL, label_metadata = NULL ) ## S4 method for signature 'Image' ome_write( image, path = "/", axes = NULL, scalefactors = c(2, 2, 2, 2), version = c("0.5", "0.4"), storage_options = NULL, type = c("image", "label"), label_name = NULL, label_metadata = NULL )ome_write( image, path = "/", axes = NULL, scalefactors = c(2, 2, 2, 2), version = c("0.5", "0.4"), storage_options = NULL, type = c("image", "label"), label_name = NULL, label_metadata = NULL ) ## S4 method for signature 'array' ome_write( image, path = "/", axes = NULL, scalefactors = c(2, 2, 2, 2), version = c("0.5", "0.4"), storage_options = NULL, type = c("image", "label"), label_name = NULL, label_metadata = NULL ) ## S4 method for signature 'Image' ome_write( image, path = "/", axes = NULL, scalefactors = c(2, 2, 2, 2), version = c("0.5", "0.4"), storage_options = NULL, type = c("image", "label"), label_name = NULL, label_metadata = NULL )
image |
an n-dimensional (or a path to an) array representing the image data (1<n<6) |
path |
the path to writing ome.zarr |
axes |
a character vector specifying the axes of the image (e.g. c("t", "c", "z", "y", "x")) |
scalefactors |
Scale factors to apply to construct a multiscale image. Importantly, each scale factor is relative to the previous scale factor. For example, if the scale factors are c(2, 2, 2), the returned multiscale image will have 4 scales. |
version |
OME-Zarr version (0.4 or 0.5), lower versions are not supported for writing. |
storage_options |
a list of storage options for the zarr array (e.g. chunks) |
type |
The type of OME pyramid written: 'image' (default) or 'label'. |
label_name |
The name of the label data. |
label_metadata |
label metadata added to attributes. |
An object of ome_zarr (OME-Zarr) class representing an
image or label pyramid.
library(EBImage) nuc <- readImage(system.file("images", "nuclei.tif", package="EBImage")) nuc <- getFrames(nuc)[[1]] td <- tempfile(fileext = ".ome.zarr") # write image pyramid ome_nuc <- ome_write(nuc, path = td, version = "0.4", storage_options = list(chunk_dim = c(64,64))) # nuclei segmentation using otsu's method nuc_th = nuc > otsu(nuc) # write label pyramid ome_nuc_th <- ome_write(nuc_th, path = td, version = "0.4", scalefactors = c(2,2,3), storage_options = list(chunk_dim = c(64,64)), label_name = "nuclei_segmentation", type = "label")library(EBImage) nuc <- readImage(system.file("images", "nuclei.tif", package="EBImage")) nuc <- getFrames(nuc)[[1]] td <- tempfile(fileext = ".ome.zarr") # write image pyramid ome_nuc <- ome_write(nuc, path = td, version = "0.4", storage_options = list(chunk_dim = c(64,64))) # nuclei segmentation using otsu's method nuc_th = nuc > otsu(nuc) # write label pyramid ome_nuc_th <- ome_write(nuc_th, path = td, version = "0.4", scalefactors = c(2,2,3), storage_options = list(chunk_dim = c(64,64)), label_name = "nuclei_segmentation", type = "label")
ome_zarr object.Plot an ome_zarr object.
## S3 method for class 'ome_zarr' plot(x, level = 1, ...)## S3 method for class 'ome_zarr' plot(x, level = 1, ...)
x |
An |
level |
Integer. The scale level to plot. Defaults to |
... |
Additional arguments passed to |
None
omezarrzip <- system.file("extdata", "test_ngff_image_v04.ome.zarr.zip", package = "romeo") dir.create(td <- tempfile()) unzip(omezarrzip, exdir = td) x <- ome_read(td) plot(x) plot(x, 2) plot(x, all = TRUE)omezarrzip <- system.file("extdata", "test_ngff_image_v04.ome.zarr.zip", package = "romeo") dir.create(td <- tempfile()) unzip(omezarrzip, exdir = td) x <- ome_read(td) plot(x) plot(x, 2) plot(x, all = TRUE)