本文整理汇总了Python中pydicom.dataset.Dataset.ImplementationClassUID方法的典型用法代码示例。如果您正苦于以下问题:Python Dataset.ImplementationClassUID方法的具体用法?Python Dataset.ImplementationClassUID怎么用?Python Dataset.ImplementationClassUID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pydicom.dataset.Dataset
的用法示例。
在下文中一共展示了Dataset.ImplementationClassUID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_filelike_position
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import ImplementationClassUID [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)
示例2: create_metadata
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import ImplementationClassUID [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
示例3: on_c_store
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import ImplementationClassUID [as 别名]
def on_c_store(dataset):
"""
Function replacing ApplicationEntity.on_store(). Called when a dataset is
received following a C-STORE. Write the received dataset to file
Parameters
----------
dataset - pydicom.Dataset
The DICOM dataset sent via the C-STORE
Returns
-------
status : pynetdicom.SOPclass.Status or int
A valid return status code, see PS3.4 Annex B.2.3 or the
StorageServiceClass implementation for the available statuses
"""
mode_prefix = 'UN'
mode_prefixes = {'CT Image Storage' : 'CT',
'Enhanced CT Image Storage' : 'CTE',
'MR Image Storage' : 'MR',
'Enhanced MR Image Storage' : 'MRE',
'Positron Emission Tomography Image Storage' : 'PT',
'Enhanced PET Image Storage' : 'PTE',
'RT Image Storage' : 'RI',
'RT Dose Storage' : 'RD',
'RT Plan Storage' : 'RP',
'RT Structure Set Storage' : 'RS',
'Computed Radiography Image Storage' : 'CR',
'Ultrasound Image Storage' : 'US',
'Enhanced Ultrasound Image Storage' : 'USE',
'X-Ray Angiographic Image Storage' : 'XA',
'Enhanced XA Image Storage' : 'XAE',
'Nuclear Medicine Image Storage' : 'NM',
'Secondary Capture Image Storage' : 'SC'}
try:
mode_prefix = mode_prefixes[dataset.SOPClassUID.__str__()]
except:
pass
filename = '%s.%s' %(mode_prefix, dataset.SOPInstanceUID)
logger.info('Storing DICOM file: %s' %filename)
if os.path.exists(filename):
logger.warning('DICOM file already exists, overwriting')
meta = Dataset()
meta.MediaStorageSOPClassUID = dataset.SOPClassUID
meta.MediaStorageSOPInstanceUID = dataset.SOPInstanceUID
meta.ImplementationClassUID = pynetdicom_uid_prefix
ds = FileDataset(filename, {}, file_meta=meta, preamble=b"\0" * 128)
ds.update(dataset)
ds.is_little_endian = True
ds.is_implicit_VR = True
ds.save_as(filename)
return 0x0000 # Success
示例4: test_bad_elements
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import ImplementationClassUID [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: test_version
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import ImplementationClassUID [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')
示例6: create_dicom_plan
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import ImplementationClassUID [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
示例7: test_prefix
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import ImplementationClassUID [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')
示例8: test_missing_elements
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import ImplementationClassUID [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)
示例9: test_group_length
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import ImplementationClassUID [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')
示例10: OnReceiveStore
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import ImplementationClassUID [as 别名]
def OnReceiveStore(SOPClass, DS):
#print "Received C-STORE"
# do something with dataset. For instance, store it on disk.
file_meta = Dataset()
file_meta.MediaStorageSOPClassUID = DS.SOPClassUID
file_meta.MediaStorageSOPInstanceUID = "1.2.3" # !! Need valid UID here
file_meta.ImplementationClassUID = "1.2.3.4" # !!! Need valid UIDs here
filename = '%s/%s.dcm' % (tempfile.gettempdir(), DS.SOPInstanceUID)
ds = FileDataset(filename, {}, file_meta=file_meta, preamble="\0" * 128)
ds.update(DS)
ds.is_little_endian = True
ds.is_implicit_VR = True
ds.save_as(filename)
#print "File %s written" % filename
# must return appropriate status
return SOPClass.Success
示例11: test_group_length_updated
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import ImplementationClassUID [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')
示例12: on_c_store
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import ImplementationClassUID [as 别名]
def on_c_store(sop_class, dataset):
"""
Function replacing ApplicationEntity.on_store(). Called when a dataset is
received following a C-STORE. Write the received dataset to file
Parameters
----------
sop_class - pydicom.SOPclass.StorageServiceClass
The StorageServiceClass representing the object
dataset - pydicom.Dataset
The DICOM dataset sent via the C-STORE
Returns
-------
status
A valid return status, see the StorageServiceClass for the
available statuses
"""
filename = 'CT.%s' %dataset.SOPInstanceUID
logger.info('Storing DICOM file: %s' %filename)
if os.path.exists(filename):
logger.warning('DICOM file already exists, overwriting')
#logger.debug("pydicom::Dataset()")
meta = Dataset()
meta.MediaStorageSOPClassUID = dataset.SOPClassUID
meta.MediaStorageSOPInstanceUID = '1.2.3'
meta.ImplementationClassUID = '1.2.3.4'
#logger.debug("pydicom::FileDataset()")
ds = FileDataset(filename, {}, file_meta=meta, preamble=b"\0" * 128)
ds.update(dataset)
ds.is_little_endian = True
ds.is_implicit_VR = True
#logger.debug("pydicom::save_as()")
ds.save_as(filename)
return sop_class.Success
示例13: print
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import ImplementationClassUID [as 别名]
print()
if sys.platform.lower().startswith("win"):
filename = r"c:\temp\test.dcm"
filename2 = r"c:\temp\test-explBig.dcm"
else:
homedir = os.path.expanduser("~")
filename = os.path.join(homedir, "test.dcm")
filename2 = os.path.join(homedir, "test-explBig.dcm")
print("Setting file meta information...")
# Populate required values for file meta information
file_meta = Dataset()
file_meta.MediaStorageSOPClassUID = "1.2.840.10008.5.1.4.1.1.2" # CT Image Storage
file_meta.MediaStorageSOPInstanceUID = "1.2.3" # !! Need valid UID here for real work
file_meta.ImplementationClassUID = "1.2.3.4" # !!! Need valid UIDs here
print("Setting dataset values...")
# Create the FileDataset instance (initially no data elements, but file_meta supplied)
ds = FileDataset(filename, {}, file_meta=file_meta, preamble=b"\0" * 128)
# Add the data elements -- not trying to set all required here. Check DICOM standard
ds.PatientName = "Test^Firstname"
ds.PatientID = "123456"
# Set the transfer syntax
ds.is_little_endian = True
ds.is_implicit_VR = True
print("Writing test file", filename)
示例14: print
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import ImplementationClassUID [as 别名]
import datetime
import pydicom
from pydicom.dataset import Dataset, FileDataset
# Create some temporary filenames
suffix = '.dcm'
filename_little_endian = tempfile.NamedTemporaryFile(suffix=suffix).name
filename_big_endian = tempfile.NamedTemporaryFile(suffix=suffix).name
print("Setting file meta information...")
# Populate required values for file meta information
file_meta = Dataset()
file_meta.MediaStorageSOPClassUID = '1.2.840.10008.5.1.4.1.1.2'
file_meta.MediaStorageSOPInstanceUID = "1.2.3"
file_meta.ImplementationClassUID = "1.2.3.4"
print("Setting dataset values...")
# Create the FileDataset instance (initially no data elements, but file_meta
# supplied)
ds = FileDataset(filename_little_endian, {},
file_meta=file_meta, preamble=b"\0" * 128)
# Add the data elements -- not trying to set all required here. Check DICOM
# standard
ds.PatientName = "Test^Firstname"
ds.PatientID = "123456"
# Set the transfer syntax
ds.is_little_endian = True
ds.is_implicit_VR = True
示例15: on_c_store
# 需要导入模块: from pydicom.dataset import Dataset [as 别名]
# 或者: from pydicom.dataset.Dataset import ImplementationClassUID [as 别名]
def on_c_store(dataset):
"""
Write `dataset` to file as little endian implicit VR
Parameters
----------
dataset - pydicom.Dataset
The DICOM dataset sent via the C-STORE
Returns
-------
status
A valid return status code, see PS3.4 Annex B.2.3 or the
StorageServiceClass implementation for the available statuses
"""
mode_prefix = 'UN'
mode_prefixes = {'CT Image Storage' : 'CT',
'Enhanced CT Image Storage' : 'CTE',
'MR Image Storage' : 'MR',
'Enhanced MR Image Storage' : 'MRE',
'Positron Emission Tomography Image Storage' : 'PT',
'Enhanced PET Image Storage' : 'PTE',
'RT Image Storage' : 'RI',
'RT Dose Storage' : 'RD',
'RT Plan Storage' : 'RP',
'RT Structure Set Storage' : 'RS',
'Computed Radiography Image Storage' : 'CR',
'Ultrasound Image Storage' : 'US',
'Enhanced Ultrasound Image Storage' : 'USE',
'X-Ray Angiographic Image Storage' : 'XA',
'Enhanced XA Image Storage' : 'XAE',
'Nuclear Medicine Image Storage' : 'NM',
'Secondary Capture Image Storage' : 'SC'}
try:
mode_prefix = mode_prefixes[dataset.SOPClassUID.__str__()]
except:
pass
filename = '%s.%s' %(mode_prefix, dataset.SOPInstanceUID)
logger.info('Storing DICOM file: %s' %filename)
if os.path.exists(filename):
logger.warning('DICOM file already exists, overwriting')
meta = Dataset()
meta.MediaStorageSOPClassUID = dataset.SOPClassUID
meta.MediaStorageSOPInstanceUID = dataset.SOPInstanceUID
meta.ImplementationClassUID = pynetdicom_uid_prefix
ds = FileDataset(filename, {}, file_meta=meta, preamble=b"\0" * 128)
ds.update(dataset)
ds.is_little_endian = True
ds.is_implicit_VR = True
if not args.ignore:
# Try to save to output-directory
if args.output_directory is not None:
filename = os.path.join(args.output_directory, filename)
try:
ds.save_as(filename)
except IOError:
logger.error('Could not write file to specified directory:')
logger.error(" %s" %os.path.dirname(filename))
logger.error('Directory may not exist or you may not have write '
'permission')
return 0xA700 # Failed - Out of Resources
except:
logger.error('Could not write file to specified directory:')
logger.error(" %s" %os.path.dirname(filename))
return 0xA700 # Failed - Out of Resources
return 0x0000 # Success