Skip to content

Instantly share code, notes, and snippets.

@sarthakpati
Created May 10, 2021 22:22
Show Gist options
  • Save sarthakpati/1cc4739aeba15f61ed0b5c1ed072facf to your computer and use it in GitHub Desktop.
Save sarthakpati/1cc4739aeba15f61ed0b5c1ed072facf to your computer and use it in GitHub Desktop.
## Ref: https://github.com/razorx89/pydicom-seg#getting-started
import pydicom
import pydicom_seg
import SimpleITK as sitk
dcm_path = pydicom.dcmread('/path/to/segmentation.dcm')
reader = pydicom_seg.MultiClassReader()
result = reader.read(dcm_path)
image_data = result.data # directly available
image = result.image # lazy construction
sitk.WriteImage(image, '/path/for/saving/segmentation.nii.gz', True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment