我正在尝试使用SimpleTk读取一个DICOM文件并将其保存到其他地方。我注意到Series Instance UID
的变化与我显式设置它的事实无关
如何保存原始UID
from pathlib import Path
import SimpleITK as sitk
dicom_path = '......'
p = Path(dicom_path)
reader = sitk.ImageFileReader()
reader.SetFileName(str(p))
reader.LoadPrivateTagsOn()
image = reader.Execute()
print('Series Instance UID', image.GetMetaData('0020|000e'))
print('SOP Instance UID', image.GetMetaData('0008|0018'))
image.SetMetaData('0020|000e', image.GetMetaData('0020|000e'))
writer = sitk.ImageFileWriter()
writer.SetFileName(out_folder+case+p.name)
writer.SetUseCompression(False)
writer.Execute(image)
reader = sitk.ImageFileReader()
reader.SetFileName(out_folder+case+p.name)
reader.LoadPrivateTagsOn()
image = reader.Execute()
print('Series Instance UID', image.GetMetaData('0020|000e'))
print('SOP Instance UID', image.GetMetaData('0008|0018'))
为系列UID提供两个不同的字符串。但SOP UID保持不变:
Series Instance UID 1.3.12.2.1107.5.1.4.74141.30000017013107011409700014483
SOP Instance UID 1.3.12.2.1107.5.1.4.74141.30000017013107011409700014570
Series Instance UID 1.2.826.0.1.3680043.2.1125.1.65790274925978549485969544082687134
SOP Instance UID 1.3.12.2.1107.5.1.4.74141.30000017013107011409700014570
虽然我从未使用过工具箱,但工具箱的行为很奇怪。如果像素数据被修改,一些属性应该被改变;在这种情况下,SOP实例UID是最重要的
但是,在您的情况下,像素数据不会被修改。而且,只修改了Series实例UID;SOP实例UID保持不变
无论如何,工具箱提供了一种在编写DICOM数据集时保留UID的方法。详情请参阅^{} 成员
这将指示toolkit在编写数据集时保留原始UID
相关问题 更多 >
编程相关推荐