Expand description
Overlap-tiled inference for fully-convolutional deep-learning inversions (onnx).
Whole-volume nets (e.g. xQSM, QSMnet) allocate activations proportional to the entire
volume, which overflows a 32-bit WASM heap (4 GB ceiling) on clinical-size data. Because
these nets are fully convolutional, they can instead be run patch-by-patch: each
output “core” is produced from a patch that includes a halo of surrounding context,
then written back — the classic U-Net overlap-tile strategy. Peak memory is bounded by a
single patch regardless of volume size.
NOTE: tiling a net trained on whole volumes is an approximation. Dipole inversion is a
global operation, so a patch is blind to distant susceptibility sources; a larger halo
reduces the resulting low-frequency / boundary error but does not eliminate it.
Tiles run in parallel with the parallel feature. One patch bounds memory only if the number
of concurrent patches is bounded too, which on a 32-bit WASM heap it has to be — see
tile_concurrency.
Re-exports§
pub use super::tile_budget::*;
Functions§
- check_
wasm_ patch_ fits - Refuse a tile config whose patch is too big for a WASM heap even on its own.
- tile_
concurrency - How many tiles
tiled_scatterkeeps in flight at once. - tile_
cost_ 🔒of - The cost a tiled network’s wrapper budgets with, from its registry entry
(
ModelSpec::tile_cost). Every tiled network has one (a test below checks), so a missing figure is a bug in the registry, not a runtime condition. - tiled_
field_ inversion - Run a fully-convolutional field→χ ONNX net patch-by-patch with a context halo, bounding peak memory to a single patch.
- tiled_
scatter - Shared overlap-tiling driver. Enumerates the core-aligned tiles that actually touch
mask(all-background tiles are skipped → work is restricted to the mask bounding box for free), runs each throughrun_tile, and scatters the results back into a full-volume buffer (masked). Handles the empty-tile skip, parallel batching, and progress reporting so each model only supplies its own per-patch logic. - tiled_
volume_ algorithm - Overlap-tile an entire volume→volume algorithm (not just one forward pass). For each
tile, a padded
p³sub-volume offield/maskis cut out (withhalocontext, zero outside the volume),run_patch(field_patch, mask_patch, patch_grid)is run on it, and the central core is written back. Use this for the FFT-unrolled nets (lpcnn/modl-qsm/nextqsm) whose Rust-side physics loop wraps a whole-volume CNN — running the whole algorithm per patch bounds memory. Strongly off-design (the dipole/k-space step then sees only a patch), so results are approximate; callers should warn and steer users to a full-volume run for real work.costis the network’s tile cost, as fortiled_scatter; its divisor pads each patch.
Type Aliases§
- Tile
- A core-aligned tile:
(x0, y0, z0, cx, cy, cz)— origin + core extent (clamped at edges).