pydicom中的ds.get()和ds.get_item()有什么区别 [英] What is the difference between ds.get() and ds.get_item() in pydicom

查看:310
本文介绍了pydicom中的ds.get()和ds.get_item()有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道FileDataset.get()FileDataset.get_item()这两种方法在Pydicom中有什么区别吗? 谢谢!

Does anyone know what is the difference in Pydicom between the two methods FileDataset.get() and FileDataset.get_item()? Thanks!

推荐答案

这两个在用户代码中都不经常使用. Dataset.get等同于python的 dict.get ;它允许您在字典中请求一个项目,但是如果该项目在数据集中不存在,则返回默认值.从数据集中获取项目的更常见方法是使用点表示法,例如

Both of these are not used often in user code. Dataset.get is the equivalent of python's dict.get; it allows you to ask for an item in the dictionary, but return a default if that item does not exist in the Dataset. The more usual way to get an item from a Dataset is to use the dot notation, e.g.

dataset.PatientName

或通过标签号获取DataElement对象,例如

or to get the DataElement object via the tag number, e.g.

dataset[0x100010]

Dataset.get_item是较低级别的例程,主要用于某些传入数据有问题的情况,需要在将原始数据元素"值转换为python标准类型(int,float,字符串类型等).

Dataset.get_item is a lower-level routine, primarily used when there is something wrong with some incoming data, and it needs to be corrected before the "raw data element" value is converted into python standard types (int, float, string types, etc).

与关键字一起使用时,Dataset.get()返回一个,而不是一个DataElement实例. Dataset.get_item始终返回DataElement实例或RawDataElement实例.

When used with a keyword, Dataset.get() returns a value, not a DataElement instance. Dataset.get_item always returns either a DataElement instance, or a RawDataElement instance.

这篇关于pydicom中的ds.get()和ds.get_item()有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