skills/cv/center-z-slice-selection/SKILL.md
Select a fixed number of Z-slices centered around the volume midpoint for memory-efficient 2.5D input from 3D CT/MRI stacks
npx skillsauth add wenmin-wu/ds-skills cv-center-z-slice-selectionInstall 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.
3D medical/scientific volumes often have 30-65+ slices, but loading all of them as input channels is memory-prohibitive. Selecting a fixed number of slices centered around the volume midpoint captures the most informative region (where the surface of interest typically lies) while reducing input channels from 65 to e.g. 6-12. This enables using standard 2D pretrained backbones with multi-channel input.
import cv2
import numpy as np
def load_center_slices(slice_dir, total_slices=65, n_channels=6):
mid = total_slices // 2
start = mid - n_channels // 2
end = mid + n_channels // 2
images = []
for i in range(start, end):
img = cv2.imread(f"{slice_dir}/{i:02d}.tif", cv2.IMREAD_GRAYSCALE)
images.append(img)
return np.stack(images, axis=-1) # (H, W, n_channels)
volume = load_center_slices("fragment_01/surface_volume", n_channels=8)
# Feed to 2D model with in_channels=8
mid = total // 2[mid - n//2, mid + n//2)in_channels parameterdata-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