Skip to content

No such file or directory error #1

Description

@Med-Rokaimi

Hey,
I'm trying to implement your amazing tutorial but keeps giving me this error.
FileNotFoundError: [Errno 2] No such file or directory: 'D:/manifest-1654812109500/Duke-Breast-Cancer-MRI/Breast_MRI_001/1.3.6.1.4.1.14519.5.2.1.186051521067863971269584893740842397538/1.3.6.1.4.1.14519.5.2.1.185777849803665244536713316058283493877/1-01.dcm'
this is my paths definition:

data_path = 'D:/manifest-1654812109500'
boxes_path = 'D:/Annotation_Boxes.csv'
mapping_path = 'D:/Breast-Cancer-MRI-filepath_filename-mapping.csv'
target_png_dir = 'png_out'
if not os.path.exists(target_png_dir):
	 #os.makedirs(target_png_dir)

the completed message:

FileNotFoundError                         Traceback (most recent call last)
~\AppData\Local\Temp\7\ipykernel_8036\3333985462.py in save_dcm_slice(dcm_fname, label, vol_idx)
     14         try:
---> 15             dcm = pydicom.dcmread(dcm_fname)
     16         except FileNotFoundError:

C:\ProgramData\Anaconda3\lib\site-packages\pydicom\filereader.py in dcmread(fp, defer_size, stop_before_pixels, force, specific_tags)
    992         logger.debug("Reading file '{0}'".format(fp))
--> 993         fp = open(fp, 'rb')
    994     elif fp is None or not hasattr(fp, "read") or not hasattr(fp, "seek"):

FileNotFoundError: [Errno 2] No such file or directory: 'D:/manifest-1654812109500\\Duke-Breast-Cancer-MRI/Breast_MRI_001/1.3.6.1.4.1.14519.5.2.1.186051521067863971269584893740842397538/1.3.6.1.4.1.14519.5.2.1.185777849803665244536713316058283493877/1-001.dcm'

During handling of the above exception, another exception occurred:

FileNotFoundError                         Traceback (most recent call last)
~\AppData\Local\Temp\7\ipykernel_8036\536749713.py in <module>
     39                 if ct_negative >= N_class:
     40                         continue
---> 41                 save_dcm_slice(dcm_fname, 0, vol_idx)
     42                 ct_negative += 1

~\AppData\Local\Temp\7\ipykernel_8036\3333985462.py in save_dcm_slice(dcm_fname, label, vol_idx)
     25             dcm_fname_split[-1] = dcm_fname_end
     26             dcm_fname = '/'.join(dcm_fname_split)
---> 27             dcm = pydicom.dcmread(dcm_fname)
     28 
     29 

C:\ProgramData\Anaconda3\lib\site-packages\pydicom\filereader.py in dcmread(fp, defer_size, stop_before_pixels, force, specific_tags)
    991         caller_owns_file = False
    992         logger.debug("Reading file '{0}'".format(fp))
--> 993         fp = open(fp, 'rb')
    994     elif fp is None or not hasattr(fp, "read") or not hasattr(fp, "seek"):
    995         raise TypeError("dcmread: Expected a file path or a file-like, "

FileNotFoundError: [Errno 2] No such file or directory: 'D:/manifest-1654812109500\\Duke-Breast-Cancer-MRI/Breast_MRI_001/1.3.6.1.4.1.14519.5.2.1.186051521067863971269584893740842397538/1.3.6.1.4.1.14519.5.2.1.185777849803665244536713316058283493877/1-01.dcm'

The error is occurring because the Dicom files are stored with other paths, not the default you set in your code
1-001.dcm
for example:
D:\manifest-1654812109500\Duke-Breast-Cancer-MRI\Breast_MRI_001\01-01-1990-NA-MRI BREAST BILATERAL WWO-97538\8.000000-ax dyn 2nd pass-92755

Is there an easy way please to deal with this path issue ?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions