自用,资料来源网络。
医学DICOM文件解析:https://blog.csdn.net/qq_42823043/article/details/107763358
---------------------------------------------
https://blog.csdn.net/weixin_40451627/article/details/105574348
使用Python对Dicom文件进行读取与写入
在一些特殊情况下,比如直接读取从医院拿到的数据(未经任何处理)时,可能会发生以下报错:
File is missing DICOM File Meta Information header or the \'DICM\' prefix is missing from the header. Use force=True to force reading.
》dicom文件丢失DICOM文件元信息头或头中丢失“DICM”前缀。使用强制阅读。
》raise InvalidDicomError("File is missing DICOM File Meta Information " pydicom.errors.InvalidDicomError: File is missing DICOM File Meta Information header or the \'DICM\' prefix is missing from the header. Use force=True to force reading.
可以看到,由于缺失文件元信息头,无法直接读取,只能强行读取.这种情况可以直接根据提示,调整命令为:(一般到这步就结束了)
ds = pydicom.dcmread(file_path,force=True)
但后续还会碰到: AttributeError: \'Dataset\' object has no attribute \'TransferSyntaxUID\' 在网上检索后发现,可以通过设置TransferSyntaxUID来解决问题: ds.file_meta.TransferSyntaxUID = pydicom.uid.ImplicitVRLittleEndian
----------------------------------
https://www.cnblogs.com/haochuang/p/8033688.html
dicom文件tag详解
#print(ds.dir()) # 打印所有 DICOM TAG 名
print(ds.PatientID,ds.StudyDate,ds.Modality)
或者 ds.get(0x00100020) # 这里得到的是PatientID (更推荐这个,更好用一点)
》》print(ds.get(0x0008103E)) #Series Description 检查描述和说明(这个有用!可以区别MR文件的序列)