Reading and writing DICOM files¶
Common pydicom functions called by user code
File Reading/Parsing¶
The main function to read and parse DICOM files using pydicom is
dcmread()
. It’s part of the
pydicom.filereader
module, but is also imported when the pydicom
package is
imported
>>> import pydicom >>> dataset = pydicom.dcmread('path/to/file')
If you need fine control over the reading, you can either call
read_partial()
or use dcmread()
.
File Writing¶
DICOM files can also be written using pydicom. There are two ways to do this.
The first is to use
dcmwrite()
with a prexistingFileDataset
(derived fromDataset
) instance.The second is to use the
Dataset.save_as()
method on aFileDataset
orDataset
instance.