本文整理汇总了Python中pydicom.dataset.Dataset.top方法的典型用法代码示例。如果您正苦于以下问题:Python Dataset.top方法的具体用法?Python Dataset.top怎么用?Python Dataset.top使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pydicom.dataset.Dataset
的用法示例。
在下文中一共展示了Dataset.top方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_top
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import top [as 别名]
def test_top(self):
"""Test Dataset.top returns only top level str"""
ds = Dataset()
ds.PatientName = 'CITIZEN^Jan'
ds.BeamSequence = [Dataset()]
ds.BeamSequence[0].PatientID = 'JAN^Citizen'
assert "Patient's Name" in ds.top()
assert "Patient ID" not in ds.top()
示例2: print
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import top [as 别名]
from pydicom.datadict import DicomDictionary, keyword_dict
from pydicom.dataset import Dataset
print(__doc__)
# Define items as (VR, VM, description, is_retired flag, keyword)
# Leave is_retired flag blank.
new_dict_items = {
0x10011001: ('UL', '1', "Test One", '', 'TestOne'),
0x10011002: ('OB', '1', "Test Two", '', 'TestTwo'),
0x10011003: ('UI', '1', "Test Three", '', 'TestThree'),
}
# Update the dictionary itself
DicomDictionary.update(new_dict_items)
# Update the reverse mapping from name to tag
new_names_dict = dict([(val[4], tag) for tag, val in
new_dict_items.items()])
keyword_dict.update(new_names_dict)
# Test that it is working
ds = Dataset() # or could get one from dcmread, etc
ds.TestOne = 42
ds.TestTwo = '12345'
ds.TestThree = '1.2.3.4.5'
print(ds.top())