def define_template_tables(file_path: Path, sheet_name: str, \
            tmpl_title: str, tmpl_offset='A1', tmpl_columns=2, \
            struc_title='Template Structures', struc_offset='D1', struc_columns=5):
    '''Create Table definitions for the template table and
    it's companion structure list required to build a structure template.
    '''
    #TODO define_template_tables is getting messy probably should get rid of it
    # values for all tables
    tmp_index = 'Attribute'
    str_index = 'ID'
    # Rows is not yet implemented not using
    template_table = tb.Table(file_path,
                              sheet_name,
                              tmpl_title,
                              tmp_index,
                              tmpl_offset,
                              columns=tmpl_columns)
    structures_dfn = define_structure_attributes()
    structures_table = tb.Table(file_path,
                                sheet_name,
                                struc_title,
                                str_index,
                                struc_offset,
                                struc_columns,
                                variables=structures_dfn)

    return (template_table, structures_table)
Пример #2
0
def import_template_list(base_path: Path):
    '''Import the list of active templates.
    '''
    template_list_path = base_path / TEMPLATE_LIST_FILE
    variables = define_template_list()
    template_list_table = tb.Table(template_list_path,
                                   'templates',
                                   variables=variables)
    template_list = template_list_table.read_table()
    active_templates = template_list[template_list.in_use == 'True']
    active_templates['name'] = active_templates['title']
    active_templates.set_index('name', inplace=True)
    active_templates['columns'] = active_templates['columns'].astype('int64')
    return active_templates
Пример #3
0
def define_structure_tables(file_path: Path, structures: list):
    '''Create a list of Type Table values that define all of the structure tables required to build a complete structures data lookup.
    '''
    # Define the tables
    tables_def = [
         ['Structure Dictionary Assignment', 'Structure Dictionary', 6],
         ['Volume Types', 'Volume Type', 3],
         ['Structure colors', 'Structure Colors', 6],
         ['CT Search', 'HU Values', 3],
         ['DVH Lines', 'DVH',4]]
    # values for all tables
    offset = 'A1'
    index = 'Structure'
    # Rows is not yet implemented not using
    table_list = [tb.Table(file_path, sheet_name=sheet_name, title=title, \
                        index=index, offset=offset, columns=columns, \
                        variables=structures)
                  for (sheet_name, title, columns) in tables_def]
    return  table_list
Пример #4
0
    file = open(str(structures_pickle_file_path), 'wb')
    dump(structures_lookup, file)
    file.close()
    return structures_pickle_file_path

def load_structure_references(structures_pickle_file_path)->pd.DataFrame:
    file = open(str(structures_pickle_file_path), 'rb')
    structures_lookup = load(file)
    return structures_lookup

if __name__ == '__main__':
    structures_file_path = Path(r'.\Template Tests.xlsx')
    structures_lookup = build_structures_lookup(structures_file_path)
    #print(structures_lookup)

    file_path = file_path = Path(r'.\Template Tests.xlsx')
    sheet_name = 'Test Template'
    title = 'Structures'
    offset = 'A6'
    index = 'ID'
    columns = 5
    structures_table = tb.Table(file_path, sheet_name, title, index, offset, columns, define_structure_attributes())
    structures = build_structures_list(structures_table, structures_lookup)
    print(structures)
    structure_set = build_structures_element(structures)

    #title = 'Test Template'
    #offset = 'A1'
    #columns = 8
    #template_table = tb.Table(file_path, sheet_name, title, offset=offset, columns=columns)