Example #1
0
def init(addon):
    if not bpy.data.objects.get("full_colorbar", None):
        return
    ColorbarPanel.addon = addon
    colorbar_files = glob.glob(op.join(mu.file_fol(), "color_maps", "*.npy"))
    if len(colorbar_files) == 0:
        return None
    files_names = [mu.namebase(fname).replace("_", "-") for fname in colorbar_files]
    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
    )
    bpy.context.scene.colorbar_files = files_names[0]
    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:
        bpy.context.scene.colorbar_min = -1
        bpy.context.scene.colorbar_max = 1
        bpy.context.scene.colorbar_title = "MEG"
    bpy.context.scene.colorbar_files = "BuPu-YlOrRd"
    bpy.context.scene.colorbar_y = 0.18
    bpy.context.scene.colorbar_text_y = -1.53
Example #2
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_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
Example #3
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'
Example #4
0
electrodes_panel_parent = electrodes_panel.PARENT_OBJ_NAME
electrodes_panel_parent_obj = bpy.data.objects.get(electrodes_panel_parent,
                                                   None)
meg_panel_parent = meg_panel.PARENT_OBJ_NAME
ANGLES_DICT = show_hide_panel.ANGLES_DICT
ANGLES_NAMES_DICT = show_hide_panel.ANGLES_NAMES_DICT
# Remove double definition (also in show_hide_panel)
(ROT_SAGITTAL_LEFT, ROT_SAGITTAL_RIGHT, ROT_CORONAL_ANTERIOR,
 ROT_CORONAL_POSTERIOR, ROT_AXIAL_SUPERIOR, ROT_AXIAL_INFERIOR,
 ROT_MEDIAL_LEFT, ROT_MEDIAL_RIGHT) = range(8)

utils = mmvt_utils
colors = colors_utils
scene = bpy.context.scene
tmp = mmvt_utils.get_3d_spaces(only_neuro=True)
view_region = tmp.__next__().region_3d
q = view_region.view_rotation.to_euler()
bpy.context.scene.view_rotations_x = view_region.view_rotation.to_euler()[0]
bpy.context.scene.view_rotations_y = view_region.view_rotation.to_euler()[1]
bpy.context.scene.view_rotations_z = view_region.view_rotation.to_euler()[2]

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Data links ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
data = data_panel
import_brain = data_panel.import_brain
add_data_to_parent_obj = data_panel.add_data_to_parent_obj
add_data_to_brain = data_panel.add_data_to_brain
import_electrodes = data_panel.import_electrodes
eeg_data_and_meta = data_panel.eeg_data_and_meta
load_meg_labels_data = data_panel.load_meg_labels_data
load_electrodes_data = data_panel.load_electrodes_data