'Importing DICOM image path (using MacBook, google collab) but getting [Errno 2] No such file or directory
I'm having trouble reading the file path that contains a DICOM image. I'm familiar with retrieving a file path on Windows and reading it but I'm currently using a MacBook and it seems a little different. Can anyone shed some tips and guide me to correct solution?
import os
f = open (os.path.expanduser("/Users/lynova/Downloads/MRI_CV/SER00006/IMG00001.dcm"))
ds=dicom.read_file(f)
Solution 1:[1]
Do not use the os.path.expanduser function, unless you're using the tilde for the home folder Documentation
import os
f = open ("/Users/lynova/Downloads/MRI_CV/SER00006/IMG00001.dcm","rb")
ds=dicom.read_file(f)
Change the rb to r if the DICOM file is not binary.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Armando Leopoldo Keller |