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


Python Dataset.PatientName方法代码示例

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


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

示例1: testEqualitySequence

# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import PatientName [as 别名]
    def testEqualitySequence(self):
        """Dataset: equality returns correct value when dataset has sequences"""
        # Test even sequences
        d = Dataset()
        d.SOPInstanceUID = "1.2.3.4"
        d.BeamSequence = []
        beam_seq = Dataset()
        beam_seq.PatientName = "ANON"
        d.BeamSequence.append(beam_seq)
        self.assertTrue(d == d)

        e = Dataset()
        e.SOPInstanceUID = "1.2.3.4"
        e.BeamSequence = []
        beam_seq = Dataset()
        beam_seq.PatientName = "ANON"
        e.BeamSequence.append(beam_seq)
        self.assertTrue(d == e)

        e.BeamSequence[0].PatientName = "ANONY"
        self.assertFalse(d == e)

        # Test uneven sequences
        e.BeamSequence[0].PatientName = "ANON"
        self.assertTrue(d == e)

        e.BeamSequence.append(beam_seq)
        self.assertFalse(d == e)

        d.BeamSequence.append(beam_seq)
        self.assertTrue(d == e)
        d.BeamSequence.append(beam_seq)
        self.assertFalse(d == e)
开发者ID:DimitriPapadopoulos,项目名称:pydicom,代码行数:35,代码来源:test_dataset.py

示例2: test_equality_elements

# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import PatientName [as 别名]
    def test_equality_elements(self):
        """Test that Dataset equality only checks DataElements."""
        d = Dataset()
        d.SOPInstanceUID = '1.2.3.4'
        d.PatientName = 'Test'
        d.foo = 'foo'
        assert d == d

        e = Dataset()
        e.PatientName = 'Test'
        e.SOPInstanceUID = '1.2.3.4'
        assert d == e
开发者ID:kayarre,项目名称:pydicom,代码行数:14,代码来源:test_dataset.py

示例3: test_conversion_rsp

# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import PatientName [as 别名]
 def test_conversion_rsp(self):
     """ Check conversion to a -RSP PDU produces the correct output """
     primitive = C_FIND_ServiceParameters()
     primitive.MessageIDBeingRespondedTo = 5
     primitive.AffectedSOPClassUID = '1.2.840.10008.5.1.4.1.1.2'
     primitive.Status = 0xFF00
     
     refIdentifier = Dataset()
     refIdentifier.QueryRetrieveLevel = "PATIENT"
     refIdentifier.RetrieveAETitle = validate_ae_title("FINDSCP")
     refIdentifier.PatientName = "ANON^A^B^C^D"
     
     primitive.Identifier = BytesIO(encode(refIdentifier, True, True))
     
     dimse_msg = C_FIND_RSP()
     dimse_msg.primitive_to_message(primitive)
     
     pdvs = dimse_msg.Encode(1, 16382)
     
     # Command Set
     ref = b'\x03\x00\x00\x00\x00\x04\x00\x00\x00\x4a\x00\x00\x00\x00\x00\x02' \
           b'\x00\x1a\x00\x00\x00\x31\x2e\x32\x2e\x38\x34\x30\x2e\x31\x30\x30' \
           b'\x30\x38\x2e\x35\x2e\x31\x2e\x34\x2e\x31\x2e\x31\x2e\x32\x00\x00' \
           b'\x00\x00\x01\x02\x00\x00\x00\x20\x80\x00\x00\x20\x01\x02\x00\x00' \
           b'\x00\x05\x00\x00\x00\x00\x08\x02\x00\x00\x00\x01\x00\x00\x00\x00' \
           b'\x09\x02\x00\x00\x00\x00\xff'
     self.assertEqual(pdvs[0].presentation_data_value_list[0][1], ref)
     
     ref = b'\x02\x08\x00\x52\x00\x08\x00\x00\x00\x50\x41\x54\x49\x45\x4e\x54' \
           b'\x20\x08\x00\x54\x00\x10\x00\x00\x00\x46\x49\x4e\x44\x53\x43\x50' \
           b'\x20\x20\x20\x20\x20\x20\x20\x20\x20\x10\x00\x10\x00\x0c\x00\x00' \
           b'\x00\x41\x4e\x4f\x4e\x5e\x41\x5e\x42\x5e\x43\x5e\x44'
     self.assertEqual(pdvs[1].presentation_data_value_list[0][1], ref)
开发者ID:scaramallion,项目名称:pynetdicom,代码行数:35,代码来源:test_dimse_c.py

示例4: test_delitem_slice

# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import PatientName [as 别名]
    def test_delitem_slice(self):
        """Test Dataset.__delitem__ using slices."""
        ds = Dataset()
        ds.CommandGroupLength = 120  # 0000,0000
        ds.CommandLengthToEnd = 111  # 0000,0001
        ds.Overlays = 12  # 0000,51B0
        ds.LengthToEnd = 12  # 0008,0001
        ds.SOPInstanceUID = '1.2.3.4'  # 0008,0018
        ds.SkipFrameRangeFlag = 'TEST'  # 0008,9460
        ds.add_new(0x00090001, 'PN', 'CITIZEN^1')
        ds.add_new(0x00090002, 'PN', 'CITIZEN^2')
        ds.add_new(0x00090003, 'PN', 'CITIZEN^3')
        ds.add_new(0x00090004, 'PN', 'CITIZEN^4')
        ds.add_new(0x00090005, 'PN', 'CITIZEN^5')
        ds.add_new(0x00090006, 'PN', 'CITIZEN^6')
        ds.add_new(0x00090007, 'PN', 'CITIZEN^7')
        ds.add_new(0x00090008, 'PN', 'CITIZEN^8')
        ds.add_new(0x00090009, 'PN', 'CITIZEN^9')
        ds.add_new(0x00090010, 'PN', 'CITIZEN^10')
        ds.PatientName = 'CITIZEN^Jan'  # 0010,0010
        ds.PatientID = '12345'  # 0010,0010
        ds.ExaminedBodyThickness = 1.223  # 0010,9431
        ds.BeamSequence = [Dataset()]  # 300A,00B0
        ds.BeamSequence[0].PatientName = 'ANON'

        # Delete the 0x0009 group
        del ds[0x00090000:0x00100000]
        self.assertTrue('SkipFrameRangeFlag' in ds)
        self.assertFalse(0x00090001 in ds)
        self.assertFalse(0x00090010 in ds)
        self.assertTrue('PatientName' in ds)
开发者ID:moloney,项目名称:pydicom,代码行数:33,代码来源:test_dataset.py

示例5: test_save_as

# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import PatientName [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)
开发者ID:moloney,项目名称:pydicom,代码行数:33,代码来源:test_dataset.py

示例6: test_top

# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import PatientName [as 别名]
 def test_top(self):
     """Test Dataset.top returns only top level str"""
     ds = Dataset()
     ds.PatientName = 'CITIZEN^Jan'
     ds.BeamSequence = [Dataset()]
     ds.BeamSequence[0].PatientID = 'JAN^Citizen'
     assert "Patient's Name" in ds.top()
     assert "Patient ID" not in ds.top()
开发者ID:moloney,项目名称:pydicom,代码行数:10,代码来源:test_dataset.py

示例7: test_creation_with_container

# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import PatientName [as 别名]
    def test_creation_with_container(self):
        """FileDataset.__init__ works OK with a container such as gzip"""
        class Dummy(object):
            filename = '/some/path/to/test'

        ds = Dataset()
        ds.PatientName = "CITIZEN^Jan"
        fds = FileDataset(Dummy(), ds)
        assert fds.filename == '/some/path/to/test'
开发者ID:moloney,项目名称:pydicom,代码行数:11,代码来源:test_dataset.py

示例8: on_c_find

# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import PatientName [as 别名]
def on_c_find(dataset):
    basedir = "../test/dicom_files/"
    dcm_files = ["CTImageStorage.dcm"]
    dcm_files = [os.path.join(basedir, x) for x in dcm_files]
    for dcm in dcm_files:
        data = read_file(dcm, force=True)

        d = Dataset()
        d.QueryRetrieveLevel = dataset.QueryRetrieveLevel
        d.RetrieveAETitle = args.aetitle
        d.PatientName = data.PatientName
        yield d
开发者ID:scaramallion,项目名称:pynetdicom,代码行数:14,代码来源:findscp.py

示例9: testEqualityNoSequence

# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import PatientName [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
开发者ID:kayarre,项目名称:pydicom,代码行数:42,代码来源:test_dataset.py

示例10: test_remove_private_tags

# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import PatientName [as 别名]
    def test_remove_private_tags(self):
        """Test Dataset.remove_private_tags"""
        ds = Dataset()
        ds.CommandGroupLength = 120  # 0000,0000
        ds.SkipFrameRangeFlag = 'TEST'  # 0008,9460
        ds.add_new(0x00090001, 'PN', 'CITIZEN^1')
        ds.add_new(0x00090010, 'PN', 'CITIZEN^10')
        ds.PatientName = 'CITIZEN^Jan'  # 0010,0010

        ds.remove_private_tags()
        self.assertEqual(ds[0x00090000:0x00100000], Dataset())
        self.assertTrue('CommandGroupLength' in ds)
        self.assertTrue('SkipFrameRangeFlag' in ds)
        self.assertTrue('PatientName' in ds)
开发者ID:moloney,项目名称:pydicom,代码行数:16,代码来源:test_dataset.py

示例11: testEqualityNoSequence

# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import PatientName [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)
开发者ID:moloney,项目名称:pydicom,代码行数:39,代码来源:test_dataset.py

示例12: testEqualityInheritance

# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import PatientName [as 别名]
    def testEqualityInheritance(self):
        """Dataset: equality returns correct value for subclass """

        class DatasetPlus(Dataset):
            pass

        d = Dataset()
        d.PatientName = "ANON"
        e = DatasetPlus()
        e.PatientName = "ANON"
        self.assertTrue(d == e)
        self.assertTrue(e == d)
        self.assertTrue(e == e)

        e.PatientName = "ANONY"
        self.assertFalse(d == e)
        self.assertFalse(e == d)
开发者ID:DimitriPapadopoulos,项目名称:pydicom,代码行数:19,代码来源:test_dataset.py

示例13: test_walk

# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import PatientName [as 别名]
    def test_walk(self):
        """Test Dataset.walk iterates through sequences"""
        def test_callback(dataset, elem):
            if elem.keyword is 'PatientID':
                dataset.PatientID = 'FIXED'

        ds = Dataset()
        ds.PatientName = 'CITIZEN^Jan'
        ds.BeamSequence = [Dataset(), Dataset()]
        ds.BeamSequence[0].PatientID = 'JAN^Citizen^Snr'
        ds.BeamSequence[0].PatientName = 'Some^Name'
        ds.BeamSequence[1].PatientID = 'JAN^Citizen^Jr'
        ds.BeamSequence[1].PatientName = 'Other^Name'
        ds.walk(test_callback, recursive=True)

        assert ds.PatientName == 'CITIZEN^Jan'
        assert ds.BeamSequence[0].PatientID == 'FIXED'
        assert ds.BeamSequence[0].PatientName == 'Some^Name'
        assert ds.BeamSequence[1].PatientID == 'FIXED'
        assert ds.BeamSequence[1].PatientName == 'Other^Name'
开发者ID:moloney,项目名称:pydicom,代码行数:22,代码来源:test_dataset.py

示例14: test_formatted_lines

# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import PatientName [as 别名]
    def test_formatted_lines(self):
        """Test Dataset.formatted_lines"""
        ds = Dataset()
        with pytest.raises(StopIteration):
            next(ds.formatted_lines())
        ds.PatientName = 'CITIZEN^Jan'
        ds.BeamSequence = [Dataset()]
        ds.BeamSequence[0].PatientID = 'JAN^Citizen'
        elem_format = "%(tag)s"
        seq_format = "%(name)s %(tag)s"
        indent_format = ">>>"  # placeholder for future functionality

        line_generator = ds.formatted_lines(element_format=elem_format,
                                            sequence_element_format=seq_format,
                                            indent_format=indent_format)
        assert next(line_generator) == "(0010, 0010)"
        assert next(line_generator) == "Beam Sequence (300a, 00b0)"
        assert next(line_generator) == "(0010, 0020)"
        with pytest.raises(StopIteration):
            next(line_generator)
开发者ID:moloney,项目名称:pydicom,代码行数:22,代码来源:test_dataset.py

示例15: test_conversion_rq

# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import PatientName [as 别名]
 def test_conversion_rq(self):
     """ Check conversion to a -RQ PDU produces the correct output """
     primitive = C_STORE_ServiceParameters()
     primitive.MessageID = 7
     primitive.AffectedSOPClassUID = '1.2.840.10008.5.1.4.1.1.2'
     primitive.AffectedSOPInstanceUID = '1.2.392.200036.9116.2.6.1.48.1215709044.1459316254.522441'
     primitive.Priority = 0x02
     primitive.MoveOriginatorApplicationEntityTitle = 'UNITTEST_SCP'
     primitive.MoveOriginatorMessageID = 3
     
     refDataset = Dataset()
     refDataset.PatientID = 'Test1101'
     refDataset.PatientName = "Tube HeNe"
     
     primitive.DataSet = BytesIO(encode(refDataset, True, True))
     
     dimse_msg = C_STORE_RQ()
     dimse_msg.primitive_to_message(primitive)
     
     pdvs = dimse_msg.Encode(1, 16382)
         
     # Command Set
     ref = b'\x03\x00\x00\x00\x00\x04\x00\x00\x00\xae\x00\x00\x00\x00\x00\x02' \
           b'\x00\x1a\x00\x00\x00\x31\x2e\x32\x2e\x38\x34\x30\x2e\x31\x30\x30' \
           b'\x30\x38\x2e\x35\x2e\x31\x2e\x34\x2e\x31\x2e\x31\x2e\x32\x00\x00' \
           b'\x00\x00\x01\x02\x00\x00\x00\x01\x00\x00\x00\x10\x01\x02\x00\x00' \
           b'\x00\x07\x00\x00\x00\x00\x07\x02\x00\x00\x00\x02\x00\x00\x00\x00' \
           b'\x08\x02\x00\x00\x00\x01\x00\x00\x00\x00\x10\x3a\x00\x00\x00\x31' \
           b'\x2e\x32\x2e\x33\x39\x32\x2e\x32\x30\x30\x30\x33\x36\x2e\x39\x31' \
           b'\x31\x36\x2e\x32\x2e\x36\x2e\x31\x2e\x34\x38\x2e\x31\x32\x31\x35' \
           b'\x37\x30\x39\x30\x34\x34\x2e\x31\x34\x35\x39\x33\x31\x36\x32\x35' \
           b'\x34\x2e\x35\x32\x32\x34\x34\x31\x00\x00\x00\x30\x10\x10\x00\x00' \
           b'\x00\x55\x4e\x49\x54\x54\x45\x53\x54\x5f\x53\x43\x50\x20\x20\x20' \
           b'\x20\x00\x00\x31\x10\x02\x00\x00\x00\x03\x00'
     self.assertEqual(pdvs[0].presentation_data_value_list[0][1], ref)
     
     # Dataset
     ref = b'\x02\x10\x00\x10\x00\x0a\x00\x00\x00\x54\x75\x62\x65\x20\x48\x65' \
           b'\x4e\x65\x20\x10\x00\x20\x00\x08\x00\x00\x00\x54\x65\x73\x74\x31' \
           b'\x31\x30\x31'
     self.assertEqual(pdvs[1].presentation_data_value_list[0][1], ref)
开发者ID:scaramallion,项目名称:pynetdicom,代码行数:43,代码来源:test_dimse_c.py


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