Пример #1
0
def define_structure_attributes():
    '''Create a dictionary with Type Variable values that define all of the structure attributes.
    The attributes:
        EUDAlpha
        TCPAlpha
        TCPBeta and
        TCPGamma
        Are supplied but not used,
        the add_structure method forces them to be: 'xsi:nil="true"'
    '''
    var_type = 'Structure'
    is_string = lambda x: isinstance(x, str)
    id_check = lambda x: is_string(x) and len(x) < 13
    # TODO Merge with define_structure_table from update_template_list
    # TODO more attribute checks should be added to the attribute definitions

    structure_def = [('StructureID', id_check, None), \
                     ('Name', is_string, ''), \
                     ('StructureCategory', is_string, ''), \
                     ('VolumeID', None, ''), \
                     ('VolumeType', is_string, ''), \
                     ('VolumeCode', is_string, ''), \
                     ('VolumeCodeTable', is_string, ''), \
                     ('Label', is_string, None), \
                     ('StructureCode', None, None), \
                     ('CodeScheme', is_string, None), \
                     ('CodeSchemeVersion', None, None), \
                     ('TypeIndex', None, 2), \
                     ('ColorAndStyle', is_string, 'Blue'), \
                     ('SearchCTLow', None, 'Missing'), \
                     ('SearchCTHigh', None, 'Missing'), \
                     ('DVHLineColor', None, -16777216), \
                     ('DVHLineWidth', None, 1), \
                     ('DVHLineStyle', None, 0), \
                     ('EUDAlpha', None, 'xsi:nil="true"'), \
                     ('TCPAlpha', None, 'xsi:nil="true"'), \
                     ('TCPBeta', None, 'xsi:nil="true"'), \
                     ('TCPGamma', None, 'xsi:nil="true"')]
    return {
        ID: tb.Variable(ID, var_type, validate=val, default=dflt)
        for (ID, val, dflt) in structure_def
    }
def define_template_attributes():
    '''Create a dictionary with Type Variable values that define all of the template attributes.
    '''
    var_type = 'Template'
    is_string = lambda x: isinstance(x, str)
    id_check = lambda x: is_string(x) and len(x) < 13
    #TODO more attribute checks should be added to the attribute definitions

    template_def = [('Version', None, 1.0), \
                     ('Type', is_string, 'Structure'), \
                     ('ID', id_check, None), \
                     ('Diagnosis', is_string, ''), \
                     ('TreatmentSite', is_string, '.All'), \
                     ('AssignedUsersID', is_string, 'gsal;'), \
                     ('Description', is_string, ''), \
                     ('ApprovalStatus', is_string, 'Unapproved'), \
                     ('ApprovalHistory', is_string, ''), \
                     ('LastModified', is_string, '')]
    return {
        ID: tb.Variable(ID, var_type, validate=val, default=dflt)
        for (ID, val, dflt) in template_def
    }
Пример #3
0
def define_template_list():
    '''Create a dictionary with Type Variable values that define the template list columns.
    '''
    var_type = 'Template_List'

    def is_int(x):
        return isinstance(x, int)

    def is_string(x):
        return isinstance(x, str)

    # TODO more attribute checks should be added to the attribute definitions
    # TODO make attribute checks more tolerant ie. if type conversion works

    template_def = [('workbook_name', is_string, 'Structure Templates.xlsx'), \
                     ('sheet_name', is_string, None), \
                     ('title', is_string, None), \
                     ('columns', is_int, 3), \
                     ('output_file_name', is_string, 'template.xml'), \
                     ('in_use', None, True)]
    return {
        ID: tb.Variable(ID, var_type, validate=val, default=dflt)
        for (ID, val, dflt) in template_def
    }