skills/cv/hu-windowing/SKILL.md
Apply radiological windowing to HU images — clamp to center/width range for tissue-specific visualization (lung, bone, soft tissue)
npx skillsauth add wenmin-wu/ds-skills cv-hu-windowingInstall 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.
Different tissues are best visualized at different Hounsfield Unit ranges. Windowing clamps pixel values to a center±width/2 range, then rescales to display range. Use multiple windows as separate input channels to give models tissue-specific contrast without losing information.
import numpy as np
def apply_window(hu_image, center, width):
"""Apply radiological window to HU image.
Args:
hu_image: array in Hounsfield Units
center: window center (e.g., -600 for lung)
width: window width (e.g., 1500 for lung)
Returns:
windowed image clamped to [min_val, max_val]
"""
min_val = center - width / 2
max_val = center + width / 2
windowed = np.clip(hu_image, min_val, max_val)
return windowed
# Common presets
WINDOWS = {
'lung': (-600, 1500), # air-filled structures
'soft_tissue': (40, 400), # organs, muscles
'bone': (400, 1800), # skeletal structures
'brain': (40, 80), # intracranial
'mediastinum': (50, 350), # chest soft tissue
}
# Multi-window 3-channel input for CNN
lung = apply_window(hu_slice, *WINDOWS['lung'])
soft = apply_window(hu_slice, *WINDOWS['soft_tissue'])
bone = apply_window(hu_slice, *WINDOWS['bone'])
rgb_input = np.stack([lung, soft, bone], axis=-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