skills/cv/slice-padding-augmented-duplicates/SKILL.md
Pad 3D volumes with fewer slices than required by duplicating existing slices with slight brightness variation via convertScaleAbs
npx skillsauth add wenmin-wu/ds-skills cv-slice-padding-augmented-duplicatesInstall 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.
When a 3D volume has fewer slices than the target depth, zero-padding wastes model capacity on empty data. Instead, pad by duplicating randomly chosen existing slices with slight brightness augmentation (cv2.convertScaleAbs(alpha=1.2)). This fills the depth dimension with plausible content and acts as a mild data augmentation, better than both zero-padding and plain duplication.
import cv2
import random
import numpy as np
def pad_volume_with_augmented_slices(slices, target_depth, alpha=1.2, beta=0):
"""Pad a list of slices to target_depth by duplicating with brightness jitter."""
while len(slices) < target_depth and slices:
donor = random.choice(slices)
augmented = cv2.convertScaleAbs(donor, alpha=alpha, beta=beta)
slices.append(augmented)
return slices[:target_depth]
flair_slices = [cv2.imread(p, 0) for p in flair_paths]
flair_slices = pad_volume_with_augmented_slices(flair_slices, target_depth=64)
volume = np.stack(flair_slices)
cv2.convertScaleAbs(alpha, beta) for slight brightness changedata-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