当前位置: 首页>>代码示例>>Python>>正文


Python Dataset.TransferSyntaxUID方法代码示例

本文整理汇总了Python中pydicom.dataset.Dataset.TransferSyntaxUID方法的典型用法代码示例。如果您正苦于以下问题:Python Dataset.TransferSyntaxUID方法的具体用法?Python Dataset.TransferSyntaxUID怎么用?Python Dataset.TransferSyntaxUID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pydicom.dataset.Dataset的用法示例。


在下文中一共展示了Dataset.TransferSyntaxUID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_filelike_position

# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import TransferSyntaxUID [as 别名]
    def test_filelike_position(self):
        """Test that the file-like's ending position is OK."""
        # 4 bytes prefix
        # 8 + 4 bytes FileMetaInformationGroupLength
        # 12 + 2 bytes FileMetaInformationVersion
        # 8 + 4 bytes MediaStorageSOPClassUID
        # 8 + 4 bytes MediaStorageSOPInstanceUID
        # 8 + 4 bytes TransferSyntaxUID
        # 8 + 4 bytes ImplementationClassUID
        # 78 bytes total
        meta = Dataset()
        meta.MediaStorageSOPClassUID = '1.1'
        meta.MediaStorageSOPInstanceUID = '1.2'
        meta.TransferSyntaxUID = '1.3'
        meta.ImplementationClassUID = '1.4'
        _write_file_meta_info(self.fp, meta)
        self.assertEqual(self.fp.tell(), 78)

        # 8 + 6 bytes ImplementationClassUID
        # 80 bytes total, group length 64
        self.fp.seek(0)
        meta.ImplementationClassUID = '1.4.1'
        _write_file_meta_info(self.fp, meta)
        # Check File Meta length
        self.assertEqual(self.fp.tell(), 80)
        # Check Group Length
        self.fp.seek(12)
        self.assertEqual(self.fp.read(4), b'\x40\x00\x00\x00')
        _write_file_meta_info(self.fp, meta)
开发者ID:bastula,项目名称:pydicom,代码行数:31,代码来源:test_filewriter.py

示例2: create_metadata

# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import TransferSyntaxUID [as 别名]
 def create_metadata():
     metadata = Dataset()
     metadata.MediaStorageSOPClassUID = '1.2.840.10008.5.1.4.1.1.7'
     metadata.MediaStorageSOPInstanceUID = '1.2.3'
     metadata.TransferSyntaxUID = '1.2.840.10008.1.2'
     metadata.ImplementationClassUID = '1.3.6.1.4.1.5962.2'
     return metadata
开发者ID:mrbean-bremen,项目名称:dcm-spec-tools,代码行数:9,代码来源:test_dicom_file_validator.py

示例3: testUID

# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.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.assertTrue(isinstance(ds.TransferSyntaxUID, UID),
                     "Assignment to UID did not create UID class")
     ds.TransferSyntaxUID += ".4.5.6"
     self.assertTrue(isinstance(ds.TransferSyntaxUID, UID),
                     "+= to UID did not keep as UID class")
开发者ID:bastula,项目名称:pydicom,代码行数:11,代码来源:test_dataelem.py

示例4: test_bad_elements

# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import TransferSyntaxUID [as 别名]
 def test_bad_elements(self):
     """Test that non-group 2 elements aren't written to the file meta."""
     meta = Dataset()
     meta.PatientID = '12345678'
     meta.MediaStorageSOPClassUID = '1.1'
     meta.MediaStorageSOPInstanceUID = '1.2'
     meta.TransferSyntaxUID = '1.3'
     meta.ImplementationClassUID = '1.4'
     self.assertRaises(ValueError, _write_file_meta_info, self.fp, meta)
开发者ID:bastula,项目名称:pydicom,代码行数:11,代码来源:test_filewriter.py

示例5: test_version

# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import TransferSyntaxUID [as 别名]
    def test_version(self):
        """Test that the value for FileMetaInformationVersion is OK."""
        meta = Dataset()
        meta.MediaStorageSOPClassUID = '1.1'
        meta.MediaStorageSOPInstanceUID = '1.2'
        meta.TransferSyntaxUID = '1.3'
        meta.ImplementationClassUID = '1.4'
        _write_file_meta_info(self.fp, meta)

        self.fp.seek(16 + 12)
        self.assertEqual(self.fp.read(2), b'\x00\x01')
开发者ID:bastula,项目名称:pydicom,代码行数:13,代码来源:test_filewriter.py

示例6: create_dicom_plan

# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import TransferSyntaxUID [as 别名]
    def create_dicom_plan(self):
        """ Create a dummy DICOM RT-plan object.

        The only data which is forwarded to this object, is self.patient_name.
        :returns: a DICOM RT-plan object.
        """
        meta = Dataset()
        meta.MediaStorageSOPClassUID = '1.2.840.10008.5.1.4.1.1.2'  # CT Image Storage
        meta.MediaStorageSOPInstanceUID = "1.2.3"
        meta.ImplementationClassUID = "1.2.3.4"
        meta.TransferSyntaxUID = uid.ImplicitVRLittleEndian  # Implicit VR Little Endian - Default Transfer Syntax
        ds = FileDataset("file", {}, file_meta=meta, preamble=b"\0" * 128)
        ds.PatientsName = self.patient_name
        if self.patient_id in (None, ''):
            ds.PatientID = datetime.datetime.today().strftime('%Y%m%d-%H%M%S')
        else:
            ds.PatientID = self.patient_id  # Patient ID tag 0x0010,0x0020 (type LO - Long String)
        ds.PatientsSex = ''  # Patient's Sex tag 0x0010,0x0040 (type CS - Code String)
        #                      Enumerated Values: M = male F = female O = other.
        ds.PatientsBirthDate = '19010101'
        ds.SpecificCharacterSet = 'ISO_IR 100'
        ds.SOPClassUID = '1.2.840.10008.5.1.4.1.1.2'  # CT Image Storage

        # Study Instance UID tag 0x0020,0x000D (type UI - Unique Identifier)
        # self._dicom_study_instance_uid may be either set in __init__ when creating new object
        #   or set when import a DICOM file
        #   Study Instance UID for structures is the same as Study Instance UID for CTs
        ds.StudyInstanceUID = self._dicom_study_instance_uid

        # Series Instance UID tag 0x0020,0x000E (type UI - Unique Identifier)
        # self._pl_dicom_series_instance_uid may be either set in __init__ when creating new object
        #   Series Instance UID might be different than Series Instance UID for CTs
        ds.SeriesInstanceUID = self._plan_dicom_series_instance_uid

        ds.Modality = "RTPLAN"
        ds.SeriesDescription = 'RT Plan'
        ds.RTPlanDate = datetime.datetime.today().strftime('%Y%m%d')
        ds.RTPlanGeometry = ''
        ds.RTPlanLabel = 'B1'
        ds.RTPlanTime = datetime.datetime.today().strftime('%H%M%S')
        structure_ref = Dataset()
        structure_ref.RefdSOPClassUID = '1.2.840.10008.5.1.4.1.1.481.3'  # RT Structure Set Storage
        structure_ref.RefdSOPInstanceUID = '1.2.3'
        ds.RefdStructureSets = Sequence([structure_ref])

        dose_ref = Dataset()
        dose_ref.DoseReferenceNumber = 1
        dose_ref.DoseReferenceStructureType = 'SITE'
        dose_ref.DoseReferenceType = 'TARGET'
        dose_ref.TargetPrescriptionDose = self.target_dose
        dose_ref.DoseReferenceDescription = "TUMOR"
        ds.DoseReferenceSequence = Sequence([dose_ref])
        return ds
开发者ID:pytrip,项目名称:pytrip,代码行数:55,代码来源:dos.py

示例7: test_group_length

# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import TransferSyntaxUID [as 别名]
    def test_group_length(self):
        """Test that the value for FileMetaInformationGroupLength is OK."""
        meta = Dataset()
        meta.MediaStorageSOPClassUID = '1.1'
        meta.MediaStorageSOPInstanceUID = '1.2'
        meta.TransferSyntaxUID = '1.3'
        meta.ImplementationClassUID = '1.4'
        _write_file_meta_info(self.fp, meta)

        # 78 in total, - 4 for prefix, - 12 for group length = 62
        self.fp.seek(12)
        self.assertEqual(self.fp.read(4), b'\x3E\x00\x00\x00')
