简体   繁体   English

尝试获取DicomDataset时获取“ DicomTag不支持值”

[英]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方法,例如GetValueOrDefaultGetValues<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.

相关问题 收到错误消息“此页面使用框架,但您的浏览器不支持” - Getting error “This page uses frames, but your browser doesn't support” 获取错误:合同需要Duplex,但Binding&#39;BasicHttpBinding&#39;不支持它,或者没有正确配置以支持它 - Getting an error: Contract requires Duplex, but Binding 'BasicHttpBinding' doesn't support it or isn't configured properly to support it 尝试获取 Microsoft Graph 令牌时出现 NullReferenceException - NullReferenceException when trying to obtain Microsoft Graph Token 使用反射获取对象内部的属性值不起作用 - Getting property values inside object using reflection doesn't work 尝试发送短信循环时,BackgroundWorker不报告进度 - BackgroundWorker doesn't report progress when trying to send a loop of sms 尝试重新加载页面时未显示捕获异常消息 - Catch exception message doesn't displaying when trying to reload page 快速尝试时AJAX搜索无法返回准确的结果 - AJAX Search doesn't return accurate results when trying fast 尝试获取 c# 表单应用程序的 exe,获取.dll 文件 - Trying to obtain the exe for a c# form Application, getting .dll file 数据绑定时从当前行获取值 - Obtain values from current row when databinding 尝试模拟时,源 IQueryable 未实现 IDbAsyncEnumerable - The source IQueryable doesn't implement IDbAsyncEnumerable when trying to mock
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM