A DICOMDIR file contains a list of directoty records for patients, studies, series and images with some of their attributes. If all you need is a list of the DICOM files referenced in the DICOMDIR, you can just find all ReferencedFileID
tags, which contain the path components to the path as a list.
In pydicom
, a DICOMDIR is represented by a FileSet.
So, if you want to get all DICOM file paths referenced in the DICOMDIR, you can do something like this:
ds = dcmread(dicomdir_path)
fs = FileSet(ds)
root_path = fs.path
file_ids = fs.find_values("ReferencedFileID")
for file_id in file_ids:
# file_id is a list, unpack it into the components using *
dcm_path = os.path.join(root_path, *file_id)
print(dcm_path) # here you can collect the paths or load the dataset
dcmread
, you don't need to use DICOMDIR if you already know which files you want to access. – MrBean BremenReferencedFileID
). – MrBean Bremen