skills/cv/dicom-12bit-pixel-correction/SKILL.md
Fix pixel overflow artifacts in 12-bit unsigned DICOM files where values wrap around at 4096
npx skillsauth add wenmin-wu/ds-skills cv-dicom-12bit-pixel-correctionInstall 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.
Some DICOM files store pixel data as 12-bit unsigned integers (BitsStored=12, PixelRepresentation=0) but report a RescaleIntercept near 0 instead of -1024. This causes pixel values to wrap around at 4096, producing artifacts. Detecting and correcting this before HU conversion prevents corrupted images from entering the training pipeline.
import pydicom
import numpy as np
def correct_dcm(dcm):
x = dcm.pixel_array + 1000
px_mode = 4096
x[x >= px_mode] = x[x >= px_mode] - px_mode
dcm.PixelData = x.tobytes()
dcm.RescaleIntercept = -1000
def safe_pixel_array(dcm):
if (dcm.BitsStored == 12
and dcm.PixelRepresentation == 0
and int(dcm.RescaleIntercept) > -100):
correct_dcm(dcm)
return dcm.pixel_array * dcm.RescaleSlope + dcm.RescaleIntercept
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