本文整理汇总了Python中pydicom.dataset.Dataset.is_implicit_VR方法的典型用法代码示例。如果您正苦于以下问题:Python Dataset.is_implicit_VR方法的具体用法?Python Dataset.is_implicit_VR怎么用?Python Dataset.is_implicit_VR使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pydicom.dataset.Dataset
的用法示例。
在下文中一共展示了Dataset.is_implicit_VR方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_save_as
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import is_implicit_VR [as 别名]
def test_save_as(self):
"""Test Dataset.save_as"""
fp = DicomBytesIO()
ds = Dataset()
ds.PatientName = 'CITIZEN'
# Raise AttributeError if is_implicit_VR or is_little_endian missing
self.assertRaises(
AttributeError,
ds.save_as,
fp,
write_like_original=False)
ds.is_implicit_VR = True
self.assertRaises(
AttributeError,
ds.save_as,
fp,
write_like_original=False)
ds.is_little_endian = True
del ds.is_implicit_VR
self.assertRaises(
AttributeError,
ds.save_as,
fp,
write_like_original=False)
ds.is_implicit_VR = True
ds.file_meta = Dataset()
ds.file_meta.MediaStorageSOPClassUID = '1.1'
ds.file_meta.MediaStorageSOPInstanceUID = '1.2'
ds.file_meta.TransferSyntaxUID = '1.3'
ds.file_meta.ImplementationClassUID = '1.4'
ds.save_as(fp, write_like_original=False)
示例2: test_is_original_encoding
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import is_implicit_VR [as 别名]
def test_is_original_encoding(self):
"""Test Dataset.write_like_original"""
ds = Dataset()
assert not ds.is_original_encoding
# simulate reading
ds.SpecificCharacterSet = 'ISO_IR 100'
ds.read_little_endian = True
ds.read_implicit_vr = True
ds.read_encoding = ['latin_1', 'latin_1', 'latin_1']
assert not ds.is_original_encoding
ds.is_little_endian = True
ds.is_implicit_VR = True
assert ds.is_original_encoding
# changed character set
ds.SpecificCharacterSet = 'ISO_IR 192'
assert not ds.is_original_encoding
# back to original character set
ds.SpecificCharacterSet = 'ISO_IR 100'
assert ds.is_original_encoding
ds.is_little_endian = False
assert not ds.is_original_encoding
ds.is_little_endian = True
ds.is_implicit_VR = False
assert not ds.is_original_encoding
示例3: new_data_set
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import is_implicit_VR [as 别名]
def new_data_set(tags):
""" Create a DICOM data set with the given attributes """
tags = tags or {}
data_set = Dataset()
for tag_name, value in tags.items():
setattr(data_set, tag_name, value)
data_set.file_meta = Dataset()
data_set.is_implicit_VR = False
data_set.is_little_endian = True
return data_set
示例4: test_overlay
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import is_implicit_VR [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')
示例5: _create_temporary_dataset
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import is_implicit_VR [as 别名]
def _create_temporary_dataset(shape=(100, 1024, 1024, 3), bit_depth=16):
"""Function to create a temporary dataset for use in testing.
Parameters
----------
shape : 4-tuple
The (frames, rows, columns, channels) of the test dataset.
bit_depth : int
The BitsAllocated value to use for the dataset, one of 8, 16, 32, 64.
Returns
-------
tempfile.TemporaryFile
A created DICOM File Format conformant dataset.
"""
ds = Dataset()
ds.is_little_endian = True
ds.is_implicit_VR = False
ds.file_meta = Dataset()
ds.file_meta.TransferSyntaxUID = ExplicitVRLittleEndian
ds.SOPClassUID = '1.2.3.4'
ds.SOPInstanceUID = generate_uid()
ds.BitsAllocated = bit_depth
ds.PixelRepresentation = 0
ds.PlanarConfiguration = 0
ds.Rows = shape[1]
ds.Columns = shape[2]
ds.NumberOfFrames = shape[0]
ds.SamplesPerPixel = shape[3]
if shape[3] == 1:
ds.PhotometricInterpretation = 'MONOCHROME2'
elif shape[3] == 3:
ds.PhotometricInterpretation = 'RGB'
arr = np.zeros(shape, dtype='uint{}'.format(bit_depth))
ds.PixelData = arr.tobytes()
if len(ds.PixelData) % 2:
ds.PixelData += b'\x00'
tfile = TemporaryFile(mode='w+b')
ds.save_as(tfile, write_like_original=False)
tfile.seek(0)
return tfile