【发布时间】:2022-01-08 06:44:49
【问题描述】:
我正在尝试使用 pyDicom 将 DICOM 数据集中包含的所有 TIME (VR = TM) 标签设置为占位符值。
我可以删除 DICOM 元数据的 root 中所有 TIME (VR = TM) 标记的值:
TIME_TAGS = [
(0x10, 0x32), # Patient's Birth Time
(0x40, 0x245), # Performed Procedure Step Start Time
(0x8, 0x13), # Instance Creation Time
(0x8, 0x30), # Study Time
(0x8, 0x31), # Series Time
(0x8, 0x32), # Acquisition Time
(0x8, 0x33), # Content Time
]
TIME_VAL_REPLACEMENT = '120000'
def _clear_times(dir_name: str) -> None:
'''
Set all DICOM standard (i.e. non-vendor) time tags
to a non-unique value (defined in _presets.py)
dir_name:
full path of the directory to process
'''
for dcm_file in os.listdir(dir_name):
dcm_file = os.path.join(dir_name, dcm_file)
# _presets defines what time tags to change
for time_str in TIME_TAGS:
dcmfile = pydicom.dcmread(dcm_file)
if dcmfile.get(time_str, None) and dcmfile.get(time_str,
None).VR == 'TM':
logging.debug("Removing time (%s)", time_str)
new_data = pydicom.dataelem.DataElement(
time_str, 'TM', TIME_VAL_REPLACEMENT)
dcmfile[time_str] = new_data
dcmfile.save_as(dcm_file)
else:
logging.debug("%s not set", time_str)
但是,这错过了sequences 的嵌套/子标签。
使用 pyDicom 删除所有相关的嵌套/子标签的最佳方法是什么?
【问题讨论】: