Package org.micromanager.mmomezarr
Class OMEZarrStorage
- java.lang.Object
-
- org.micromanager.mmomezarr.OMEZarrStorage
-
- All Implemented Interfaces:
AutoCloseable,MultiresOMEZarrAPI,OMEZarrAPI
public final class OMEZarrStorage extends Object implements MultiresOMEZarrAPI
Disk-backed, streaming OME-Zarr (OME-NGFF v0.5 / Zarr v3) storage with a multiscale pyramid and concurrent read-while-write. Modeled onorg.micromanager.ndtiffstorage.NDTiffStorage: a single writer thread drains a bounded queue (back-pressure), images are readable from an in-memory write-pending buffer the instant they are queued, and pyramid levels can be added at any time.Axis layout is either declared via
OMEZarrStorageConfigor inferred from the first image. The position axis (default"position") maps to separate OME-Zarr image groups (bioformats2raw layout); the remaining axes plus the implicit spatial y/x form each array.
-
-
Constructor Summary
Constructors Constructor Description OMEZarrStorage(String dir, String name, String summaryMetadataJson, OMEZarrStorageConfig config)Create a new dataset for writing.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckForWritingException()Re-throw any exception that occurred on the writer thread.voidclose()Release all resources.voidcloseAndWait()Release all resources and block until done.voidfinishedWriting()Signal that no more images will be written; the dataset becomes read-only.Set<Map<String,Object>>getAxesSet()The set of axis positions for every image in the dataset.StringgetCustomMetadata(String key)Retrieve a custom-metadata blob previously stored underkey, or null.StringgetDiskLocation()Path to the dataset root folder, or null if not on disk.EssentialImageMetadatagetEssentialImageMetadata(Map<String,Object> axes)Essential metadata (width/height/bitDepth/rgb) without loading pixels.EssentialImageMetadatagetEssentialImageMetadata(Map<String,Object> axes, int level)Essential metadata at the given resolution level.OMEZarrImagegetImage(Map<String,Object> axes)Get a single image (resolution level 0).OMEZarrImagegetImage(Map<String,Object> axes, int level)Get a single image at the given resolution level.int[]getImageBounds()[xMin, yMin, xMax, yMax] pixel bounds of acquired data.StringgetImageMetadata(Map<String,Object> axes)Get per-image metadata JSON for the image with the given axes, or null.intgetNumResLevels()Number of resolution levels currently in the pyramid.StringgetSummaryMetadata()The dataset summary metadata as a JSON string (supplied at construction), or null.StringgetUniqueAcqName()A unique name for this dataset instance.intgetWritingQueueTaskMaxSize()Maximum size of the writer queue.intgetWritingQueueTaskSize()Number of images waiting in the writer queue.booleanhasImage(Map<String,Object> axes)Whether an image with the given axes exists.booleanhasImage(Map<String,Object> axes, int level)Whether an image exists at the given resolution level.booleanisFinished()Whether the dataset is finished writing and now read-only.static OMEZarrStorageload(String dir)Open an existing dataset for reading.static OMEZarrStorageload(String dir, OMEZarrStorageConfig config)Open an existing dataset for reading with a custom config (e.g.Future<Void>putImage(Object pixels, String metadataJson, Map<String,Object> axes, boolean rgb, int bitDepth, int imageHeight, int imageWidth)Add an image to storage (resolution level 0).Future<Void>putImage(Object pixels, String metadataJson, Map<String,Object> axes, boolean rgb, int bitDepth, int imageHeight, int imageWidth, int resolutionLevel)Write a caller-supplied image to a specific resolution level, bypassing auto-downsampling.voidsetCustomMetadata(String key, String json)Store an arbitrary custom-metadata blob underkeyin the root group.voidsetMaxResolutionLevel(int newNumLevels)Ensure the pyramid has at least this many levels, creating new levels and back-filling them from existing data as needed.
-
-
-
Constructor Detail
-
OMEZarrStorage
public OMEZarrStorage(String dir, String name, String summaryMetadataJson, OMEZarrStorageConfig config)
Create a new dataset for writing.- Parameters:
dir- parent directoryname- dataset name (a.ome.zarrfolder is created under dir)summaryMetadataJson- opaque summary metadata JSON (may be null)config- storage configuration (may be null for defaults)
-
-
Method Detail
-
load
public static OMEZarrStorage load(String dir)
Open an existing dataset for reading.
-
load
public static OMEZarrStorage load(String dir, OMEZarrStorageConfig config)
Open an existing dataset for reading with a custom config (e.g. a different backend).
-
putImage
public Future<Void> putImage(Object pixels, String metadataJson, Map<String,Object> axes, boolean rgb, int bitDepth, int imageHeight, int imageWidth)
Description copied from interface:OMEZarrAPIAdd an image to storage (resolution level 0).- Specified by:
putImagein interfaceOMEZarrAPI- Parameters:
pixels- primitive pixel array (byte[],short[],float[])metadataJson- per-image metadata as a JSON string (may be null)axes- axis name to position (Integer or String)rgb- whether the image is RGB (unsupported in v1)bitDepth- bits per pixel component (8/16/32)imageHeight- image height in pixelsimageWidth- image width in pixels- Returns:
- a future completing when the image is written
-
putImage
public Future<Void> putImage(Object pixels, String metadataJson, Map<String,Object> axes, boolean rgb, int bitDepth, int imageHeight, int imageWidth, int resolutionLevel)
Description copied from interface:MultiresOMEZarrAPIWrite a caller-supplied image to a specific resolution level, bypassing auto-downsampling. This is the "write lower-resolution data at any point in time" path.- Specified by:
putImagein interfaceMultiresOMEZarrAPIresolutionLevel- 0 = full resolution, 1 = downsampled ×2, etc.
-
getNumResLevels
public int getNumResLevels()
Description copied from interface:MultiresOMEZarrAPINumber of resolution levels currently in the pyramid.- Specified by:
getNumResLevelsin interfaceMultiresOMEZarrAPI
-
setMaxResolutionLevel
public void setMaxResolutionLevel(int newNumLevels)
Description copied from interface:MultiresOMEZarrAPIEnsure the pyramid has at least this many levels, creating new levels and back-filling them from existing data as needed. Can be called at any time during or after writing.- Specified by:
setMaxResolutionLevelin interfaceMultiresOMEZarrAPI- Parameters:
newNumLevels- desired number of resolution levels (>= current)
-
getImage
public OMEZarrImage getImage(Map<String,Object> axes)
Description copied from interface:OMEZarrAPIGet a single image (resolution level 0).- Specified by:
getImagein interfaceOMEZarrAPI
-
getImage
public OMEZarrImage getImage(Map<String,Object> axes, int level)
Description copied from interface:MultiresOMEZarrAPIGet a single image at the given resolution level.- Specified by:
getImagein interfaceMultiresOMEZarrAPI
-
getImageMetadata
public String getImageMetadata(Map<String,Object> axes)
Description copied from interface:OMEZarrAPIGet per-image metadata JSON for the image with the given axes, or null.- Specified by:
getImageMetadatain interfaceOMEZarrAPI
-
getEssentialImageMetadata
public EssentialImageMetadata getEssentialImageMetadata(Map<String,Object> axes)
Description copied from interface:OMEZarrAPIEssential metadata (width/height/bitDepth/rgb) without loading pixels.- Specified by:
getEssentialImageMetadatain interfaceOMEZarrAPI
-
getEssentialImageMetadata
public EssentialImageMetadata getEssentialImageMetadata(Map<String,Object> axes, int level)
Description copied from interface:MultiresOMEZarrAPIEssential metadata at the given resolution level.- Specified by:
getEssentialImageMetadatain interfaceMultiresOMEZarrAPI
-
hasImage
public boolean hasImage(Map<String,Object> axes)
Description copied from interface:OMEZarrAPIWhether an image with the given axes exists.- Specified by:
hasImagein interfaceOMEZarrAPI
-
hasImage
public boolean hasImage(Map<String,Object> axes, int level)
Description copied from interface:MultiresOMEZarrAPIWhether an image exists at the given resolution level.- Specified by:
hasImagein interfaceMultiresOMEZarrAPI
-
getAxesSet
public Set<Map<String,Object>> getAxesSet()
Description copied from interface:OMEZarrAPIThe set of axis positions for every image in the dataset.- Specified by:
getAxesSetin interfaceOMEZarrAPI
-
getSummaryMetadata
public String getSummaryMetadata()
Description copied from interface:OMEZarrAPIThe dataset summary metadata as a JSON string (supplied at construction), or null.- Specified by:
getSummaryMetadatain interfaceOMEZarrAPI
-
setCustomMetadata
public void setCustomMetadata(String key, String json)
Description copied from interface:OMEZarrAPIStore an arbitrary custom-metadata blob underkeyin the root group.- Specified by:
setCustomMetadatain interfaceOMEZarrAPI
-
getCustomMetadata
public String getCustomMetadata(String key)
Description copied from interface:OMEZarrAPIRetrieve a custom-metadata blob previously stored underkey, or null.- Specified by:
getCustomMetadatain interfaceOMEZarrAPI
-
isFinished
public boolean isFinished()
Description copied from interface:OMEZarrAPIWhether the dataset is finished writing and now read-only.- Specified by:
isFinishedin interfaceOMEZarrAPI
-
checkForWritingException
public void checkForWritingException() throws ExceptionDescription copied from interface:OMEZarrAPIRe-throw any exception that occurred on the writer thread.- Specified by:
checkForWritingExceptionin interfaceOMEZarrAPI- Throws:
Exception
-
finishedWriting
public void finishedWriting()
Description copied from interface:OMEZarrAPISignal that no more images will be written; the dataset becomes read-only.- Specified by:
finishedWritingin interfaceOMEZarrAPI
-
getDiskLocation
public String getDiskLocation()
Description copied from interface:OMEZarrAPIPath to the dataset root folder, or null if not on disk.- Specified by:
getDiskLocationin interfaceOMEZarrAPI
-
getUniqueAcqName
public String getUniqueAcqName()
Description copied from interface:OMEZarrAPIA unique name for this dataset instance.- Specified by:
getUniqueAcqNamein interfaceOMEZarrAPI
-
getWritingQueueTaskSize
public int getWritingQueueTaskSize()
Description copied from interface:OMEZarrAPINumber of images waiting in the writer queue.- Specified by:
getWritingQueueTaskSizein interfaceOMEZarrAPI
-
getWritingQueueTaskMaxSize
public int getWritingQueueTaskMaxSize()
Description copied from interface:OMEZarrAPIMaximum size of the writer queue.- Specified by:
getWritingQueueTaskMaxSizein interfaceOMEZarrAPI
-
close
public void close()
Description copied from interface:OMEZarrAPIRelease all resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceOMEZarrAPI
-
closeAndWait
public void closeAndWait() throws InterruptedExceptionDescription copied from interface:OMEZarrAPIRelease all resources and block until done.- Specified by:
closeAndWaitin interfaceOMEZarrAPI- Throws:
InterruptedException
-
getImageBounds
public int[] getImageBounds()
Description copied from interface:OMEZarrAPI[xMin, yMin, xMax, yMax] pixel bounds of acquired data.- Specified by:
getImageBoundsin interfaceOMEZarrAPI
-
-