如何在C#中使用openDicom.net读取dicom标记值?
我正在使用openDicom.net阅读dicom标记,如下所示:如何在C#中使用openDicom.net读取dicom标记值?,c#,tags,dicom,C#,Tags,Dicom,我正在使用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_re
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();
}
如何读取dicom标记值?我假设sq是一个序列
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();
}
我没有使用过openDicom,但是我很确定你在那里所做的不会产生你想要的结果
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();
}
您只有一个标记、描述和val_rep变量,但使用foreach填充它们,这意味着序列中的最后一个数据元素将是您检索的唯一值。您可以使用以下方法达到相同的效果:
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();
}
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文件中包含的所有不同数据元素
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();
}
如果我在这里有点离谱,请随时在您的原始帖子中回复评论或发布更多信息。我假设sq是一个序列
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();
}
我没有使用过openDicom,但是我很确定你在那里所做的不会产生你想要的结果
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();
}
您只有一个标记、描述和val_rep变量,但使用foreach填充它们,这意味着序列中的最后一个数据元素将是您检索的唯一值。您可以使用以下方法达到相同的效果:
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();
}
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文件中包含的所有不同数据元素
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();
}
如果我在这里偏离了基本点,请随时返回评论或在原始帖子中发布更多信息。未实现value.ToString()
方法。在Value.cs中实现您自己的方法,您将获得“Value”的值
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();
}
例如(仅限字符串和数值):
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();
}
未实现value.ToString()
方法。在Value.cs中实现您自己的方法,您将获得“Value”的值
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();
}
例如(仅限字符串和数值):
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();
}
使用“value”类中的“ToArray()”重写方法,从“DataElement”中的“value”成员中以泛型对象数组的形式检索标记值
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();
}
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));
}
cniDicomTagList=新列表();
foreach(sq中的数据元素)
{
string tag=element.tag.ToString();
string description=element.VR.Tag.GetDictionaryEntry().description;
object[]valueArr=element.Value.ToArray();
添加(新的CNIDicomTag(tag,description,valueArr));
}
使用'value'类中的'ToArray()'重写方法,从'DataElement'中的'value'成员中以泛型对象数组的形式检索标记值
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();
}
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));
}
cniDicomTagList=新列表();
foreach(sq中的数据元素)
{
string tag=element.tag.ToString();
string description=element.VR.Tag.GetDictionaryEntry().description;
object[]valueArr=element.Value.ToArray();
添加(新的CNIDicomTag(tag,description,valueArr));
}
您的代码不读取任何标记。我的代码与其他查看器读取的内容相同,但我找不到如何显示标记值。当您逐步查看foreach时,val_rep是否会加载其他值?我的观点是,即使您在序列的数据元素上使用foreach,您仍然只需要从序列的最终数据元素返回值。最后的数据元素很可能是空的。@Nathan Wheeler不知道为什么这被标记为正确答案。luc问你如何得到标签的价值。似乎所有将引导您找到该值的成员都是私有的。您的代码不读取任何标记。我的代码与其他查看器读取的内容相同,但我找不到如何显示标记值。当您逐步查看foreach时,val_rep是否加载了其他值?我的观点是,即使您在序列的数据元素上使用foreach,您仍然只需要从序列的最终数据元素返回值。最后的数据元素很可能是空的。@Nathan Wheeler不知道为什么这被标记为正确答案。luc问你如何得到标签的价值。似乎所有将引导您获得该值的成员都是私有的。为什么会被否决?这是一个合法的问题。为什么这会被否决?这是一个合法的问题。