Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No such file or directory error #1

Open
Med-Rokaimi opened this issue Dec 30, 2022 · 1 comment
Open

No such file or directory error #1

Med-Rokaimi opened this issue Dec 30, 2022 · 1 comment

Comments

@Med-Rokaimi
Copy link

Med-Rokaimi commented Dec 30, 2022

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 ?

@nickk124
Copy link
Member

Hi, sorry for the late reply. I think this may be because it seems that you're running on Windows. I just commited a fix for the code to be OS agnostic (a few lines before used linux path separation), in 316cb28.

Does that fix things?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants