Beispiel #1
0
def import_new_materials():
    #empty_brain_path = op.join(mmvt_utils.get_parent_fol(mmvt_utils.get_user_fol()), 'empty_subject.blend')
    empty_brain_path = op.join(mmvt_utils.get_resources_dir(), 'empty_subject.blend')
    
    new_mats_list = ['Helmet_map_mat', 'unselected_label_Mat_cortex', 'unselected_label_Mat_subcortical']
    for cur_mat in new_mats_list:
        bpy.ops.wm.append(filepath=empty_brain_path, directory=empty_brain_path + '\\Material\\', filename=cur_mat)
        bpy.data.materials[cur_mat].use_fake_user = True
def init(addon):
    if not bpy.data.objects.get('full_colorbar', None):
        print("No full_colorbar object, Can't load the colorbar panel")
        return
    ColorbarPanel.addon = addon
    colorbar_files_fol = mu.make_dir(
        op.join(mu.get_parent_fol(mu.get_user_fol()), 'color_maps'))
    colorbar_files_code_fol = op.join(mu.get_resources_dir(), 'color_maps')
    colorbar_files_template = op.join(colorbar_files_fol, '*.npy')
    colorbar_files_code_template = op.join(colorbar_files_code_fol, '*.npy')
    # colorbar_files_template = op.join(mu.file_fol(), 'color_maps', '*.npy')
    colorbar_files = glob.glob(colorbar_files_template)
    colorbar_code_files = glob.glob(colorbar_files_code_template)
    extra_files = list(
        set([mu.namebase_with_ext(f) for f in colorbar_code_files]) -
        set([mu.namebase_with_ext(f) for f in colorbar_files]))
    for extra_file in extra_files:
        print('Coping missing cb file: {}'.format(
            mu.namebase_with_ext(extra_file)))
        shutil.copyfile(
            op.join(colorbar_files_code_fol, extra_file),
            op.join(colorbar_files_fol, mu.namebase_with_ext(extra_file)))
    if len(colorbar_files) == 0:
        print("No colorbar files ({}), Can't load the colorbar panel".format(
            colorbar_files_template))
        return None
    colorbar_files = glob.glob(colorbar_files_template)
    files_names = [mu.namebase(fname)
                   for fname in colorbar_files]  # .replace('_', '-')
    ColorbarPanel.maps_names = files_names
    colorbar_items = [(c, c, '', ind) for ind, c in enumerate(files_names)]
    bpy.types.Scene.colorbar_files = bpy.props.EnumProperty(
        items=colorbar_items,
        update=colormap_update,
        description='Selects the colorbar color palette.\n\nCurrent palette')
    if not colorbar_values_are_locked():
        bpy.context.scene.colorbar_files = files_names[0]
    else:
        load_colormap()
    for space in mu.get_3d_spaces():
        if space.lock_object and space.lock_object.name == 'full_colorbar':
            space.show_only_render = True
    register()
    ColorbarPanel.init = True
    bpy.context.scene.show_cb_in_render = False
    mu.select_hierarchy('colorbar_camera', False, False)
    if not ColorbarPanel.colorbar_updated and not colorbar_values_are_locked():
        ColorbarPanel.should_not_lock_values = True
        # bpy.context.scene.colorbar_min = -1
        # bpy.context.scene.colorbar_max = 1
        # bpy.context.scene.colorbar_title = '     MEG'
        bpy.context.scene.colorbar_y = 0.18
        bpy.context.scene.colorbar_text_y = -1.53
        bpy.context.scene.colorbar_prec = 2
        ColorbarPanel.should_not_lock_values = False
Beispiel #3
0
def check_empty_subject_version():
    import shutil
    resources_dir = mmvt_utils.get_resources_dir()
    mmvt_dir = mmvt_utils.get_mmvt_dir()
    resources_empty_brain = op.join(resources_dir, 'empty_subject.blend')
    mmvt_empty_brain = op.join(mmvt_dir, 'empty_subject.blend')
    if not op.isfile(mmvt_empty_brain):
        print('Copying new empty brain')
        shutil.copy(resources_empty_brain, mmvt_empty_brain)
    else:
        empty_brain_resources_mod_time = mmvt_utils.file_modification_time(resources_empty_brain)
        empty_brain_mmvt_mod_time = mmvt_utils.file_modification_time(mmvt_empty_brain)
        if empty_brain_resources_mod_time > empty_brain_mmvt_mod_time:
            print('Copying new empty brain')
            shutil.copy(resources_empty_brain, mmvt_empty_brain)
Beispiel #4
0
def init(addon):
    if not bpy.data.objects.get('full_colorbar', None):
        print("No full_colorbar object, Can't load the colorbar panel")
        return
    ColorbarPanel.addon = addon
    colorbar_files_template = op.join(mu.get_resources_dir(), 'color_maps',
                                      '*.npy')
    # colorbar_files_template = op.join(mu.file_fol(), 'color_maps', '*.npy')
    colorbar_files = glob.glob(colorbar_files_template)
    if len(colorbar_files) == 0:
        print("No colorbar files ({}), Can't load the colorbar panel".format(
            colorbar_files_template))
        return None
    files_names = [
        mu.namebase(fname).replace('_', '-') for fname in colorbar_files
    ]
    ColorbarPanel.maps_names = files_names
    colorbar_items = [(c, c, '', ind) for ind, c in enumerate(files_names)]
    bpy.types.Scene.colorbar_files = bpy.props.EnumProperty(
        items=colorbar_items,
        description="colormaps files",
        update=colormap_update)
    if not colorbar_values_are_locked():
        bpy.context.scene.colorbar_files = files_names[0]
    else:
        load_colormap()
    for space in mu.get_3d_spaces():
        if space.lock_object and space.lock_object.name == 'full_colorbar':
            space.show_only_render = True
    register()
    ColorbarPanel.init = True
    bpy.context.scene.show_cb_in_render = False
    mu.select_hierarchy('colorbar_camera', False, False)
    if not ColorbarPanel.colorbar_updated and not colorbar_values_are_locked():
        # bpy.context.scene.colorbar_min = -1
        # bpy.context.scene.colorbar_max = 1
        # bpy.context.scene.colorbar_title = '     MEG'
        bpy.context.scene.colorbar_y = 0.18
        bpy.context.scene.colorbar_text_y = -1.53
        bpy.context.scene.colorbar_prec = 2
    if not colorbar_values_are_locked():
        if 'fMRI' in bpy.context.scene.colorbar_title:
            bpy.context.scene.colorbar_files = 'PuBu-RdOrYl'
        else:
            bpy.context.scene.colorbar_files = 'BuPu-YlOrRd'