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


Python DicomBytesIO.is_little_endian方法代码示例

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


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

示例1: test_charset_patient_names

# 需要导入模块: from pydicom.filebase import DicomBytesIO [as 别名]
# 或者: from pydicom.filebase.DicomBytesIO import is_little_endian [as 别名]
    def test_charset_patient_names(self, filename, patient_name):
        """Test patient names are correctly decoded and encoded."""
        # check that patient names are correctly read
        file_path = get_charset_files(filename + '.dcm')[0]
        ds = dcmread(file_path)
        ds.decode()
        assert patient_name == ds.PatientName

        # check that patient names are correctly written back
        fp = DicomBytesIO()
        fp.is_implicit_VR = False
        fp.is_little_endian = True
        ds.save_as(fp, write_like_original=False)
        fp.seek(0)
        ds = dcmread(fp)
        assert patient_name == ds.PatientName

        # check that patient names are correctly written back
        # without original byte string (PersonName3 only)
        if hasattr(ds.PatientName, 'original_string'):
            ds.PatientName.original_string = None
            fp = DicomBytesIO()
            fp.is_implicit_VR = False
            fp.is_little_endian = True
            ds.save_as(fp, write_like_original=False)
            fp.seek(0)
            ds = dcmread(fp)
            assert patient_name == ds.PatientName
开发者ID:scaramallion,项目名称:pydicom,代码行数:30,代码来源:test_charset.py

示例2: test_write_tag

# 需要导入模块: from pydicom.filebase import DicomBytesIO [as 别名]
# 或者: from pydicom.filebase.DicomBytesIO import is_little_endian [as 别名]
    def test_write_tag(self):
        """Test DicomIO.write_tag indirectly"""
        tag = Tag(0x01020304)

        # Little endian
        fp = DicomBytesIO()
        fp.is_little_endian = True
        fp.write_tag(tag)
        assert fp.getvalue() == b'\x02\x01\x04\x03'

        # Big endian
        fp = DicomBytesIO()
        fp.is_little_endian = False
        fp.write_tag(tag)
        assert fp.getvalue() == b'\x01\x02\x03\x04'
开发者ID:jrkerns,项目名称:pydicom,代码行数:17,代码来源:test_filebase.py

示例3: test_zero_length

# 需要导入模块: from pydicom.filebase import DicomBytesIO [as 别名]
# 或者: from pydicom.filebase.DicomBytesIO import is_little_endian [as 别名]
 def test_zero_length(self):
     """Test reading BOT with zero length"""
     bytestream = b'\xFE\xFF\x00\xE0' \
                  b'\x00\x00\x00\x00'
     fp = DicomBytesIO(bytestream)
     fp.is_little_endian = True
     assert [0] == get_frame_offsets(fp)
开发者ID:kayarre,项目名称:pydicom,代码行数:9,代码来源:test_encaps.py

示例4: test_read_be_tag

# 需要导入模块: from pydicom.filebase import DicomBytesIO [as 别名]
# 或者: from pydicom.filebase.DicomBytesIO import is_little_endian [as 别名]
 def test_read_be_tag(self):
     """Test DicomIO.read_be_tag indirectly"""
     # Tags are 2 + 2 = 4 bytes
     bytestream = b'\x01\x02\x03\x04\x05\x06'
     fp = DicomBytesIO(bytestream)
     fp.is_little_endian = False
     assert Tag(fp.read_be_tag()) == 0x01020304
开发者ID:jrkerns,项目名称:pydicom,代码行数:9,代码来源:test_filebase.py

示例5: encode

# 需要导入模块: from pydicom.filebase import DicomBytesIO [as 别名]
# 或者: from pydicom.filebase.DicomBytesIO import is_little_endian [as 别名]
def encode(ds, is_implicit_VR, is_little_endian):
    """
    Given a pydicom Dataset, encode it to a byte stream
    
    Parameters
    ----------
    ds - pydicom.dataset.Dataset
        The dataset to encode
    is_implicit_VR - bool
        Transfer syntax implicit/explicit VR
    is_little_endian - bool
        Transfer syntax byte ordering
    
    Returns
    -------
    bytes or None
        The encoded dataset (if successful), None if encoding failed.
    """
    f = DicomBytesIO()
    f.is_implicit_VR = is_implicit_VR
    f.is_little_endian = is_little_endian
    try:
        write_dataset(f, ds)
    except Exception as e:
        logger.error("pydicom.write_dataset() failed:")
        logger.error(e)
        f.close()
        return None
    
    rawstr = f.parent.getvalue()
    f.close()
    return rawstr
