因为课题需要使用DICOM格式的CT数据,为了保护病人隐私,需要删除与病人相关的名字等信息。网上搜索了几款免费的软件,都不是好用,也知道一些C++的库,但不是免费的,后面发现可以用pydicom这个软件包。
修改病人姓名的简单示例如下:
import pydicom
from pydicom.data import get_testdata_files
filename = r"D:UserDataxxxxxCT23979.dcm"
ds = pydicom.dcmread(filename) # 读取dicom文件
ds.PatientName = '0000'
ds.save_as("1.dcm") # 将修改后文件保存
之外也可通dir()
查看其它可更改信息
> ds.dir()
['AccessionNumber',
'AcquisitionDate',
'AcquisitionDateTime',...]
参考:
pydicom官方指南