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.
Structs§
- Tile
Config - Tiling parameters for
tiled_field_inversion.
Functions§
- tile_
patch_ size - Padded input-patch size per axis for a config and the net’s
size_divisor:core + 2·halorounded up to a multiple ofdivisor. Isotropic, so one value serves all axes. Callers use this to build a reusableOnnxModel::plan_forplan of shape[1, 1, p, p, p]. - 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.
Type Aliases§
- Tile
- A core-aligned tile:
(x0, y0, z0, cx, cy, cz)— origin + core extent (clamped at edges).