skills/cv/3d-patch-sliding-window-inference/SKILL.md
Tiles 3D volumes into overlapping patches for inference and averages overlapping regions to produce seamless predictions.
npx skillsauth add wenmin-wu/ds-skills cv-3d-patch-sliding-window-inferenceInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Large 3D volumes (CT, cryo-ET, MRI) rarely fit in GPU memory whole. Sliding-window inference tiles the volume into overlapping patches, runs the model on each, then blends overlapping regions via averaging or Gaussian weighting. Eliminates boundary artifacts while keeping memory constant.
from monai.inferers import SlidingWindowInferer
inferer = SlidingWindowInferer(
roi_size=(96, 96, 96),
sw_batch_size=4,
overlap=0.5,
mode="gaussian", # Gaussian weighting reduces edge artifacts
)
output = inferer(inputs=volume_tensor, network=model)
roi_size matching the model's training patch sizeoverlap (0.25–0.5) — higher overlap = smoother but slower"gaussian" weights center pixels more; "constant" averages uniformlynp.lib.stride_tricks + weighted accumulation bufferdata-ai
Scaled Pinball Loss (SPL) metric for evaluating quantile forecasts, normalized by mean absolute successive differences of training data
data-ai
Walk backward through a time series and multiplicatively rescale segments when jumps exceed a fraction of the running mean to correct data collection anomalies
testing
Transform forecasting target to next/current ratio minus one so that optimizing MAE or squared error implicitly minimizes SMAPE
tools
Convert point forecasts to prediction intervals by scaling with logit-transformed quantile ratios passed through a Normal CDF