开发者ID:bastula,项目名称:pydicom,代码行数:14,代码来源:test_filewriter.py

示例8: test_prefix

# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import TransferSyntaxUID [as 别名]
    def test_prefix(self):
        """Test that the 'DICM' prefix is present."""
        meta = Dataset()
        meta.MediaStorageSOPClassUID = '1.1'
        meta.MediaStorageSOPInstanceUID = '1.2'
        meta.TransferSyntaxUID = '1.3'
        meta.ImplementationClassUID = '1.4'
        _write_file_meta_info(self.fp, meta)

        self.fp.seek(0)
        prefix = self.fp.read(4)
        self.assertEqual(prefix, b'DICM')
开发者ID:bastula,项目名称:pydicom,代码行数:14,代码来源:test_filewriter.py

示例9: test_missing_elements

# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import TransferSyntaxUID [as 别名]
 def test_missing_elements(self):
     """Test that missing required elements raises ValueError."""
     meta = Dataset()
     self.assertRaises(ValueError, _write_file_meta_info, self.fp, meta)
     meta.MediaStorageSOPClassUID = '1.1'
     self.assertRaises(ValueError, _write_file_meta_info, self.fp, meta)
     meta.MediaStorageSOPInstanceUID = '1.2'
     self.assertRaises(ValueError, _write_file_meta_info, self.fp, meta)
     meta.TransferSyntaxUID = '1.3'
     self.assertRaises(ValueError, _write_file_meta_info, self.fp, meta)
     meta.ImplementationClassUID = '1.4'
     _write_file_meta_info(self.fp, meta)
开发者ID:bastula,项目名称:pydicom,代码行数:14,代码来源:test_filewriter.py

示例10: test_group_length_updated

# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import TransferSyntaxUID [as 别名]
    def test_group_length_updated(self):
        """Test that FileMetaInformationGroupLength gets updated if present."""
        meta = Dataset()
        meta.FileMetaInformationGroupLength = 100 # Actual length
        meta.MediaStorageSOPClassUID = '1.1'
        meta.MediaStorageSOPInstanceUID = '1.2'
        meta.TransferSyntaxUID = '1.3'
        meta.ImplementationClassUID = '1.4'
        _write_file_meta_info(self.fp, meta)

        self.fp.seek(12)
        self.assertEqual(self.fp.read(4), b'\x3E\x00\x00\x00')
        # Check original file meta is unchanged/updated
        self.assertEqual(meta.FileMetaInformationGroupLength, 62)
        self.assertEqual(meta.FileMetaInformationVersion, b'\x00\x01')
        self.assertEqual(meta.MediaStorageSOPClassUID, '1.1')
        self.assertEqual(meta.MediaStorageSOPInstanceUID, '1.2')
        self.assertEqual(meta.TransferSyntaxUID, '1.3')
        self.assertEqual(meta.ImplementationClassUID, '1.4')
开发者ID:bastula,项目名称:pydicom,代码行数:21,代码来源:test_filewriter.py

示例11: read_partial

# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.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.

    Parameters
    ----------
    fileobj : a file-like object
        Note that the file will not close when the function returns.
    stop_when :
        Stop condition. See ``read_dataset`` for more info.
    defer_size : int, str, None, optional
        See ``read_file`` for parameter info.
    force : boolean
        See ``read_file`` for parameter info.

    Notes
    -----
    Use ``read_file`` unless you need to stop on some condition
    other than reaching pixel data.

    Returns
    -------
    FileDataset instance or DicomDir instance.

    See Also
    --------
    read_file
        More generic file reading function.
    """
    # 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 == pydicom.uid.ImplicitVRLittleEndian:
            pass
        elif transfer_syntax == pydicom.uid.ExplicitVRLittleEndian:
            is_implicit_VR = False
        elif transfer_syntax == pydicom.uid.ExplicitVRBigEndian:
            is_implicit_VR = False
            is_little_endian = False
        elif transfer_syntax == pydicom.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 = pydicom.uid.ImplicitVRLittleEndian

    try:
        dataset = read_dataset(fileobj, is_implicit_VR, is_little_endian,
                               stop_when=stop_when, defer_size=defer_size)
    except EOFError:
        pass  # error already logged in read_dataset

    class_uid = file_meta_dataset.get("MediaStorageSOPClassUID", None)
    if class_uid and class_uid == "Media Storage Directory Storage":
        return DicomDir(fileobj, dataset, preamble, file_meta_dataset,
                        is_implicit_VR, is_little_endian)
    else:
        return FileDataset(fileobj, dataset, preamble, file_meta_dataset,
                           is_implicit_VR, is_little_endian)
开发者ID:kaurousseau,项目名称:toad,代码行数:80,代码来源:filereader.py

示例12: read_partial

# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.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.

    Parameters
    ----------
    fileobj : a file-like object
        Note that the file will not close when the function returns.
    stop_when :
        Stop condition. See ``read_dataset`` for more info.
    defer_size : int, str, None, optional
        See ``read_file`` for parameter info.
    force : boolean
        See ``read_file`` for parameter info.

    Notes
    -----
    Use ``read_file`` unless you need to stop on some condition
    other than reaching pixel data.

    Returns
    -------
    FileDataset instance or DicomDir instance.

    See Also
    --------
    read_file
        More generic file reading function.
    """
    # 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.get("TransferSyntaxUID")
        if transfer_syntax is None:  # issue 258
            # Assume and set ImplicitVRLittleEndian transfer syntax
            file_meta_dataset.TransferSyntaxUID = \
                pydicom.uid.ImplicitVRLittleEndian
        elif transfer_syntax == pydicom.uid.ImplicitVRLittleEndian:
            pass
        elif transfer_syntax == pydicom.uid.ExplicitVRLittleEndian:
            is_implicit_VR = False
        elif transfer_syntax == pydicom.uid.ExplicitVRBigEndian:
            is_implicit_VR = False
            is_little_endian = False
        elif transfer_syntax == pydicom.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 = pydicom.uid.ImplicitVRLittleEndian
        endian_chr = "<"
        element_struct = Struct(endian_chr + "HH2sH")
        # Try reading first 8 bytes
        group, elem, VR, length = element_struct.unpack(fileobj.read(8))
        # Rewind file object
        fileobj.seek(0)
        # If the VR is a valid VR, assume Explicit VR transfer systax
        from pydicom.values import converters
        if not in_py2:
            VR = VR.decode(default_encoding)
        if VR in converters.keys():
            is_implicit_VR = False
            # Determine if group in low numbered range (Little vs Big Endian)
            if group == 0:  # got (0,0) group length. Not helpful.
                # XX could use similar to http://www.dclunie.com/medical-image-faq/html/part2.html code example
                msg = ("Not able to guess transfer syntax when first item "
                       "is group length")
                raise NotImplementedError(msg)
            if group < 2000:
                file_meta_dataset.TransferSyntaxUID = pydicom.uid.ExplicitVRLittleEndian
            else:
                file_meta_dataset.TransferSyntaxUID = pydicom.uid.ExplicitVRBigEndian
                is_little_endian = False

    try:
        dataset = read_dataset(fileobj, is_implicit_VR, is_little_endian,
                               stop_when=stop_when, defer_size=defer_size)
    except EOFError:
        pass  # error already logged in read_dataset

    class_uid = file_meta_dataset.get("MediaStorageSOPClassUID", None)
    if class_uid and class_uid == "Media Storage Directory Storage":
#.........这里部分代码省略.........
开发者ID:bastula,项目名称:pydicom,代码行数:103,代码来源:filereader.py

示例13: test_formatted_lines_known_uid

# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import TransferSyntaxUID [as 别名]
 def test_formatted_lines_known_uid(self):
     """Test that the UID name is output when known."""
     ds = Dataset()
     ds.TransferSyntaxUID = '1.2.840.10008.1.2'
     assert 'Implicit VR Little Endian' in str(ds)
开发者ID:kayarre,项目名称:pydicom,代码行数:7,代码来源:test_dataset.py

示例14: create_dicom_base

# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import TransferSyntaxUID [as 别名]
    def create_dicom_base(self):
        if _dicom_loaded is False:
            raise ModuleNotLoadedError("Dicom")
        if self.header_set is False:
            raise InputError("Header not loaded")

        # TODO tags + code datatypes are described here:
        # https://www.dabsoft.ch/dicom/6/6/#(0020,0012)
        # datatype codes are described here:
        # ftp://dicom.nema.org/medical/DICOM/2013/output/chtml/part05/sect_6.2.html

        meta = Dataset()
        meta.MediaStorageSOPClassUID = '1.2.840.10008.5.1.4.1.1.2'  # CT Image Storage
        # Media Storage SOP Instance UID tag 0x0002,0x0003 (type UI - Unique Identifier)
        meta.MediaStorageSOPInstanceUID = self._ct_sop_instance_uid
        meta.ImplementationClassUID = "1.2.3.4"
        meta.TransferSyntaxUID = uid.ImplicitVRLittleEndian  # Implicit VR Little Endian - Default Transfer Syntax
        ds = FileDataset("file", {}, file_meta=meta, preamble=b"\0" * 128)
        ds.PatientName = self.patient_name
        if self.patient_id in (None, ''):
            ds.PatientID = datetime.datetime.today().strftime('%Y%m%d-%H%M%S')
        else:
            ds.PatientID = self.patient_id  # Patient ID tag 0x0010,0x0020 (type LO - Long String)
        ds.PatientSex = ''  # Patient's Sex tag 0x0010,0x0040 (type CS - Code String)
        #                      Enumerated Values: M = male F = female O = other.
        ds.PatientBirthDate = '19010101'
        ds.SpecificCharacterSet = 'ISO_IR 100'
        ds.AccessionNumber = ''
        ds.is_little_endian = True
        ds.is_implicit_VR = True
        ds.SOPClassUID = '1.2.3'  # !!!!!!!!
        # SOP Instance UID tag 0x0008,0x0018 (type UI - Unique Identifier)
        ds.SOPInstanceUID = self._ct_sop_instance_uid

        # Study Instance UID tag 0x0020,0x000D (type UI - Unique Identifier)
        # self._dicom_study_instance_uid may be either set in __init__ when creating new object
        #   or set when import a DICOM file
        #   Study Instance UID for structures is the same as Study Instance UID for CTs
        ds.StudyInstanceUID = self._dicom_study_instance_uid

        # Series Instance UID tag 0x0020,0x000E (type UI - Unique Identifier)
        # self._ct_dicom_series_instance_uid may be either set in __init__ when creating new object
        #   or set when import a DICOM file
        #   Series Instance UID for structures might be different than Series Instance UID for CTs
        ds.SeriesInstanceUID = self._ct_dicom_series_instance_uid

        # Study Instance UID tag 0x0020,0x000D (type UI - Unique Identifier)
        ds.FrameofReferenceUID = '1.2.3'  # !!!!!!!!!
        ds.StudyDate = datetime.datetime.today().strftime('%Y%m%d')
        ds.StudyTime = datetime.datetime.today().strftime('%H%M%S')
        ds.PhotometricInterpretation = 'MONOCHROME2'
        ds.SamplesPerPixel = 1
        ds.ImageOrientationPatient = ['1', '0', '0', '0', '1', '0']
        ds.Rows = self.dimx
        ds.Columns = self.dimy
        ds.SliceThickness = str(self.slice_distance)
        ds.PixelSpacing = [self.pixel_size, self.pixel_size]

        # Add eclipse friendly IDs
        ds.StudyID = '1'  # Study ID tag 0x0020,0x0010 (type SH - Short String)
        ds.ReferringPhysiciansName = 'py^trip'  # Referring Physician's Name tag 0x0008,0x0090 (type PN - Person Name)
        ds.PositionReferenceIndicator = ''  # Position Reference Indicator tag 0x0020,0x1040
        ds.SeriesNumber = '1'  # SeriesNumber tag 0x0020,0x0011 (type IS - Integer String)

        return ds
开发者ID:pytrip,项目名称:pytrip,代码行数:67,代码来源:cube.py

示例15: write_file

# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import TransferSyntaxUID [as 别名]
def write_file(filename, dataset, write_like_original=True):
    """Write `dataset` to the `filename` specified.

    If `write_like_original` is True then `dataset` will be written as is
    (after minimal validation checking) and may or may not contain all or parts
    of the File Meta Information (and hence may or may not be conformant with
    the DICOM File Format).
    If `write_like_original` is False, `dataset` will be stored in the DICOM
    File Format in accordance with DICOM Standard Part 10 Section 7. The byte
    stream of the `dataset` will be placed into the file after the DICOM File
    Meta Information.

    File Meta Information
    ---------------------
    The File Meta Information consists of a 128-byte preamble, followed by a 4
    byte DICOM prefix, followed by the File Meta Information Group elements.

    Preamble and Prefix
    ~~~~~~~~~~~~~~~~~~~
    The `dataset.preamble` attribute shall be 128-bytes long or None and is
    available for use as defined by the Application Profile or specific
    implementations. If the preamble is not used by an Application Profile or
    specific implementation then all 128 bytes should be set to 0x00. The
    actual preamble written depends on `write_like_original` and
    `dataset.preamble` (see the table below).

    +------------------+------------------------------+
    |                  | write_like_original          |
    +------------------+-------------+----------------+
    | dataset.preamble | True        | False          |
    +==================+=============+================+
    | None             | no preamble | 128 0x00 bytes |
    +------------------+------------------------------+
    | 128 bytes        | dataset.preamble             |
    +------------------+------------------------------+

    The prefix shall be the string 'DICM' and will be written if and only if
    the preamble is present.

    File Meta Information Group Elements
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The preamble and prefix are followed by a set of DICOM Elements from the
    (0002,eeee) group. Some of these elements are required (Type 1) while
    others are optional (Type 3/1C). If `write_like_original` is True then the
    File Meta Information Group elements are all optional. See
    pydicom.filewriter.write_file_meta_info for more information on which
    elements are required.

    The File Meta Information Group elements should be included within their
    own Dataset in the `dataset.file_meta` attribute.

    If (0002,0010) 'Transfer Syntax UID' is included then the user must ensure
    it's value is compatible with the values for the `dataset.is_little_endian`
    and `dataset.is_implicit_VR` attributes. For example, if is_little_endian
    and is_implicit_VR are both True then the Transfer Syntax UID must be
    1.2.840.10008.1.2 'Implicit VR Little Endian'. See the DICOM standard
    Part 5 Section 10 for more information on Transfer Syntaxes.

    Encoding
    ~~~~~~~~
    The preamble and prefix are encoding independent. The File Meta Elements
    are encoded as Explicit VR Little Endian as required by the DICOM standard.

    Dataset
    -------
    A DICOM Dataset representing a SOP Instance related to a DICOM Information
    Object Definition. It is up to the user to ensure the `dataset` conforms
    to the DICOM standard.

    Encoding
    ~~~~~~~~
    The `dataset` is encoded as specified by the `dataset.is_little_endian`
    and `dataset.is_implicit_VR` attributes. It's up to the user to ensure
    these attributes are set correctly (as well as setting an appropriate value
    for `dataset.file_meta.TransferSyntaxUID` if present).

    Parameters
    ----------
    filename : str or file-like
        Name of file or the file-like to write the new DICOM file to.
    dataset : pydicom.dataset.FileDataset
        Dataset holding the DICOM information; e.g. an object read with
        pydicom.read_file().
    write_like_original : bool
        If True (default), preserves the following information from
        the Dataset (and may result in a non-conformant file):
        - preamble -- if the original file has no preamble then none will be
            written.
        - file_meta -- if the original file was missing any required File Meta
            Information Group elements then they will not be added or written.
            If (0002,0000) 'File Meta Information Group Length' is present then
            it may have its value updated.
        - seq.is_undefined_length -- if original had delimiters, write them now
            too, instead of the more sensible length characters
        - is_undefined_length_sequence_item -- for datasets that belong to a
            sequence, write the undefined length delimiters if that is
            what the original had.
        If False, produces a file conformant with the DICOM File Format, with
        explicit lengths for all elements.

#.........这里部分代码省略.........
开发者ID:glemaitre,项目名称:pydicom,代码行数:103,代码来源:filewriter.py


注:本文中的pydicom.dataset.Dataset.TransferSyntaxUID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。