Skip to content
AI360Xpert
Beta

DICOM Handling for Medical Images

DICOM files carry pixels plus patient geometry and dose tags, so handling means parsing orientation before any model runs.

DICOM handling parses geometry and dose tags before pixels reach models
DICOM handling parses geometry and dose tags before pixels reach models

Why Does This Exist?

PNGs hold pixels; scanners hold patients. DICOM wraps pixels with Study, Series, and Instance UIDs plus Image Position, Orientation, Rescale Slope and Intercept, and dose tags. Ignoring them flips left-right or shifts Hounsfield by hundreds. Input is a directory of .dcm slices; output is an oriented volume in patient coordinates ready for 3D medical segmentation.

Think of It Like This

Film canisters with lab notes taped on

Photo canisters hold film plus notes on camera angle, exposure, and order. Developing film without notes mixes rolls and mirrors shots. Reading notes first stacks frames correctly.

Tags are notes and pixels are film. The analogy stops at privacy: notes include names that must be scrubbed.

How It Actually Works

Group by Series UID into volumes; sort by Image Position along the normal. Apply HU=pixel×slope+interceptHU = \text{pixel} \times \text{slope} + \text{intercept} with slope often 11 and intercept −1024-1024. Orientation cosines map array axes to LPS patient axes. Anonymize by dropping names, dates, and UIDs while keeping geometry for organ segmentation.

Worked example

A CT slice stores pixel 11501150 with slope 11 and intercept −1024-1024, giving 126126 HU liver. Orientation (1,0,0,0,1,0)(1, 0, 0, 0, 1, 0) keeps rows left-right. Sorting 200200 slices by zz position from −150-150 to +50+50 mm rebuilds 11 mm spacing. Dropping PatientName plus shifting dates keeps geometry while passing privacy review.

Watch Out For

Left-right flips from ignored orientation

Assuming axial rows always run left to right mirrors situs cases and mislabels liver side. The symptom is perfect Dice on flipped anatomy. Apply orientation cosines explicitly and verify liver right on overviews.

The Quick Version

  • DICOM pairs pixels with geometry, dose, and identity tags.
  • Rescale tags make Hounsfield numbers; orientation makes left-right.
  • Group by Series UID and sort by position before modeling.
  • Do not feed raw pixels without rescale; numbers shift by hundreds.
  • Anonymize names and dates but keep spacing for volumes.