邪恶的 DICOM 列表所有元素
Evil DICOM list all elements
我想在 C# 中列出一个 DICOM 文件的所有标签。
我想要下面 link 中所示的内容
我假设这是一个旧版本,因为当我将它粘贴到 Visual Studio 时它无法被识别。任何帮助将不胜感激。
假设您可以使用 Evil Dicom:
public class DicomManager
{
public List<Tag> ReadAllTags(string dicomFile)
{
var dcm = DICOMObject.Read(dicomFile);
return dcm.AllElements.Select(e => e.Tag).ToList();
}
}
UPDATE:
As per your comment, let's say you need to show the elements in a component on the UI. I'll give you an example of how you could show all the elements in a console app, but the traversing algorithm is the same in any other presentation technology.
看看Evil Dicom:
中IDICOMElement接口是怎么定义的
public interface IDICOMElement
{
Tag Tag { get; set; }
Type DatType { get; }
object DData { get; set; }
ICollection DData_ { get; set; }
}
这意味着一个元素具有您需要使用它的所有信息。
迭代元素并显示标签名称 - 元素值。
var dcm = DICOMObject.Read(dicomFile);
dcm.AllElements
.ForEach(element => Console.WriteLine("{0} - {1}", element.Tag, element.DData));
如您所见,如果您只想显示值 - 它的字符串表示形式 - 前面的代码片段应该足够了,但在元素中您有更多关于内部对象的真实类型的信息以及值的集合 - 在多值元素的情况下。
但是您需要小心,因为 DICOMObject 中的某些 VR 可能非常大,因此请确保您使用异步方法或工作线程进行处理,以便让您 UI 响应并且不除非你特别需要,否则获取一个值。
希望对您有所帮助!
我想在 C# 中列出一个 DICOM 文件的所有标签。
我想要下面 link 中所示的内容
我假设这是一个旧版本,因为当我将它粘贴到 Visual Studio 时它无法被识别。任何帮助将不胜感激。
假设您可以使用 Evil Dicom:
public class DicomManager
{
public List<Tag> ReadAllTags(string dicomFile)
{
var dcm = DICOMObject.Read(dicomFile);
return dcm.AllElements.Select(e => e.Tag).ToList();
}
}
UPDATE: As per your comment, let's say you need to show the elements in a component on the UI. I'll give you an example of how you could show all the elements in a console app, but the traversing algorithm is the same in any other presentation technology.
看看Evil Dicom:
中IDICOMElement接口是怎么定义的 public interface IDICOMElement
{
Tag Tag { get; set; }
Type DatType { get; }
object DData { get; set; }
ICollection DData_ { get; set; }
}
这意味着一个元素具有您需要使用它的所有信息。
迭代元素并显示标签名称 - 元素值。
var dcm = DICOMObject.Read(dicomFile);
dcm.AllElements
.ForEach(element => Console.WriteLine("{0} - {1}", element.Tag, element.DData));
如您所见,如果您只想显示值 - 它的字符串表示形式 - 前面的代码片段应该足够了,但在元素中您有更多关于内部对象的真实类型的信息以及值的集合 - 在多值元素的情况下。
但是您需要小心,因为 DICOMObject 中的某些 VR 可能非常大,因此请确保您使用异步方法或工作线程进行处理,以便让您 UI 响应并且不除非你特别需要,否则获取一个值。
希望对您有所帮助!