Reads a multiplex image into R without Java, auto-detecting the container:
QPTIFF from Akoya PhenoCycler-Fusion (formerly CODEX), Cell DIVE, or Vectra / Polaris scanners - brightfield RGB, Polaris ScanBand XML, and Fusion per-page JSON+XML variants.
OME-TIFF (as written by tifffile, Bio-Formats, or QuPath) - channel names are read from the
<Channel Name="...">attributes of the OME-XML.OME-Zarr (OME-NGFF) stores - requires the Rarr package; channel names / colours are read from
omero.channels.
Arguments
- path
Character, path to the image. A QPTIFF / OME-TIFF file, or an OME-Zarr store (a directory, or a path ending in
.zarr).- channels
Character vector of channel names to load, an integer vector of 1-based channel indices, or
NULL(default) to load all channels.- level
Integer, pyramid resolution level.
1= full resolution (default),2= half resolution, etc. OME-TIFF sub-resolution pyramids (SubIFDs) are not supported; uselevel = 1.- as_integer
Logical; return raw 16-bit integers (0-65535) rather than normalised
[0, 1]doubles? DefaultTRUE.- lazy
Logical; if
TRUEreturn aDelayedArraybacked by aQPTIFFArraySeedthat reads pages from disk on demand. IfFALSE(default) load all requested channels into memory and return aQPTIFFImage.
Value
lazy = FALSEA
QPTIFFImage- a 3-D numeric array[height, width, channels]with classc("QPTIFFImage", "array"). Channel names are stored indimnames(img)[[3]]. Standard array subscripting works:img[, , "DAPI"]extracts a single channel as a matrix;img[1:512, 1:512, ]crops spatially. Rich metadata is inattr(img, "metadata").lazy = TRUEA
DelayedArraywithdim = c(H, W, C). Individual channel pages are read from disk only when accessed. The seed is aQPTIFFArraySeedaccessible viaDelayedArray::seed(arr).
Details
Channel names and rich per-channel metadata (fluorophore, exposure time,
wavelengths, filters, colour) are parsed into an OME-organised
QPTIFFMetadata object, available via metadata.
The native, Java-free TIFF/QPTIFF reader and writer implemented here was translated from the bioio-tifffile fork by Rafael Tubelleza.
Examples
path <- system.file("extdata", "PA_HNC_sample.ome.tiff", package = "bgnormR")
img <- read_qptiff(path)
#> Reading TIFF directory structure ...
#> Reading OME-TIFF metadata ...
#> Reading IFD page layouts ...
#> Loading 5 channel(s) ...
#> Loading 5 channel(s) ...
dim(img) # c(H, W, n_channels)
#> [1] 550 800 5
names(img) # channel names
#> [1] "CD20" "CD3e" "CD8" "PanCK" "Vimentin"
cd20 <- img[, , "CD20"] # extract one channel as a 2-D matrix
# Load specific channels only
img2 <- read_qptiff(path, channels = c("CD20", "PanCK"))
#> Reading TIFF directory structure ...
#> Reading OME-TIFF metadata ...
#> Reading IFD page layouts ...
#> Loading 2 channel(s) ...
#> Loading 2 channel(s) ...
names(img2)
#> [1] "CD20" "PanCK"
# \donttest{
# Lazy / out-of-core load (backed by DelayedArray)
arr <- read_qptiff(path, lazy = TRUE)
#> Reading TIFF directory structure ...
#> Reading OME-TIFF metadata ...
#> Reading IFD page layouts ...
#> Loading 5 channel(s) ...
# }