[英]Getting “DicomTag doesn't support values” when trying to obtain DicomDataset
After upgrading to fo-dicom 4.0, I started to get a DicomDataException: 'DicomTag doesn't support values'
when trying to obtain a DicomDataset from a DICOMDIR file. 升级到fo-dicom 4.0后,我开始获得
DicomDataException: 'DicomTag doesn't support values'
尝试从DICOMDIR文件获取DicomDataset时, DicomDataException: 'DicomTag doesn't support values'
。
Code is as follows: 代码如下:
var dicomDirectory = await DicomDirectory.OpenAsync(dicomdirPath);
foreach (var patientRecord in dicomDirectory.RootDirectoryRecordCollection)
{
foreach (var studyRecord in patientRecord.LowerLevelDirectoryRecordCollection)
{
foreach (var seriesRecord in studyRecord.LowerLevelDirectoryRecordCollection)
{
foreach (var imageRecord in seriesRecord.LowerLevelDirectoryRecordCollection)
{
//this is the problematic line
var dicomDataset = imageRecord.GetValue<DicomSequence>(DicomTag.IconImageSequence, 0).Items.First();
//more stuff
}
}
}
}
With the previous version (3.?) I was doing var dicomImage = imageRecord.Get<DicomSequence>(DicomTag.IconImageSequence).Items.First();
在以前的版本(3.?)中,我正在执行
var dicomImage = imageRecord.Get<DicomSequence>(DicomTag.IconImageSequence).Items.First();
and it worked just fine, but after the upgrade I was getting an Obsolete warning so I changed it to the recommended method, which was GetValue. 并且它工作得很好,但是在升级之后,我收到了过时警告,因此将其更改为推荐的方法,即GetValue。
How can I get the dataset using the current version of fo-dicom? 如何使用fo-dicom的当前版本获取数据集?
Finally, after digging through fo-dicom's Gitter and GitHub issues (and as @BenVoight mentioned in the comments as well), I found that in 4.0 we should use GetSequence(DicomTag.IconImageSequence)
instead of GetValue<DicomSequence>(DicomTag.IconImageSequence)
: when retrieving Sequences, using GetValue will throw. 最后,在仔细研究了fo-dicom的Gitter和GitHub问题(以及注释中提到的@BenVoight )之后,我发现在4.0中,我们应该使用
GetSequence(DicomTag.IconImageSequence)
而不是GetValue<DicomSequence>(DicomTag.IconImageSequence)
:检索序列时,将使用GetValue抛出。 Several other Get
methods have been added, such as GetValueOrDefault
, GetValues<T>
instead of GetValue<T[]>
, and more, as can be seen in the project's Dataset test . 在项目的Dataset测试中可以看到,还添加了其他一些
Get
方法,例如GetValueOrDefault
, GetValues<T>
而不是GetValue<T[]>
等。
Also, as a corollary, I also found another API incompatibility in 4.0 regarding the previous version (I'll post it here in case someone upgraded and got lost in the changes): when dealing with DicomImage, we shouldn't access its .Dataset
to retrieve values, because it's been deprecated as well. 此外,作为推论,我还发现了与先前版本有关的4.0中的另一个API不兼容(如果有人升级并丢失更改,我会在此处发布它):处理DicomImage时,我们不应访问其
.Dataset
检索值,因为它也已弃用。 Instead, we should store a reference to the Dataset from which the DicomImage was created in order to retrieve tag values. 相反,我们应该存储对创建DicomImage的数据集的引用,以便检索标签值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.