Tile sizing
blockbuster.auto_tile_shape(shape: tuple[int, ...], dtype: Any, target_bytes: int = 64 * 1024 ** 2, use_gpu: bool = False, gpu_memory: int | None = None, available_memory: int | None = None, n_workers: int | None = None, verbose: bool = False) -> tuple[int, ...]
Balanced tile shape for general-purpose 3-D processing.
Sizes the last three axes (spatial) to stay within the memory budget while keeping the shape as cubic as possible. Leading axes (t, c) are always 1.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
tuple[int, ...]
|
Full array shape, e.g. |
required |
dtype
|
Any
|
Array dtype. |
required |
target_bytes
|
int
|
Memory ceiling per tile. Default 64 MiB. |
64 * 1024 ** 2
|
use_gpu
|
bool
|
Size tiles against GPU VRAM rather than host RAM. |
False
|
gpu_memory
|
int | None
|
Available GPU VRAM in bytes; auto-queried when None. |
None
|
available_memory
|
int | None
|
Available host RAM in bytes; auto-queried when None. |
None
|
n_workers
|
int | None
|
Number of parallel workers (divides the RAM budget). |
None
|
verbose
|
bool
|
Log the chosen shape and estimated tile size. |
False
|
Returns:
| Type | Description |
|---|---|
tuple[int, ...]
|
Tile shape with the same number of dimensions as shape. |
Examples:
Source code in src/blockbuster/_chunks.py
blockbuster.auto_tile_shape_cellpose(shape: tuple[int, ...], dtype: Any, diameter: float | None = None, do_3D: bool = False, use_gpu: bool = False, gpu_memory: int | None = None, available_memory: int | None = None, n_workers: int | None = None, model_memory_bytes: int = 2 * 1024 ** 3, cellpose_memory_factor: int = 20, verbose: bool = False) -> tuple[int, ...]
Cellpose-optimised tile shape.
Cellpose is fundamentally 2-D: even in 3-D mode it runs 2-D segmentation on orthogonal planes and takes a consensus.
do_3D=False (default)
z is set to 1. Each tile is one 2-D (y, x) slice.
do_3D=True z is kept at its full extent per tile. y and x are tiled based on the available memory, accounting for the 3× overhead of three plane orientations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
tuple[int, ...]
|
Spatial shape, e.g. |
required |
dtype
|
Any
|
Array dtype. |
required |
diameter
|
float | None
|
Expected cell diameter in pixels. Tile will be at least |
None
|
do_3D
|
bool
|
Whether Cellpose will run in 3-D mode. |
False
|
use_gpu
|
bool
|
Size tiles for GPU VRAM. |
False
|
gpu_memory
|
int | None
|
Memory parameters (auto-queried when None). |
None
|
available_memory
|
int | None
|
Memory parameters (auto-queried when None). |
None
|
n_workers
|
int | None
|
Memory parameters (auto-queried when None). |
None
|
model_memory_bytes
|
int
|
Memory consumed by the Cellpose model weights (default 2 GiB). |
2 * 1024 ** 3
|
cellpose_memory_factor
|
int
|
Cellpose allocates roughly this multiple of raw input bytes (default 20×). |
20
|
verbose
|
bool
|
Log the chosen shape and memory estimates. |
False
|
Returns:
| Type | Description |
|---|---|
tuple[int, ...]
|
Tile shape with the same number of dimensions as shape. |
Examples:
>>> tile = auto_tile_shape_cellpose((128, 2048, 2048), "uint16", diameter=30)
>>> tile
(1, 2048, 2048)
Source code in src/blockbuster/_chunks.py
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 212 213 214 215 216 217 218 219 220 221 222 223 224 | |