本文整理汇总了Python中pydicom.dataset.Dataset.PatientID方法的典型用法代码示例。如果您正苦于以下问题:Python Dataset.PatientID方法的具体用法?Python Dataset.PatientID怎么用?Python Dataset.PatientID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pydicom.dataset.Dataset
的用法示例。
在下文中一共展示了Dataset.PatientID方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_delitem_slice
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import PatientID [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)
示例2: test_conversion_rq
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import PatientID [as 别名]
def test_conversion_rq(self):
""" Check conversion to a -RQ PDU produces the correct output """
primitive = C_MOVE_ServiceParameters()
primitive.MessageID = 7
primitive.AffectedSOPClassUID = '1.2.840.10008.5.1.4.1.1.2'
primitive.Priority = 0x02
primitive.MoveDestination = validate_ae_title("MOVE_SCP")
refIdentifier = Dataset()
refIdentifier.PatientID = '*'
refIdentifier.QueryRetrieveLevel = "PATIENT"
primitive.Identifier = BytesIO(encode(refIdentifier, True, True))
dimse_msg = C_MOVE_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\x62\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\x21\x00\x00\x00\x10\x01\x02\x00\x00' \
b'\x00\x07\x00\x00\x00\x00\x06\x10\x00\x00\x00\x4d\x4f\x56\x45\x5f' \
b'\x53\x43\x50\x20\x20\x20\x20\x20\x20\x20\x20\x00\x00\x00\x07\x02' \
b'\x00\x00\x00\x02\x00\x00\x00\x00\x08\x02\x00\x00\x00\x01\x00'
self.assertEqual(pdvs[0].presentation_data_value_list[0][1], ref)
# Dataset
ref = b'\x02\x08\x00\x52\x00\x08\x00\x00\x00\x50\x41\x54\x49\x45\x4e\x54' \
b'\x20\x10\x00\x20\x00\x02\x00\x00\x00\x2a\x20'
self.assertEqual(pdvs[1].presentation_data_value_list[0][1], ref)
示例3: test_assignment
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import PatientID [as 别名]
def test_assignment(self):
""" Check assignment works correctly """
primitive = C_FIND_ServiceParameters()
primitive.MessageID = 11
self.assertEqual(primitive.MessageID, 11)
primitive.MessageIDBeingRespondedTo = 13
self.assertEqual(primitive.MessageIDBeingRespondedTo, 13)
primitive.AffectedSOPClassUID = '1.2.4.10'
self.assertEqual(primitive.AffectedSOPClassUID, '1.2.4.10')
primitive.Priority = 0x02
self.assertEqual(primitive.Priority, 0x02)
refDataset = Dataset()
refDataset.PatientID = '*'
refDataset.QueryRetrieveLevel = "PATIENT"
primitive.Identifier = BytesIO(encode(refDataset, True, True))
#self.assertEqual(primitive.DataSet, refDataset)
primitive.Status = 0x0000
self.assertEqual(primitive.Status, 0x0000)
primitive.Status = 0xC123
self.assertEqual(primitive.Status, 0xC123)
示例4: test_bad_elements
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import PatientID [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)
示例5: testTagExceptionPrint
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import PatientID [as 别名]
def testTagExceptionPrint(self):
# When printing datasets, a tag number should appear in error
# messages
ds = Dataset()
ds.PatientID = "123456" # Valid value
ds.SmallestImagePixelValue = 0 # Invalid value
if compat.in_PyPy:
expected_msg = "Invalid tag (0028, 0106): 'int' has no length"
else:
expected_msg = "Invalid tag (0028, 0106): object of type 'int' " "has no len()"
self.failUnlessExceptionArgs(expected_msg, TypeError, lambda: str(ds))
示例6: testEqualitySequence
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import PatientID [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.PatientID = '1234'
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'
beam_seq.PatientID = '1234'
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)
示例7: testTagExceptionWalk
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import PatientID [as 别名]
def testTagExceptionWalk(self):
# When recursing through dataset, a tag number should appear in
# error messages
ds = Dataset()
ds.PatientID = "123456" # Valid value
ds.SmallestImagePixelValue = 0 # Invalid value
if compat.in_PyPy:
expected_msg = "Invalid tag (0028, 0106): 'int' has no length"
else:
expected_msg = "Invalid tag (0028, 0106): object of type 'int' " "has no len()"
callback = lambda dataset, data_element: str(data_element)
func = lambda: ds.walk(callback)
self.failUnlessExceptionArgs(expected_msg, TypeError, func)
示例8: testTagExceptionWalk
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import PatientID [as 别名]
def testTagExceptionWalk(self):
# When recursing through dataset, a tag number should appear in
# error messages
ds = Dataset()
ds.PatientID = "123456" # Valid value
ds.SmallestImagePixelValue = 0 # Invalid value
if compat.in_PyPy:
expected_msg = ("With tag (0028, 0106) got exception: "
"'int' has no length")
else:
expected_msg = ("With tag (0028, 0106) got exception: "
"object of type 'int' has no len()")
def callback(dataset, data_element):
return str(data_element)
def func(dataset=ds):
return dataset.walk(callback)
self.failUnlessExceptionArgs(expected_msg, TypeError, func)
示例9: test_conversion_rsp
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import PatientID [as 别名]
def test_conversion_rsp(self):
""" Check conversion to a -RSP PDU produces the correct output """
primitive = C_MOVE_ServiceParameters()
primitive.MessageIDBeingRespondedTo = 5
primitive.AffectedSOPClassUID = '1.2.840.10008.5.1.4.1.1.2'
primitive.Status = 0xFF00
primitive.NumberOfRemainingSuboperations = 3
primitive.NumberOfCompletedSuboperations = 1
primitive.NumberOfFailedSuboperations = 2
primitive.NumberOfWarningSuboperations = 4
refIdentifier = Dataset()
refIdentifier.QueryRetrieveLevel = "PATIENT"
refIdentifier.PatientID = "*"
primitive.Identifier = BytesIO(encode(refIdentifier, True, True))
dimse_msg = C_MOVE_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\x72\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\x21\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\x00\x00\x20\x10\x02\x00\x00\x00\x03' \
b'\x00\x00\x00\x21\x10\x02\x00\x00\x00\x01\x00\x00\x00\x22\x10\x02' \
b'\x00\x00\x00\x02\x00\x00\x00\x23\x10\x02\x00\x00\x00\x04\x00'
self.assertEqual(pdvs[0].presentation_data_value_list[0][1], ref)
# Data Set
ref = b'\x02\x08\x00\x52\x00\x08\x00\x00\x00\x50\x41\x54\x49\x45\x4e\x54' \
b'\x20\x10\x00\x20\x00\x02\x00\x00\x00\x2a\x20'
self.assertEqual(pdvs[1].presentation_data_value_list[0][1], ref)
示例10: Dataset
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import PatientID [as 别名]
# create association with remote AE
print "Request association"
assoc = MyAE.RequestAssociation(RemoteAE)
# perform a DICOM ECHO
print "DICOM Echo ... ",
st = assoc.VerificationSOPClass.SCU(1)
print 'done with status "%s"' % st
print "DICOM FindSCU ... ",
d = Dataset()
d.PatientsName = args.searchstring
d.QueryRetrieveLevel = "PATIENT"
d.PatientID = "*"
st = assoc.PatientRootFindSOPClass.SCU(d, 1)
print 'done with status "%s"' % st
for ss in st:
if not ss[1]:
continue
# print ss[1]
try:
d.PatientID = ss[1].PatientID
except:
continue
print "Moving"
print d
assoc2 = MyAE.RequestAssociation(RemoteAE)
gen = assoc2.PatientRootMoveSOPClass.SCU(d, 'PYNETDICOM', 1)
示例11: test_getitem_slice
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import PatientID [as 别名]
def test_getitem_slice(self):
"""Test Dataset.__getitem__ 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'
# Slice all items - should return original dataset
self.assertEqual(ds[:], ds)
# Slice starting from and including (0008,0001)
test_ds = ds[0x00080001:]
self.assertFalse('CommandGroupLength' in test_ds)
self.assertFalse('CommandLengthToEnd' in test_ds)
self.assertFalse('Overlays' in test_ds)
self.assertTrue('LengthToEnd' in test_ds)
self.assertTrue('BeamSequence' in test_ds)
# Slice ending at and not including (0009,0002)
test_ds = ds[:0x00090002]
self.assertTrue('CommandGroupLength' in test_ds)
self.assertTrue('CommandLengthToEnd' in test_ds)
self.assertTrue('Overlays' in test_ds)
self.assertTrue('LengthToEnd' in test_ds)
self.assertTrue(0x00090001 in test_ds)
self.assertFalse(0x00090002 in test_ds)
self.assertFalse('BeamSequence' in test_ds)
# Slice with a step - every second tag
# Should return zeroth tag, then second, fourth, etc...
test_ds = ds[::2]
self.assertTrue('CommandGroupLength' in test_ds)
self.assertFalse('CommandLengthToEnd' in test_ds)
self.assertTrue(0x00090001 in test_ds)
self.assertFalse(0x00090002 in test_ds)
# Slice starting at and including (0008,0018) and ending at and not
# including (0009,0008)
test_ds = ds[0x00080018:0x00090008]
self.assertTrue('SOPInstanceUID' in test_ds)
self.assertTrue(0x00090007 in test_ds)
self.assertFalse(0x00090008 in test_ds)
# Slice starting at and including (0008,0018) and ending at and not
# including (0009,0008), every third element
test_ds = ds[0x00080018:0x00090008:3]
self.assertTrue('SOPInstanceUID' in test_ds)
self.assertFalse(0x00090001 in test_ds)
self.assertTrue(0x00090002 in test_ds)
self.assertFalse(0x00090003 in test_ds)
self.assertFalse(0x00090004 in test_ds)
self.assertTrue(0x00090005 in test_ds)
self.assertFalse(0x00090006 in test_ds)
self.assertFalse(0x00090008 in test_ds)
# Slice starting and ending (and not including) (0008,0018)
self.assertEqual(
ds[(0x0008, 0x0018):(0x0008, 0x0018)],
Dataset())
# Test slicing using other acceptable Tag initialisations
self.assertTrue(
'SOPInstanceUID' in ds[(0x00080018):(0x00080019)])
self.assertTrue(
'SOPInstanceUID' in ds[(0x0008, 0x0018):(0x0008, 0x0019)])
self.assertTrue(
'SOPInstanceUID' in ds['0x00080018':'0x00080019'])