如何在 C# 中使用 openDicom.net 读取 dicom 标签值?

发布于 2024-09-18 05:03:05 字数 358 浏览 3 评论 0原文

我正在使用 openDicom.net 读取 dicom 标签,如下所示:

string tag = "";
string description = "";
string val_rep = "";

foreach (DataElement elementy in sq)
{
    tag = elementy.Tag.ToString();
    description = elementy.VR.Tag.GetDictionaryEntry().Description;
    val_rep = elementy.VR.ToString();
}

How can I read dicom tag values?

I'm reading dicom tags using openDicom.net like this:

string tag = "";
string description = "";
string val_rep = "";

foreach (DataElement elementy in sq)
{
    tag = elementy.Tag.ToString();
    description = elementy.VR.Tag.GetDictionaryEntry().Description;
    val_rep = elementy.VR.ToString();
}

How can I read dicom tag values?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

仲春光 2024-09-25 05:03:05

value.ToString() 方法未实现。在 Value.cs 中实现您自己的方法,您将获得“Value”的值。

例如(仅限字符串和数值):

public override string ToString()
{
 return valueList[0].ToString();
}

the value.ToString() method isn't implemented. Implement your own method in Value.cs and you will get a value for "Value".

For example (only strings and numeric values):

public override string ToString()
{
 return valueList[0].ToString();
}
草莓酥 2024-09-25 05:03:05

我假设 sq 是一个序列...

我没有使用过 openDicom,但我很确定你在那里所做的事情不会产生你想要的结果。

您有一个标记、描述和 val_rep 变量,但您使用 foreach 填充它们,这意味着序列中的最后一个 DataElement 将是您检索的唯一值。您可以通过使用以下方法实现相同的效果:

string tag = sq[sq.Count - 1].Tag.ToString();
string description = sq[sq.Count -1].VR.Tag.GetDictionaryEntry().Description;
string val_rep = sq[sq.Count - 1].VR.ToString();

从而从序列中检索最后一组值。我相信您会发现,如果您在执行时单步执行 foreach,它将加载 DICOM 文件中包含的所有不同的 DataElements。

如果我在这里偏离基地,请随时回复评论或在您的原始帖子中发布更多信息。

I'm assuming that sq is a Sequence...

I've not worked with openDicom, but I'm pretty sure what you're doing there isn't going to yield the results you want.

You have a single tag, description, and val_rep variable, but you're filling them using a foreach, meaning the last DataElement in the Sequence will be the only values you retrieve. You would achieve the same effect by using:

string tag = sq[sq.Count - 1].Tag.ToString();
string description = sq[sq.Count -1].VR.Tag.GetDictionaryEntry().Description;
string val_rep = sq[sq.Count - 1].VR.ToString();

Thus retrieving the last set of values from the Sequence. I believe you'll find that if you step through the foreach as it executes, it will be loading all the different DataElements contained in your DICOM file.

Feel free to return a comment or post more information in your original post if I'm way off base here.

野却迷人 2024-09-25 05:03:05

使用“Value”类中的“ToArray()”重写方法,从“DataElement”中的“Value”成员以通用对象数组形式检索标记值。

cniDicomTagList = new List<CNIDicomTag>();
foreach (DataElement element in sq)
{
     string tag = element.Tag.ToString();
     string description = element.VR.Tag.GetDictionaryEntry().Description;
     object[] valueArr = element.Value.ToArray();
     cniDicomTagList.Add(new CNIDicomTag(tag, description, valueArr));
}

The tag value is retrieved as an array of generic object from the 'Value' member in 'DataElement' using the 'ToArray()' overriding method in the 'Value' class.

cniDicomTagList = new List<CNIDicomTag>();
foreach (DataElement element in sq)
{
     string tag = element.Tag.ToString();
     string description = element.VR.Tag.GetDictionaryEntry().Description;
     object[] valueArr = element.Value.ToArray();
     cniDicomTagList.Add(new CNIDicomTag(tag, description, valueArr));
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文