MibBigDataLabelsZarr2¶
- class core.MibBigDataLabelsZarr2¶
Bases:
core.@MibBigDataLabels.MibBigDataLabelsMIBBIGDATALABELSZARR2 - read-only labels overlay for a FOREIGN zarr v2 model store.
Subclass of
core.MibBigDataLabels- read-only sibling used when a BigData dataset’s model store is a zarr v2 store MIB did not write. It parses v2 metadata directly (.zattrs/.zarray, pure MATLABjsondecode) rather than throughio.zarr.Group, because a foreign store declares its own axis order and its own multiscales layout, neither of which matches whatMibBigDataLabels.openStoreexpects. Pixel data is read throughio.zarr.Array, so the engine followsio.zarr.Configexactly as it does everywhere else.This is not the class for a MIB-written v2 store. MIB can create an editable zarr v2 model store (
MibBigDataLabels.createStorewith'zarrFormat', 2); such a store carries themibModelStoremarker attribute and is opened bycore.MibBigDataLabelsitself, fully editable.models.MibModel.loadModelpicks between the two on that marker.Why read-only. MIB’s editable BigData model is a MIB-specific packed byte format (bits 1-6 material, bit 7 mask, bit 8 selection) laid out in
[y, x, z]with a live disk-backed multi-resolution write-back pyramid. A foreign store is none of those things: its values are plain label indices in the store’s own axis order, and writing MIB’s packed bytes back into it would corrupt another tool’s data. It is instead treated as an already fully-materialized single-value-per-voxel label map - its raw values ARE the packed byte (mask/selection bits naturally 0, since there is no editing) - sogetData63(inherited, unchanged) works correctly as long as label values stay within the same[0,63]ceiling BigData imposes everywhere else.What’s overridden.
getData63itself is inherited unchanged - it already does everything needed (level picking, orientation mapping, display resize, bit-unpacking) purely by callingobj.readPackedLevel/obj.pickLevel/obj.materializeForRead, all of which dispatch polymorphically. Only three things differ fromMibBigDataLabels:openStore- v2 sidecar metadata parsing instead ofio.zarr.Group.getAttributes; setsmatLevel(:) = 1so the inheritedmaterializeForReadis a guaranteed no-op (there is no lazy up-propagation for a read-only, externally-complete source).readPackedLevel- permutes from the store’s own declared axis order, which the native path never has to do. Reads go throughio.zarr.ChunkCachelike the image loaders; MIB never writes this store, and a store replaced on disk gets a new key fromio.zarr.ChunkCache.storeKey, so cached chunks never go stale.setData63/writePackedLevel- writes are blocked; the first write attempt per session shows a one-time “read-only” notice (NOT shown on every call, sincesetData63fires on every mouse-move during a paint stroke) and the store on disk is never touched.
- Constructor Summary
- MibBigDataLabelsZarr2(img, meta)¶
MIBBIGDATALABELSZARR2 - Construct an empty read-only labels container.
- Syntax:
obj = core.MibBigDataLabelsZarr2([], meta)
Same construction contract as
core.MibBigDataLabels- pass[]forimgand attach an existing store afterwards viaopenStore. There is nocreateStorecounterpart, because a new model store is always MIB’s own:core.MibBigDataLabels.createStorewrites it, in v2 or v3, and that editable class then owns it.- Input Arguments:
img (optional) - [empty] pass
[].meta (optional) - [dictionary] metadata dictionary used by the parent constructor chain to set dimensions. Default: empty MibImage info.
- Property Summary
- modelArrayMeta¶
- modelAxisOrder¶
{1 x nLevels} full path or URL of each level array, kept from openStore so readPackedLevel can key io.zarr.ChunkCache on it without rebuilding the path on every tile read. Same key the image loaders use, so a store opened both as image and as labels shares its chunks.
- modelLevelPaths¶
{1 x nLevels} io.zarr.Array.info() results, one per level, cached alongside modelArrays{L} (the open array handle) so shape/chunkShape are not re-queried from the engine on every tile read.
- readOnlyWarningShown¶
- valueRemap¶
[char] declared C-order of the underlying zarr v2 arrays (e.g. ‘zyx’), from the store’s own multiscales.axes - unlike a MIB-written store (which always round-trips in [y,x,z], via a transpose codec in v3 or Fortran chunk order in v2), a FOREIGN store is read in whatever order it actually declared, so readPackedLevel must build the bbox / permute the result using this rather than assuming [y,x,z].
- Method Summary
- openStore(storePath)¶
OPENSTORE - attach to an EXISTING zarr v2 labels array/pyramid (read-only).
- Syntax:
obj.openStore(storePath)
Overrides
MibBigDataLabels.openStore: parses OME-NGFF multiscales metadata from.zattrs(pure MATLAB JSON, version-agnostic helpers shared with the image reader viaio.loaders.OmeZarrMetadataUtils), opens each pyramid level as anio.zarr.Array, and restores material names/colours the same wayio.loaders.Zarr2VirtualSetupLoaderresolves them forModelmode (MIB’s ownmibMaterialsattribute first, else the OME-NGFFimage-labelconvention).- Input Arguments:
storePath - [char|string] path to the zarr v2 labels group (local folder or HTTP/HTTPS URL).
- readPackedLevel(levelIdx, Ylim, Xlim, Zlim)¶
READPACKEDLEVEL - read a [ny x nx x nz] block from one level.
Overrides
MibBigDataLabels.readPackedLevel: the source array’s raw values ARE the packed byte (no bit-packing to undo - mask/ selection bits are always 0 since there is no editing), so this is a direct read, unlike the write side which stays fully blocked.Unlike a MIB-written store (whose arrays always round-trip in [y,x,z]), a foreign store is read in its OWN declared axis order (
obj.modelAxisOrder, e.g.'zyx') - the bbox rows and the result must both be built/permuted against that, not assumed.
- resolveValueRemap(attrs, storePath)¶
RESOLVEVALUEREMAP - Decide how the store’s values become materials.
- Syntax:
singleMaterialName = obj.resolveValueRemap(attrs, storePath)
Sets
valueRemapand reports whether the store turned out to hold a single class, in which case the caller names the one material after it rather than leaving 63 numbered slots.Three kinds of foreign store, decided in this order:
A declared encoding. A COSEM ground-truth class group carries
cellmap.annotationwith{absent, present, unknown}.presentbecomes material 1 and everything else - includingunknown(255), which means “not annotated”, not “background” - becomes 0. One material, named by the store’s ownclass_name.An index map. Values inside 1-63 are already MIB material indices; they pass through untouched, which is what makes a merged
allgroup (ids 3, 4, 5 … 48) keep its classes.A binary mask. An inference segmentation declares nothing and writes 0 / 255. Any non-zero value becomes material 1, named after the group’s own folder.
The distinction between 2 and 3 needs pixels, so the COARSEST pyramid level is read whole - the top of a pyramid is a few tens of kilobytes, one request. When it is empty, which a thin sparse structure often is by the time it has been downsampled eight times, the binary reading is assumed: it is the one that cannot corrupt the mask and selection layers, and an index map dense enough to be worth its ids survives downsampling.
- Input Arguments:
attrs - [struct] the store’s
.zattrs, already parsedstorePath - [char] used only for the fallback material name
- Output Arguments:
singleMaterialName - [char] name for the one material, or
''when the store holds an index map
- setData63(dataset, type, orient, materialIndex, options)¶
#ok<INUSD> SETDATA63 - blocked: zarr v2 BigData models are read-only.
Overrides
MibBigDataLabels.setData63. Never modifies the store on disk or any in-memory state. Shows a one-time “read-only” notice on the FIRST blocked write attempt of the session only - setData63 fires on every mouse-move during a paint stroke, so showing a modal dialog on every call would freeze the UI in a dialog storm.
- writePackedLevel(~, ~, ~, ~, ~, ~)¶
WRITEPACKEDLEVEL - blocked; should never be reached (setData63 blocks all writes).