Category: Other
Author’s Name: Darcy Mason
Homepage: www.pydicom.github.io
Distributed with custom license file? Yes
Published: Oct 12, 2008 | Updated: Feb 01, 2013
Read, modify and write DICOM files using the python language.
Pydicom is a pure python package for working with DICOM files. It was made for inspecting and modifying DICOM data in an easy “pythonic” way. The modifications can be written again to a new file. As a pure python package, it should run anywhere python runs without any other requirements.
Here is a short code sample from an interactive python session:
Code:
>>> import dicom
>>> plan = dicom.read_file("rtplan.dcm")
>>> plan.PatientName
'Last^First^mid^pre'
>>> plan.dir("setup") # get a list of tags with "setup" somewhere in the name
['PatientSetupSequence']
>>> plan.PatientSetupSequence[0]
(0018, 5100) Patient Position CS: 'HFS'
(300a, 0182) Patient Setup Number IS: '1'
(300a, 01b2) Setup Technique Description ST: ''
>>> plan.PatientSetupSequence[0].PatientPosition = "HFP"
>>> plan.save_as("rtplan2.dcm")
