pydcm¶
The complete DICOM toolkit for Python. One wheel reads, writes and decodes every transfer syntax — no codec plugins — hands you NumPy / PyTorch arrays zero-copy, and carries you the whole way: 3-D volumes, NIfTI, RT dose & DVH, radiomics, whole-slide tiles, segmentations, structured reports, waveforms, and DICOM networking. One install, one native engine, the entire pipeline.
import pydcm
ds = pydcm.dcmread("scan.dcm")
px = ds.pixel_array # any transfer syntax, no plugins
vol = pydcm.load_series("ct_series/") # sorted 3-D HU volume + affine
vol.to_nifti("ct.nii.gz")
The engine is compiled into the wheel — nothing to assemble, no plugins, no codec packages, no version matrix — with the same fast native path whether you're decoding a frame, building a volume, or running a transform. The API is clean and Pythonic, and most existing Python DICOM code runs against it unchanged.
Not a medical device
pydcm is not intended or cleared for clinical or diagnostic use. Decoded pixels, HU, dose and derived values are for research and engineering only.
One wheel, the whole pipeline¶
Every capability below ships in the same wheel, over the same native engine — each verified for correctness against reference data where exactness matters:
| Area | pydcm | What it does |
|---|---|---|
| Read / write / decode | dcmread, pixel_array, save_as |
every transfer syntax decoded; byte-verbatim editing; near-total element fidelity |
| DIMSE networking | pydcm.dimse |
SCU + SCP, all DIMSE services, persistent associations |
| DICOM ↔ NIfTI / BIDS / DWI | Volume.to_nifti, from_nifti, bids_sidecar, load_dwi, save_dwi |
spatially-correct affine incl. gantry tilt; FSL .bval/.bvec; NIfTI → DICOM too |
| DICOMDIR / file-sets | pydcm.FileSet |
read a DICOMDIR, iterate / find instances |
| Legacy Converted Enhanced | write_legacy_converted |
classic single-frame CT/MR/PET → enhanced multi-frame |
| SR coding (PS3.16) | sr_code_meaning, sr_validate_code, sr_cid_has |
DICOM code table + context-group membership / validation |
| Preprocessing | pydcm.transforms |
resample / normalize / sliding-window; bit-exact spatial ops, two interpolation conventions |
| Whole-slide imaging | pydcm.wsi |
tile & region reads on the DICOM WSI pyramid, bit-exact multi-vendor |
| RT dosimetry | pydcm.rt, dvhcalc |
dose read / write + DVH with full ROI coverage |
| Radiomics | pydcm.radiomics |
104 IBSI features across 7 classes |
| SEG / Parametric Map / SR | write_seg, write_paramap, write_report |
coded segmentations / parametric maps / measurement reports, lossless round-trip |
| KO / GSPS / annotations | write_ko, write_pr, read_ann |
Key Object Selection / Presentation State / bulk annotations |
| Encapsulated documents | write_encapsulated, read_encapsulated |
PDF / CDA / STL / OBJ / MTL ↔ DICOM |
| Waveforms | pydcm.waveforms |
ECG / EEG read & write; arrays ready for analysis tools |
| FHIR / HL7 bridges | pydcm.fhir, pydcm.hl7 |
DICOM → FHIR R4 ImagingStudy; HL7 v2 parse / ORU^R01 build |
| Agent / MCP server | pydcm.mcp |
in-process MCP — live-object tools for an LLM agent |
Where to go¶
- Install
- Quickstart — decode, volumes, networking, RT, WSI in ten minutes
- Behaviour notes — deliberate behaviours worth knowing, and migration tips
- How-to recipes — task-focused guides for every capability above
- Agent / MCP server — drive pydcm's live-object tools from an LLM agent
- API reference — generated from docstrings
- Transforms — precision & references — why "bit-exact" is defined per framework, and what each op is checked against