I/O helpers
blockbuster.load_ome_zarr(store_path: Union[str, Path], channel: int | None = 0, level: int = 0, chunks: tuple[int, ...] | None = None) -> da.Array
Load one spatial array from an OME-ZARR store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
store_path
|
Union[str, Path]
|
Path to the OME-ZARR store (.zarr directory). |
required |
channel
|
int | None
|
Channel index to select (axis is dropped). Pass |
0
|
level
|
int
|
Resolution pyramid level (0 = full resolution). |
0
|
chunks
|
tuple[int, ...] | None
|
Target chunk shape for the returned dask array. |
None
|
Returns:
| Type | Description |
|---|---|
Array
|
Shape |
Examples:
Source code in src/blockbuster/_io.py
blockbuster.estimate_empty_tiles(image: Union[da.Array, str, Path], tile_shape: tuple[int, ...], threshold: float | None = None, channel: int | None = 0, level: int = 0, sample_window: tuple[int, ...] = (24, 256, 256)) -> dict[str, Any]
Fast preview of which tiles are background before processing.
For each tile, reads a small centred window (sample_window) and tests
whether its max exceeds threshold. Bounded I/O — runs in seconds to
minutes on terabyte arrays.
APPROXIMATE: only the tile centre is inspected. The actual tile_process
run always tests the whole tile inline. Use this only to pick a threshold
and gauge the empty fraction before committing to a full run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
Union[Array, str, Path]
|
Dask array or OME-ZARR path. |
required |
tile_shape
|
tuple[int, ...]
|
Tile shape you plan to use, e.g. |
required |
threshold
|
float | None
|
Empty cutoff (signal <= threshold → empty). None → Otsu on samples. |
None
|
channel
|
int | None
|
Used only when image is a path. |
0
|
level
|
int | None
|
Used only when image is a path. |
0
|
sample_window
|
tuple[int, ...]
|
Size of the centred window read per tile. |
(24, 256, 256)
|
Returns:
| Type | Description |
|---|---|
dict with keys:
|
|
Examples:
>>> info = estimate_empty_tiles("image.zarr", (120, 697, 697))
>>> print(f"{info['empty_fraction']:.0%} of tiles are background")
>>> labels = tile_process("image.zarr", fn, tile_shape=(120, 697, 697),
... skip_empty=True, empty_threshold=info["threshold"])
Source code in src/blockbuster/_io.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |