Пример #1
0
def convert_DS_string(byte_string, is_little_endian, struct_format=None):
    """Read and return a DS value or list of values"""
    if in_py3:
        byte_string = byte_string.decode(default_encoding)
    # Below, go directly to DS class instance rather than factory DS,
    # but need to ensure last string doesn't have blank padding (use strip())
    return MultiString(byte_string.strip(), valtype=dicom.valuerep.DSclass)
Пример #2
0
def convert_UI(byte_string, is_little_endian, struct_format=None):
    """Read and return a UI values or values"""
    # Strip off 0-byte padding for even length (if there)
    if in_py3:
        byte_string = byte_string.decode(default_encoding)
    if byte_string and byte_string.endswith('\0'):
        byte_string = byte_string[:-1]
    return MultiString(byte_string, dicom.UID.UID)
Пример #3
0
def convert_string(byte_string,
                   is_little_endian,
                   struct_format=None,
                   encoding=default_encoding):
    """Read and return a string or strings"""
    if in_py3:
        byte_string = byte_string.decode(encoding)
    return MultiString(byte_string)
Пример #4
0
"""
# Copyright (c) 2012 Darcy Mason
# This file is part of pydicom, relased under an MIT-style license.
#    See the file license.txt included with this distribution, also
#    available at http://pydicom.googlecode.com
#

import dicom
# dicom.debug()

from dicom.valuerep import DS, MultiString
from dicom.multival import MultiValue

# print("\n\nTry creating MultiValue directly")
s = r"1.2000\2.30000"
m = MultiString(s, DS)

# print "m=", m
# print "type(m) = ", type(m)
# print "type(m[0]) = ", type(m[0])
# print "m[0].original_string", m[0].original_string

filename = "rtplan.dcm"
print(
    "\n\nTest reading rtplan.dcm and keeping original string for multival DS")
print("---------")
print("First read a file with DS as default float-derived class")
ds = dicom.read_file(filename)
dr = ds.DoseReferenceSequence[0]
drpc0 = dr.DoseReferencePointCoordinates[0]
print("Value of original_string: ".format(drpc0.original_string))
Пример #5
0
def convert_IS_string(byte_string, is_little_endian, struct_format=None):
    """Read and return an IS value or list of values"""
    if in_py3:
        byte_string = byte_string.decode(default_encoding)
    return MultiString(byte_string, valtype=dicom.valuerep.IS)
Пример #6
0
def convert_UI(bytes, is_little_endian, struct_format=None):
    """Read and return a UI values or values"""
    # Strip off 0-byte padding for even length (if there)
    if bytes and bytes.endswith('\0'):
        bytes = bytes[:-1]
    return MultiString(bytes, dicom.UID.UID)
Пример #7
0
def convert_string(bytes, is_little_endian, struct_format=None):
    """Read and return a string or strings"""
    return MultiString(bytes)
Пример #8
0
def convert_PN(bytes, is_little_endian, struct_format=None):
    """Read and return string(s) as PersonName instance(s)"""
    return MultiString(bytes, valtype=PersonName)
Пример #9
0
def convert_IS_string(bytes, is_little_endian, struct_format=None):
    """Read and return an IS value or list of values"""
    return MultiString(bytes, valtype=IS)