Isotropic Voxel Resampling
SkillDev toolsResample 3D CT volumes to uniform voxel spacing using scipy zoom, normalizing physical dimensions across scanners
Available today. Use it from your connected AI after setup.
No other account needed.
Connect ahel once, and every AI you use reads what you have installed.
Then ask your AI: use the Isotropic Voxel Resampling skill
What this skill tells your AI
The instructions your AI receives, as published by wenmin-wu/ds-skills in skills/cv/isotropic-voxel-resampling/SKILL.md and read by ahel’s review.
Overview
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.
Quick Start
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])
Key Decisions
- 1mm isotropic: standard target for lung CT; adjust for other modalities
- Nearest-mode interpolation: preserves HU values without blending; use spline for smoother results
- Round then recompute: avoids fractional voxel drift by rounding new shape first
- Memory impact: 2.5mm→1mm triples volume size along z-axis — consider chunked processing
References
- Source: pulmonary-dicom-preprocessing
- Competition: SIIM-FISABIO-RSNA COVID-19 Detection
Signals
- GitHub stars
- 60
- Forks
- 4
- Last commit
- Apr 2026
Advanced
- Catalog kind
- skill
- Gateway key
cv-isotropic-voxel-resampling- Source
- github.com/wenmin-wu/ds-skills