Zarr.NET  0.6.1
Zarr reader and writer in .NET
Loading...
Searching...
No Matches
ZarrNET Namespace Reference

Classes

class  BloscCodec
 Blosc bytes-to-bytes codec. More...
 
class  BytesCodec
 The "bytes" array-to-bytes codec (Zarr v3 spec section 3.3.2). Handles endianness conversion when translating between the in-memory array representation and a flat byte sequence. This is always the first codec in a Zarr v3 pipeline. More...
 
class  ChunkGridConfigurationDocument
 
class  ChunkGridDocument
 
class  ChunkKeyEncodingConfigurationDocument
 
class  ChunkKeyEncodingDocument
 
class  CodecDocument
 
class  CodecFactory
 Builds a CodecPipeline from the CodecInfo descriptors stored in ZarrArrayMetadata. This is the only place that knows which codec name maps to which implementation. Handles both Zarr v3 (named pipeline) and Zarr v2 (single compressor, synthesised pipeline).
 
class  CodecPipeline
 Applies an ordered list of codecs as a pipeline. More...
 
class  Crc32cCodec
 The "crc32c" bytes-to-bytes codec (Zarr v3 spec). More...
 
class  DiagnoseChunks
 
class  DiagnosticHelper
 
class  GzipCodec
 Gzip bytes-to-bytes codec. Wraps System.IO.Compression — no native dependencies. Configuration mirrors the zarr.json "gzip" codec configuration object. More...
 
interface  IZarrCodec
 A single step in a Zarr v3 codec pipeline. Codecs are applied in order during encoding (array → bytes → compressed) and reversed during decoding. Each codec is responsible for one transformation only. More...
 
class  NumpyDtypeParser
 Parses numpy-style dtype strings used in Zarr v2. Format: [byteorder][typecode][size] byteorder: '<' (little), '>' (big), '|' (not applicable) typecode: 'u' (uint), 'i' (int), 'f' (float), 'b' (bool) size: number of bytes (1, 2, 4, 8) Examples: "<u2" → little-endian uint16, ">f4" → big-endian float32, "|u1" → uint8.
 
class  PlaneHelpers
 
class  Reader
 
class  ShardingConfig
 Configuration for a sharding_indexed codec parsed from zarr.json. More...
 
class  ShardReader
 Reads individual inner chunks from a shard file.
 
class  SimpleHttpTest
 
class  ZarrArrayMetadata
 Typed metadata for a Zarr array node. Knows everything needed to read/write chunks — shape, data type, chunk layout, codec pipeline configuration. No OME-Zarr knowledge here. More...
 
class  ZarrDataType
 Typed representation of a Zarr v3 data type string (e.g. "uint8", "float32"). Resolves element size in bytes and provides type classification used by the codec pipeline for byte-order handling. More...
 
class  ZarrGroupMetadata
 Typed metadata for a Zarr v3 group node. Groups are pure containers — no data, no shape, just attributes and children. More...
 
class  ZarrJsonDocument
 Raw deserialisation of a zarr.json node document (Zarr v3 spec). This is the only place we touch raw JSON — all higher layers work with typed metadata objects derived from this. More...
 
class  ZarrV2ArrayDocument
 Raw deserialization of a .zarray file (Zarr v2). Maps array metadata — shape, chunks, dtype, compression. More...
 
class  ZarrV2AttrsDocument
 Raw deserialization of a .zattrs file (Zarr v2). This is freeform JSON — OME-Zarr metadata lives here. We just parse it as a raw JsonElement and pass to OmeAttributesParser. More...
 
class  ZarrV2CompressorDocument
 
class  ZarrV2GroupDocument
 Raw deserialization of a .zgroup file (Zarr v2). Just contains the format version — no other metadata. More...
 
class  ZstdCodec
 Zstandard bytes-to-bytes codec. Uses ZstdSharp (managed wrapper around the native zstd library, available as a NuGet package). NuGet: ZstdSharp.Port (pure managed port, no native deps) More...
 

Enumerations

enum  BloscShuffle { None = 0 , ByteShuffle = 1 , BitShuffle = 2 }
 Shuffle filter mode stored in the Blosc frame header flags byte. More...
 
