本文整理汇总了Python中pydicom.dataset.Dataset.add方法的典型用法代码示例。如果您正苦于以下问题:Python Dataset.add方法的具体用法?Python Dataset.add怎么用?Python Dataset.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pydicom.dataset.Dataset
的用法示例。
在下文中一共展示了Dataset.add方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testEqualityNoSequence
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import add [as 别名]
def testEqualityNoSequence(self):
"""Dataset: equality returns correct value with simple dataset"""
d = Dataset()
d.SOPInstanceUID = "1.2.3.4"
self.assertTrue(d == d)
e = Dataset()
e.SOPInstanceUID = "1.2.3.4"
self.assertTrue(d == e)
e.SOPInstanceUID = "1.2.3.5"
self.assertFalse(d == e)
# Check VR
del e.SOPInstanceUID
e.add(DataElement(0x00080018, "PN", "1.2.3.4"))
self.assertFalse(d == e)
# Check Tag
del e.SOPInstanceUID
e.StudyInstanceUID = "1.2.3.4"
self.assertFalse(d == e)
# Check missing Element in self
e.SOPInstanceUID = "1.2.3.4"
self.assertFalse(d == e)
# Check missing Element in other
d = Dataset()
d.SOPInstanceUID = "1.2.3.4"
d.StudyInstanceUID = "1.2.3.4.5"
e = Dataset()
e.SOPInstanceUID = "1.2.3.4"
self.assertFalse(d == e)
示例2: test_long_specific_char_set
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import add [as 别名]
def test_long_specific_char_set(self):
"""Test that specific character set is read even if it is longer
than defer_size"""
ds = Dataset()
long_specific_char_set_value = ['ISO 2022IR 100'] * 9
ds.add(DataElement(0x00080005, 'CS', long_specific_char_set_value))
fp = BytesIO()
file_ds = FileDataset(fp, ds)
file_ds.save_as(fp, write_like_original=True)
ds = dcmread(fp, defer_size=65, force=True)
self.assertEqual(ds[0x00080005].value, long_specific_char_set_value)
示例3: testEqualityPrivate
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import add [as 别名]
def testEqualityPrivate(self):
"""Dataset: equality returns correct value when dataset has private elements"""
d = Dataset()
d_elem = DataElement(0x01110001, "PN", "Private")
self.assertTrue(d == d)
d.add(d_elem)
e = Dataset()
e_elem = DataElement(0x01110001, "PN", "Private")
e.add(e_elem)
self.assertTrue(d == e)
e[0x01110001].value = "Public"
self.assertFalse(d == e)
示例4: test_correct_ambiguous_explicit_vr
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import add [as 别名]
def test_correct_ambiguous_explicit_vr(self):
"""Test correcting ambiguous VR elements read from file"""
ds = Dataset()
ds.PixelRepresentation = 0
ds.add(DataElement(0x00280108, 'US', 10))
ds.add(DataElement(0x00280109, 'US', 500))
fp = BytesIO()
file_ds = FileDataset(fp, ds)
file_ds.is_implicit_VR = False
file_ds.is_little_endian = True
file_ds.save_as(fp, write_like_original=True)
ds = dcmread(fp, force=True)
self.assertEqual(ds[0x00280108].VR, 'US')
self.assertEqual(ds.SmallestPixelValueInSeries, 10)
示例5: testEqualityNoSequence
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import add [as 别名]
def testEqualityNoSequence(self):
"""Dataset: equality returns correct value with simple dataset"""
# Test empty dataset
assert Dataset() == Dataset()
d = Dataset()
d.SOPInstanceUID = '1.2.3.4'
d.PatientName = 'Test'
assert d == d
e = Dataset()
e.PatientName = 'Test'
e.SOPInstanceUID = '1.2.3.4'
assert d == e
e.SOPInstanceUID = '1.2.3.5'
assert not d == e
# Check VR
del e.SOPInstanceUID
e.add(DataElement(0x00080018, 'PN', '1.2.3.4'))
assert not d == e
# Check Tag
del e.SOPInstanceUID
e.StudyInstanceUID = '1.2.3.4'
assert not d == e
# Check missing Element in self
e.SOPInstanceUID = '1.2.3.4'
assert not d == e
# Check missing Element in other
d = Dataset()
d.SOPInstanceUID = '1.2.3.4'
d.StudyInstanceUID = '1.2.3.4.5'
e = Dataset()
e.SOPInstanceUID = '1.2.3.4'
assert not d == e
示例6: testEqualityNoSequence
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import add [as 别名]
def testEqualityNoSequence(self):
"""Dataset: equality returns correct value with simple dataset"""
d = Dataset()
d.SOPInstanceUID = '1.2.3.4'
d.PatientName = 'Test'
self.assertTrue(d == d)
e = Dataset()
e.PatientName = 'Test'
e.SOPInstanceUID = '1.2.3.4'
self.assertTrue(d == e)
e.SOPInstanceUID = '1.2.3.5'
self.assertFalse(d == e)
# Check VR
del e.SOPInstanceUID
e.add(DataElement(0x00080018, 'PN', '1.2.3.4'))
self.assertFalse(d == e)
# Check Tag
del e.SOPInstanceUID
e.StudyInstanceUID = '1.2.3.4'
self.assertFalse(d == e)
# Check missing Element in self
e.SOPInstanceUID = '1.2.3.4'
self.assertFalse(d == e)
# Check missing Element in other
d = Dataset()
d.SOPInstanceUID = '1.2.3.4'
d.StudyInstanceUID = '1.2.3.4.5'
e = Dataset()
e.SOPInstanceUID = '1.2.3.4'
self.assertFalse(d == e)
示例7: test_overlay
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import add [as 别名]
def test_overlay(self):
"""Test correcting OverlayData"""
# Implicit VR must be 'OW'
ref_ds = Dataset()
ref_ds.is_implicit_VR = True
ref_ds.add(DataElement(0x60003000, 'OB or OW', b'\x00'))
ref_ds.add(DataElement(0x601E3000, 'OB or OW', b'\x00'))
ds = correct_ambiguous_vr(deepcopy(ref_ds), True)
self.assertTrue(ds[0x60003000].VR == 'OW')
self.assertTrue(ds[0x601E3000].VR == 'OW')
self.assertTrue(ref_ds[0x60003000].VR == 'OB or OW')
self.assertTrue(ref_ds[0x601E3000].VR == 'OB or OW')
# Explicit VR may be 'OB' or 'OW' (leave unchanged)
ref_ds.is_implicit_VR = False
ds = correct_ambiguous_vr(deepcopy(ref_ds), True)
self.assertTrue(ds[0x60003000].VR == 'OB or OW')
self.assertTrue(ref_ds[0x60003000].VR == 'OB or OW')
# Missing is_implicit_VR (leave unchanged)
del ref_ds.is_implicit_VR
ds = correct_ambiguous_vr(deepcopy(ref_ds), True)
self.assertTrue(ds[0x60003000].VR == 'OB or OW')
self.assertTrue(ref_ds[0x60003000].VR == 'OB or OW')