skills/cv/isotropic-voxel-resampling/SKILL.md
Resample 3D CT volumes to uniform voxel spacing using scipy zoom, normalizing physical dimensions across scanners
npx skillsauth add wenmin-wu/ds-skills cv-isotropic-voxel-resamplingInstall 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.
CT scanners produce volumes with non-uniform voxel spacing (e.g., 0.7×0.7×2.5 mm). Models expecting consistent spatial resolution need isotropic resampling. Compute the resize factor from original spacing to target (typically 1×1×1 mm), then apply scipy's zoom interpolation. Essential when mixing scans from different scanners or protocols.
import numpy as np
import scipy.ndimage
def resample(image, scan, new_spacing=[1, 1, 1]):
"""Resample a 3D volume to isotropic voxel spacing.
Args:
image: (D, H, W) numpy array
scan: list of pydicom Dataset objects (for metadata)
new_spacing: target voxel size in mm [z, y, x]
Returns:
resampled image, actual new spacing
"""
spacing = np.array(
[scan[0].SliceThickness] + list(scan[0].PixelSpacing),
dtype=np.float32
)
resize_factor = spacing / new_spacing
new_shape = np.round(image.shape * resize_factor)
real_resize = new_shape / image.shape
real_spacing = spacing / real_resize
resampled = scipy.ndimage.zoom(image, real_resize, mode='nearest')
return resampled, real_spacing
resampled_vol, spacing = resample(hu_volume, slices, [1, 1, 1])
data-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