0
votes

I am new to this file type. I want to access files in the folder "S65279_1148582599_LIVER__QIU__SHIFU__M_53" by accessing DICOMDIR. Inside the folder, I want to access these "IMG" files. After dcmread the DICOMDIR file in python, I get something like: this.

How should I proceed to get 'IMG00000739'?

1
Please check the documentation. Also note that using image links to text is discouraged, use plain text instead - see how to ask a question.MrBean Bremen
The documentation is the first thing I checked. However, I still do not know how to do it after I read the documentation. Hints are really appreciated.温泽海
Just to re-iterate from the documentation: DICOMDIR is just an index to the files. You can access each of the files directly by loading it using dcmread, you don't need to use DICOMDIR if you already know which files you want to access.MrBean Bremen
Yeah I know. But the thing is I am required to load only DICOMDIR and to access other files from DICOMDIR. I wonder if there is a way of doing it at all.温泽海
You have to read the other files directly, from DICOMDIR you can only get their filename (via ReferencedFileID).MrBean Bremen

1 Answers

0
votes

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