Exemplo n.º 1
0
def import_electrodes(input_file,
                      electrodes_layer,
                      bipolar='',
                      electrode_size=None,
                      parnet_name='Deep_electrodes'):
    if not electrode_size is None:
        bpy.context.scene.electrodes_radius = electrode_size
    if bipolar != '':
        bpy.context.scene.bipolar = bool(bipolar)
    mu.delete_hierarchy(parnet_name)
    f = np.load(input_file)

    electrode_size = bpy.context.scene.electrodes_radius
    layers_array = [False] * 20
    create_empty_if_doesnt_exists(parnet_name,
                                  _addon().BRAIN_EMPTY_LAYER, layers_array,
                                  parnet_name)

    layers_array = [False] * 20
    layers_array[electrodes_layer] = True

    for (x, y, z), name in zip(f['pos'], f['names']):
        elc_name = name.astype(str)
        if not bpy.data.objects.get(elc_name) is None:
            continue
        print('creating {}: {}'.format(elc_name, (x, y, z)))
        mu.create_sphere((x * 0.1, y * 0.1, z * 0.1), electrode_size,
                         layers_array, elc_name)
        cur_obj = bpy.data.objects[elc_name]
        cur_obj.select = True
        cur_obj.parent = bpy.data.objects[parnet_name]
        mu.create_and_set_material(cur_obj)
Exemplo n.º 2
0
def import_electrodes(input_file, electrodes_layer, bipolar='', electrode_size=None, parnet_name='Deep_electrodes'):
    if not electrode_size is None:
        bpy.context.scene.electrodes_radius = electrode_size
    if bipolar != '':
        bpy.context.scene.bipolar = bool(bipolar)
    mu.delete_hierarchy(parnet_name)
    f = np.load(input_file)

    electrode_size = bpy.context.scene.electrodes_radius
    layers_array = [False] * 20
    create_empty_if_doesnt_exists(parnet_name, _addon().BRAIN_EMPTY_LAYER, layers_array, parnet_name)

    layers_array = [False] * 20
    layers_array[electrodes_layer] = True

    for (x, y, z), name in zip(f['pos'], f['names']):
        elc_name = name.astype(str)
        if not bpy.data.objects.get(elc_name) is None:
            continue
        print('creating {}: {}'.format(elc_name, (x, y, z)))
        mu.create_sphere((x * 0.1, y * 0.1, z * 0.1), electrode_size, layers_array, elc_name)
        cur_obj = bpy.data.objects[elc_name]
        cur_obj.select = True
        cur_obj.parent = bpy.data.objects[parnet_name]
        mu.create_and_set_material(cur_obj)
Exemplo n.º 3
0
def import_electrodes(input_file, bipolar='', electrode_size=None):
    if not electrode_size is None:
        bpy.context.scene.electrodes_radius = electrode_size
    if bipolar != '':
        bpy.context.scene.bipolar = bool(bipolar)
    mu.delete_hierarchy('Deep_electrodes')
    print('Adding deep electrodes')
    f = np.load(input_file)

    deep_electrodes_layer = 1
    electrode_size = bpy.context.scene.electrodes_radius
    layers_array = [False] * 20
    create_empty_if_doesnt_exists('Deep_electrodes', DataMakerPanel.addon.BRAIN_EMPTY_LAYER, layers_array, 'Deep_electrodes')

    # if bpy.data.objects.get("Deep_electrodes") is None:
    #     layers_array[BRAIN_EMPTY_LAYER] = True
    #     bpy.ops.object.empty_add(type='PLAIN_AXES', radius=1, view_align=False, location=(0, 0, 0), layers=layers_array)
    #     bpy.data.objects['Empty'].name = 'Deep_electrodes'

    layers_array = [False] * 20
    layers_array[deep_electrodes_layer] = True

    for (x, y, z), name in zip(f['pos'], f['names']):
        elc_name = name.astype(str)
        if not bpy.data.objects.get(elc_name) is None:
            continue
        print('creating {}: {}'.format(elc_name, (x, y, z)))
        mu.create_sphere((x * 0.1, y * 0.1, z * 0.1), electrode_size, layers_array, elc_name)
        cur_obj = bpy.data.objects[elc_name]
        cur_obj.select = True
        cur_obj.parent = bpy.data.objects['Deep_electrodes']
        # cur_obj.active_material = bpy.data.materials['Deep_electrode_mat']
        mu.create_and_set_material(cur_obj)
Exemplo n.º 4
0
def create_new_electrode(elc_name):
    electrode_size = bpy.context.scene.electrodes_radius
    parent_name = _addon().electrodes_panel_parent
    mu.create_empty_if_doesnt_exists(parent_name, _addon().BRAIN_EMPTY_LAYER, root_fol=parent_name)
    layers_array = [False] * 20
    layers_array[_addon().ELECTRODES_LAYER] = True
    x, y, z = bpy.context.scene.cursor_location
    if not bpy.data.objects.get(elc_name) is None:
        elc_obj = bpy.data.objects[elc_name]
        elc_obj.location = [x, y, z]
    else:
        print('creating {}: {}'.format(elc_name, (x, y, z)))
        mu.create_sphere((x, y, z), electrode_size, layers_array, elc_name)
        cur_obj = bpy.data.objects[elc_name]
        cur_obj.select = True
        cur_obj.parent = bpy.data.objects[parent_name]
        mu.create_and_set_material(cur_obj)
    _addon().show_hide_electrodes(True)