开发者ID:scaramallion,项目名称:pynetdicom,代码行数:34,代码来源:dsutils.py

示例6: test_deferred_data_element_deprecated

# 需要导入模块: from pydicom.filebase import DicomBytesIO [as 别名]
# 或者: from pydicom.filebase.DicomBytesIO import is_little_endian [as 别名]
def test_deferred_data_element_deprecated():
    """Test the deprecation warning is working"""
    fp = DicomBytesIO()
    fp.is_little_endian = True
    fp.is_implicit_VR = True
    with pytest.deprecated_call():
        elem = DeferredDataElement(0x00000000, 'UL', fp, 0, 0, 4)
开发者ID:kayarre,项目名称:pydicom,代码行数:9,代码来源:test_dataelem.py

示例7: test_encapsulate_single_fragment_per_frame_bot

# 需要导入模块: from pydicom.filebase import DicomBytesIO [as 别名]
# 或者: from pydicom.filebase.DicomBytesIO import is_little_endian [as 别名]
    def test_encapsulate_single_fragment_per_frame_bot(self):
        """Test encapsulating single fragment per frame with BOT values."""
        ds = dcmread(JP2K_10FRAME_NOBOT)
        frames = decode_data_sequence(ds.PixelData)
        assert len(frames) == 10

        data = encapsulate(frames, fragments_per_frame=1, has_bot=True)
        test_frames = decode_data_sequence(data)
        for a, b in zip(test_frames, frames):
            assert a == b

        fp = DicomBytesIO(data)
        fp.is_little_endian = True
        offsets = get_frame_offsets(fp)
        assert offsets == [
            0x0000,  # 0
            0x0eee,  # 3822
            0x1df6,  # 7670
            0x2cf8,  # 11512
            0x3bfc,  # 15356
            0x4ade,  # 19166
            0x59a2,  # 22946
            0x6834,  # 26676
            0x76e2,  # 30434
            0x8594  # 34196
        ]
开发者ID:darcymason,项目名称:pydicom,代码行数:28,代码来源:test_encaps.py

示例8: encode

# 需要导入模块: from pydicom.filebase import DicomBytesIO [as 别名]
# 或者: from pydicom.filebase.DicomBytesIO import is_little_endian [as 别名]
def encode(ds, is_implicit_VR, is_little_endian):
    f = DicomBytesIO()
    f.is_implicit_VR = is_implicit_VR
    f.is_little_endian = is_little_endian
    write_dataset(f, ds)
    rawstr = f.parent.getvalue()
    f.close()
    return rawstr
开发者ID:efflicto,项目名称:pynetdicom,代码行数:10,代码来源:dsutils.py

示例9: test_single_fragment_no_delimiter

# 需要导入模块: from pydicom.filebase import DicomBytesIO [as 别名]
# 或者: from pydicom.filebase.DicomBytesIO import is_little_endian [as 别名]
 def test_single_fragment_no_delimiter(self):
     """Test single fragment is returned OK"""
     bytestream = b'\xFE\xFF\x00\xE0' \
                  b'\x04\x00\x00\x00' \
                  b'\x01\x00\x00\x00'
     fp = DicomBytesIO(bytestream)
     fp.is_little_endian = True
     assert read_item(fp) == b'\x01\x00\x00\x00'
开发者ID:kayarre,项目名称:pydicom,代码行数:10,代码来源:test_encaps.py

示例10: test_read_exact_length_raises

# 需要导入模块: from pydicom.filebase import DicomBytesIO [as 别名]
# 或者: from pydicom.filebase.DicomBytesIO import is_little_endian [as 别名]
 def test_read_exact_length_raises(self):
     """Test DicomIO.read exact length raises if short"""
     fp = DicomBytesIO(b'\x00\x01\x03')
     fp.is_little_endian = True
     with pytest.raises(EOFError,
                        match="Unexpected end of file. Read 3 bytes of 4 "
                              "expected starting at position 0x0"):
         fp.read(length=4, need_exact_length=True)
开发者ID:jrkerns,项目名称:pydicom,代码行数:10,代码来源:test_filebase.py

示例11: encode_element

# 需要导入模块: from pydicom.filebase import DicomBytesIO [as 别名]
# 或者: from pydicom.filebase.DicomBytesIO import is_little_endian [as 别名]
def encode_element(el, is_implicit_VR, is_little_endian):
    f = DicomBytesIO()
    f.is_implicit_VR = is_implicit_VR
    f.is_little_endian = is_little_endian
    write_data_element(f, el)
    rawstr = f.parent.getvalue()
    f.close()
    return rawstr
开发者ID:scaramallion,项目名称:pynetdicom,代码行数:10,代码来源:dsutils.py

示例12: test_single_frame

# 需要导入模块: from pydicom.filebase import DicomBytesIO [as 别名]
# 或者: from pydicom.filebase.DicomBytesIO import is_little_endian [as 别名]
 def test_single_frame(self):
     """Test reading single-frame BOT item"""
     bytestream = b'\xFE\xFF\x00\xE0' \
                  b'\x04\x00\x00\x00' \
                  b'\x00\x00\x00\x00'
     fp = DicomBytesIO(bytestream)
     fp.is_little_endian = True
     assert [0] == get_frame_offsets(fp)
开发者ID:kayarre,项目名称:pydicom,代码行数:10,代码来源:test_encaps.py

示例13: test_read_le_ul

# 需要导入模块: from pydicom.filebase import DicomBytesIO [as 别名]
# 或者: from pydicom.filebase.DicomBytesIO import is_little_endian [as 别名]
 def test_read_le_ul(self):
     """Test DicomIO.read_leUL indirectly"""
     # UL are 4 bytes fixed
     bytestream = b'\x00\x00\x00\x00\xFF\xFF\x00\x00\xFE\xFF\xFF\xFF'
     fp = DicomBytesIO(bytestream)
     fp.is_little_endian = True
     assert fp.read_leUL() == 0
     assert fp.read_leUL() == 0xFFFF
     assert fp.read_leUL() == 0xFFFFFFFE
开发者ID:jrkerns,项目名称:pydicom,代码行数:11,代码来源:test_filebase.py

示例14: test_read_be_us

# 需要导入模块: from pydicom.filebase import DicomBytesIO [as 别名]
# 或者: from pydicom.filebase.DicomBytesIO import is_little_endian [as 别名]
 def test_read_be_us(self):
     """Test DicomIO.read_beUS indirectly"""
     # US are 2 bytes fixed
     bytestream = b'\x00\x00\x00\xFF\xFF\xFE'
     fp = DicomBytesIO(bytestream)
     fp.is_little_endian = True
     assert fp.read_beUS() == 0
     assert fp.read_beUS() == 255
     assert fp.read_beUS() == 0xFFFE
开发者ID:jrkerns,项目名称:pydicom,代码行数:11,代码来源:test_filebase.py

示例15: test_not_little_endian

# 需要导入模块: from pydicom.filebase import DicomBytesIO [as 别名]
# 或者: from pydicom.filebase.DicomBytesIO import is_little_endian [as 别名]
 def test_not_little_endian(self):
     """Test reading big endian raises exception"""
     bytestream = b'\xFE\xFF\x00\xE0' \
                  b'\x00\x00\x00\x00'
     fp = DicomBytesIO(bytestream)
     fp.is_little_endian = False
     with pytest.raises(ValueError,
                        match="'fp.is_little_endian' must be True"):
         get_frame_offsets(fp)
开发者ID:kayarre,项目名称:pydicom,代码行数:11,代码来源:test_encaps.py


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