【发布时间】:2020-12-02 22:10:00
【问题描述】:
我有很多 DICOM 数据集,其中有一个私有标签,其中包含我不想保留在标题中的信息。此标签的值随每个数据集而变化,因此我不知道该值。以下是我想要更新或删除的 PRIVATE CREATOR 和 Private Tag 的示例。
0033,0010 ---: MITRA OBJECT UTF8 ATTRIBUTES 1.0
0033,1016 ---: Dummy^Data^G^
我希望能够完全删除 0033,1016 或使用新值更新它。我尝试过的一切要么什么都不做,要么添加另一个0033,1016 标签,创建两个0033,1016 标签。一个是原始的,一个是我尝试更新原始时添加的。
0033,0010 ---: MITRA OBJECT UTF8 ATTRIBUTES 1.0
0033,1016 ---: Dummy^Data^G^
0033,1016 ---: FOO
如果我再次运行代码,我可以更新值为FOO 的0033,1016,但我永远无法将0033,1016 标记为值为Dummy^Data^G^。
以下是我的代码:
string main_path = @"C:\Users\pthalken\Desktop\foo";
DirectoryInfo foo = new DirectoryInfo(main_path);
FileInfo[] dicomFiles = foo.GetFiles();
foreach(FileInfo files in dicomFiles)
{
DicomFile openedDicom = DicomFile.Open(files.FullName, FileReadOption.ReadAll);
//getting the private tag that I want to change or remove
var remove = DicomTag.Parse("0033,1016");
var test = DicomTag.Parse("0010,0010");
//this method will work for public tags as expected, but with private tags it will juist add another tag
//it will not update the orignial tag. If ran again it will change the recently inputted tag but still not touch the original
openedDicom.Dataset.AddOrUpdate(remove, "FOO");
//Does not update original tag, will add another 0033,1016 tag with value HOT
openedDicom.Dataset.AddOrUpdate(new DicomCodeString(openedDicom.Dataset.GetPrivateTag(new DicomTag(0x0033, 0x1016)), "HOT"));
//Does not update original tag, will add another 0033,1016 tag with value HOT CHEETO
openedDicom.Dataset.AddOrUpdate(new DicomCodeString(openedDicom.Dataset.GetPrivateTag(remove), "HOT CHEETO"));
//does not remove the orignial tag
openedDicom.Dataset.Remove(remove);
openedDicom.Save(files.FullName);
}
【问题讨论】: