我dcmread()在处理给定路径中确实存在的 DICOM 文件时遇到问题。我不确定出了什么问题。这是我的代码:
import pydicom
f = "/exact/path/hi.dcm"
fn = get_testdata_file(f)
ds = pydicom.dcmread(fn)
ds.SOPClassUID = ds.MediaStorageSOPClassUID
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Traceback (most recent call last):
File "addfields.py", line 14, in <module>
ds = pydicom.dcmread(fn)
File "/Users/user/opt/anaconda3/lib/python3.7/site-packages/pydicom/filereader.py", line 871, in dcmread
force=force, specific_tags=specific_tags)
File "/Users/user/opt/anaconda3/lib/python3.7/site-packages/pydicom/filereader.py", line 668, in read_partial
preamble = read_preamble(fileobj, force)
File "/Users/user/opt/anaconda3/lib/python3.7/site-packages/pydicom/filereader.py", line 605, in read_preamble
preamble = fp.read(128)
AttributeError: 'NoneType' object has no attribute 'read'
Run Code Online (Sandbox Code Playgroud)
But I am not sure why, because "hi.dcm" is a file that …