本文整理匯總了Python中dicom.dataset.Dataset.TransferSyntaxUID方法的典型用法代碼示例。如果您正苦於以下問題:Python Dataset.TransferSyntaxUID方法的具體用法?Python Dataset.TransferSyntaxUID怎麽用?Python Dataset.TransferSyntaxUID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dicom.dataset.Dataset
的用法示例。
在下文中一共展示了Dataset.TransferSyntaxUID方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: testUID
# 需要導入模塊: from dicom.dataset import Dataset [as 別名]
# 或者: from dicom.dataset.Dataset import TransferSyntaxUID [as 別名]
def testUID(self):
"""DataElement: setting or changing UID results in UID type........."""
ds = Dataset()
ds.TransferSyntaxUID = "1.2.3"
self.assert_(type(ds.TransferSyntaxUID) is UID, "Assignment to UID did not create UID class")
ds.TransferSyntaxUID += ".4.5.6"
self.assert_(type(ds.TransferSyntaxUID) is UID, "+= to UID did not keep as UID class")
示例2: read_partial
# 需要導入模塊: from dicom.dataset import Dataset [as 別名]
# 或者: from dicom.dataset.Dataset import TransferSyntaxUID [as 別名]
def read_partial(fileobj, stop_when=None, defer_size=None, force=False):
"""Parse a DICOM file until a condition is met
``read_partial`` is normally not called directly. Use ``read_file``
instead, unless you need to stop on some condition
other than reaching pixel data.
:arg fileobj: a file-like object. This function does not close it.
:arg stop_when: a callable which takes tag, VR, length,
and returns True or False.
If stop_when returns True,
read_data_element will raise StopIteration.
If None (default), then the whole file is read.
:returns: a set instance
"""
# Read preamble -- raise an exception if missing and force=False
preamble = read_preamble(fileobj, force)
file_meta_dataset = Dataset()
# Assume a transfer syntax, correct it as necessary
is_implicit_VR = True
is_little_endian = True
if preamble:
file_meta_dataset = _read_file_meta_info(fileobj)
transfer_syntax = file_meta_dataset.TransferSyntaxUID
if transfer_syntax == dicom.UID.ImplicitVRLittleEndian:
pass
elif transfer_syntax == dicom.UID.ExplicitVRLittleEndian:
is_implicit_VR = False
elif transfer_syntax == dicom.UID.ExplicitVRBigEndian:
is_implicit_VR = False
is_little_endian = False
elif transfer_syntax == dicom.UID.DeflatedExplicitVRLittleEndian:
# See PS3.6-2008 A.5 (p 71)
# when written, the entire dataset following
# the file metadata was prepared the normal way,
# then "deflate" compression applied.
# All that is needed here is to decompress and then
# use as normal in a file-like object
zipped = fileobj.read()
# -MAX_WBITS part is from comp.lang.python answer:
# groups.google.com/group/comp.lang.python/msg/e95b3b38a71e6799
unzipped = zlib.decompress(zipped, -zlib.MAX_WBITS)
fileobj = BytesIO(unzipped) # a file-like object
is_implicit_VR = False
else:
# Any other syntax should be Explicit VR Little Endian,
# e.g. all Encapsulated (JPEG etc) are ExplVR-LE
# by Standard PS 3.5-2008 A.4 (p63)
is_implicit_VR = False
else: # no header -- use the is_little_endian, implicit assumptions
file_meta_dataset.TransferSyntaxUID = dicom.UID.ImplicitVRLittleEndian
try:
dataset = read_dataset(fileobj, is_implicit_VR, is_little_endian,
stop_when=stop_when, defer_size=defer_size)
except EOFError as e:
pass # error already logged in read_dataset
return FileDataset(fileobj, dataset, preamble, file_meta_dataset,
is_implicit_VR, is_little_endian)
示例3: get_file_meta
# 需要導入模塊: from dicom.dataset import Dataset [as 別名]
# 或者: from dicom.dataset.Dataset import TransferSyntaxUID [as 別名]
def get_file_meta(self):
"""generate the dicom file meta data.
"""
file_meta = Dataset()
file_meta.FileMetaInformationVersion = '\x00\x01'
file_meta.MediaStorageSOPClassUID = '1.2.840.10008.5.1.4.1.1.2' # CT Image Storage
file_meta.MediaStorageSOPInstanceUID = '' # !! Need valid UID here for real work
file_meta.TransferSyntaxUID = '1.2.840.10008.1.2'
file_meta.ImplementationClassUID = pydicom_root_UID + "1" # !!! Need valid UIDs here
return file_meta