Common pydicom functions called by user code
The main function to read and parse DICOM files using pydicom is read_file. It is coded in the module dicom.filereader, but is also imported when the dicom package is imported:
>>> import dicom
>>> dataset = dicom.read_file(...)
If you need fine control over the reading, you can either call read_partial or use open_dicom. All are documented below:
Read and parse a DICOM file
Parameters: |
|
---|---|
Returns: | a FileDataset instance |
Parse a DICOM file until a condition is met
read_partial is normally not called directly. Use read_file instead, unless you need to stop on some condition other than reaching pixel data.
Parameters: |
|
---|---|
Returns: | a FileDataset instance, or if a DICOMDIR, a DicomDir instance. |
A collection (dictionary) of Dicom DataElement instances.
Example of two ways to retrieve or set values:
Example (2) uses DICOM “keywords”, defined starting in 2011 standard. PatientName is not actually a member of the object, but unknown member requests are checked against the DICOM dictionary. If the name matches a DicomDictionary descriptive string, the corresponding tag is used to look up or set the DataElement instance’s value.
Attribute indent_chars: | |
---|---|
for string display, the characters used to indent nested Data Elements (e.g. sequence items). Default is three spaces. |