skills/cv/middle-mip-std-volume-projection/SKILL.md
Compress a 3D medical volume into a 3-channel 2D image by stacking the middle slice, the max-intensity projection across depth, and the per-pixel std across depth — a poor-man's volumetric encoding that lets any pretrained 3-channel 2D CNN ingest a whole series in a single forward pass
npx skillsauth add wenmin-wu/ds-skills cv-middle-mip-std-volume-projectionInstall 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 you want to use an off-the-shelf 3-channel ImageNet backbone (RGB pretrained) but your data is volumetric, the slice-as-channel trick still requires in_chans=N. Even simpler: collapse the volume into exactly 3 channels by mixing complementary projections — the middle slice for anatomical context, max-intensity projection (MIP) for vessel/bright-structure highlighting, and the per-pixel standard deviation for "interesting variation" along the depth axis. Stacking these three as RGB lets a vanilla tf_efficientnetv2_s.in1k ingest a whole series in one forward and reach competitive scores on the RSNA Aneurysm leaderboard. The combination beats any single projection because each channel surfaces a different aspect of the volume.
import numpy as np
def project_volume_3ch(volume): # volume: (D, H, W) uint8 or float
middle = volume[len(volume) // 2]
mip = np.max(volume, axis=0)
std = np.std(volume, axis=0).astype(np.float32)
if std.max() > std.min():
std = ((std - std.min()) / (std.max() - std.min()) * 255).astype(np.uint8)
else:
std = np.zeros_like(std, dtype=np.uint8)
return np.stack([middle, mip, std], axis=-1) # (H, W, 3)
img = project_volume_3ch(volume)
# pass into any standard 3-channel timm model with ImageNet pretrain
[0, 255] independently — its scale is much smaller than slice intensities(H, W, 3) and feed through the standard ImageNet normalization (mean/std)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