enum  ByteOrder { LittleEndian , BigEndian }
 
enum  ShardIndexLocation { End , Start }
 

Functions

class PropertyReferanceGuide ()
 
record CodecInfo (string Name, JsonElement? Configuration)
 Lightweight codec descriptor parsed from zarr.json or synthesised from a v2 compressor. The actual IZarrCodec instances are built by CodecFactory from this.
 

Enumeration Type Documentation

◆ BloscShuffle

Shuffle filter mode stored in the Blosc frame header flags byte.

651{
652 None = 0,
653 ByteShuffle = 1,
654 BitShuffle = 2
655}

◆ ByteOrder

enum ZarrNET.ByteOrder
108{
109 LittleEndian,
110 BigEndian
111}

◆ ShardIndexLocation

enum ZarrNET.ShardIndexLocation
66{
67 End,
68 Start
69}

Function Documentation

◆ PropertyReferanceGuide()

class ZarrNET.PropertyReferanceGuide ( )
15 {
16 public static MultiscaleNode image;
17 // =============================================================================
18 // ResolutionLevelNode - Array-level properties
19 // =============================================================================
20 public static async Task Start(MultiscaleNode node)
21 {
22 await using var reader = await OmeZarrReader.OpenAsync("path/to/data.zarr");
23 image = reader.AsMultiscaleImage();
24 var level = await image.OpenResolutionLevelAsync(0);
25
26 // ✓ CORRECT - Available on ResolutionLevelNode:
27 long[] shape = level.Shape; // [t, c, z, y, x] - full array dimensions
28 string dtype = level.DataType; // "uint16", "float32", etc.
29 int rank = level.Rank; // Number of dimensions (e.g., 5 for t,c,z,y,x)
30 double[] pixelSize = level.GetPixelSize(); // Physical size per pixel [µm, µm, µm...]
31
32 // Example: Get width and height from Shape
33 var axes = level.Multiscale.Axes;
34 var yIndex = Array.FindIndex(axes, a => a.Name.Equals("y", StringComparison.OrdinalIgnoreCase));
35 var xIndex = Array.FindIndex(axes, a => a.Name.Equals("x", StringComparison.OrdinalIgnoreCase));
36 long arrayHeight = level.Shape[yIndex]; // Full array height
37 long arrayWidth = level.Shape[xIndex]; // Full array width
38
39 // ✗ WRONG - These don't exist on ResolutionLevelNode:
40 // int width = level.Width; // ❌ Compile error
41 // int height = level.Height; // ❌ Compile error
42
43 // =============================================================================
44 // PlaneResult - 2D plane properties (after reading)
45 // =============================================================================
46
47 var plane = await level.ReadPlaneAsync(t: 0, c: 0, z: 0);
48
49 // ✓ CORRECT - Available on PlaneResult:
50 int width = plane.Width; // Width of the read plane (x dimension)
51 int height = plane.Height; // Height of the read plane (y dimension)
52 //byte[] data = plane.Data; // Raw bytes
53 //int[] shape = plane.Shape; // Shape of the read region
54 //string dtype = plane.DataType; // Data type string
55
56 // Extract data:
57 ushort[,] pixels2D = plane.As2DArray<ushort>();
58 ushort[] pixels1D = plane.As1DArray<ushort>();
59 byte[] bytes = plane.ToBytes<ushort>(ZarrNET.Core.Helpers.PixelFormat.Gray8);
60
61 // =============================================================================
62 // RegionResult - Multi-dimensional region (may not be 2D)
63 // =============================================================================
64
65 var roi = new PhysicalROI(
66 origin: [0, 0, 0, 0, 0],
67 size: [5, 4, 10, 100, 100] // Multiple timepoints, channels, z-slices
68 );
69 var result = await level.ReadRegionAsync(roi);
70
71 // ✓ CORRECT - Available on RegionResult:
72 var data = result.Data; // Raw bytes
73 shape = result.Shape; // [5, 4, 10, 100, 100] in this case
74 dtype = result.DataType; // Data type
75 rank = result.Rank; // Number of dimensions
76 var elementCount = result.ElementCount; // Total elements
77
78 // ✗ WRONG - Width/Height only exist if it's a 2D plane:
79 // int width = result.Width; // ❌ Not available on RegionResult
80 // int height = result.Height; // ❌ Not available on RegionResult
81 }
82 // =============================================================================
83 // Common Patterns
84 // =============================================================================
85
86 // Pattern 1: Get full array dimensions
87 public static async Task GetArrayDimensions()
88 {
89 var level = await image.OpenResolutionLevelAsync(0);
90
91 // Method 1: From Shape with axis names
92 var axes = level.Multiscale.Axes;
93 for (int i = 0; i < axes.Length; i++)
94 {
95 Console.WriteLine($"{axes[i].Name}: {level.Shape[i]}");
96 }
97
98 // Method 2: Direct indexing (if you know the layout)
99 // Typical 5D: [t, c, z, y, x]
100 if (level.Rank == 5)
101 {
102 long t = level.Shape[0];
103 long c = level.Shape[1];
104 long z = level.Shape[2];
105 long y = level.Shape[3];
106 long x = level.Shape[4];
107 Console.WriteLine($"Array: {t}t x {c}c x {z}z x {y}y x {x}x");
108 }
109 }
110
111 // Pattern 2: Get plane dimensions after reading
112 public static async Task GetPlaneDimensions()
113 {
114 var level = await image.OpenResolutionLevelAsync(0);
115 var plane = await level.ReadPlaneAsync(t: 0, c: 0, z: 0);
116
117 // ✓ CORRECT - plane has Width and Height
118 Console.WriteLine($"Plane: {plane.Width} x {plane.Height}");
119
120 // Also available:
121 Console.WriteLine($"Shape: [{string.Join(", ", plane.Shape)}]");
122 }
123
124 // Pattern 3: Validate dimensions before processing
125 public async static Task ValidateDimensions()
126 {
127 var level = await image.OpenResolutionLevelAsync(0);
128
129 // Check if it's a 5D dataset
130 if (level.Rank != 5)
131 {
132 throw new InvalidOperationException(
133 $"Expected 5D data (t,c,z,y,x), got {level.Rank}D");
134 }
135
136 // Check spatial dimensions
137 var yIndex = Array.FindIndex(level.Multiscale.Axes,
138 a => a.Name.Equals("y", StringComparison.OrdinalIgnoreCase));
139 var xIndex = Array.FindIndex(level.Multiscale.Axes,
140 a => a.Name.Equals("x", StringComparison.OrdinalIgnoreCase));
141
142 long height = level.Shape[yIndex];
143 long width = level.Shape[xIndex];
144
145 Console.WriteLine($"Spatial dimensions: {width} x {height}");
146 }
147
148 // Pattern 4: Read and process plane data
149 public async static Task ProcessPlane()
150 {
151 var level = await image.OpenResolutionLevelAsync(0);
152 var plane = await level.ReadPlaneAsync(t: 0, c: 0, z: 0);
153
154 // Get dimensions from the plane result
155 int w = plane.Width;
156 int h = plane.Height;
157
158 // Process the data
159 var pixels = plane.As2DArray<ushort>();
160 for (int y = 0; y < h; y++)
161 {
162 for (int x = 0; x < w; x++)
163 {
164 ushort value = pixels[y, x];
165 // Process pixel...
166 }
167 }
168 }
169 }
Represents a multiscale image group. Contains one or more resolution levels and optionally a labels s...
Definition OmeZarrNodes.cs:40
async Task< ResolutionLevelNode > OpenResolutionLevelAsync(int multiscaleIndex=0, int datasetIndex=0, CancellationToken ct=default)
Opens a specific resolution level by index (0 = full resolution).
Definition OmeZarrNodes.cs:56
A region of interest expressed in physical units (e.g. micrometers). Axis order matches the multiscal...
Definition PhysicalROI.cs:9
Entry point for reading OME-Zarr datasets.
Definition OmeZarrReader.cs:31
static async Task< OmeZarrReader > OpenAsync(string pathOrUrl, CancellationToken ct=default)
Opens a Zarr store at the given path or URL and detects the OME-Zarr node type at the root.
Definition OmeZarrReader.cs:99
Definition PlaneReader.cs:5
Definition ChunkLruCache.cs:3
Definition BloscCodec.cs:6