Esempio n. 1
0
def slices_were_clicked(active_image, pos):
    if WhereAmIPanel.slicer_state.mri is None:
        return
    modality = bpy.context.scene.slices_modality
    images_names = [
        '{}.{}'.format(persp,
                       _addon().get_figure_format())
        for persp in ['sagital', 'coronal', 'axial']
    ]
    # images_names = ['mri_sagital.png', 'mri_coronal.png', 'mri_axial.png']
    WhereAmIPanel.slices_cursor_pos[active_image.name] = pos
    print('Image {} was click in {}'.format(active_image.name, pos))
    # print(active_image.name, pos)
    image_ind = images_names.index(active_image.name.lower())
    new_pos_vox = slicer.on_click(image_ind, pos, WhereAmIPanel.slicer_state,
                                  modality)
    if modality == 'ct':
        new_pial_ras = apply_trans(_ct_trans().vox2ras,
                                   np.array([new_pos_vox]))[0]
        new_pos_vox = apply_trans(t1_trans().ras2vox,
                                  np.array([new_pial_ras]))[0]
    new_pos_pial = apply_trans(t1_trans().vox2ras_tkr,
                               np.array([new_pos_vox]))[0]  #.astype(np.int)[0]
    # Find the closest vertex on the pial brain, and convert it to the current inflation
    new_pos = pos_to_current_inflation(new_pos_pial) / 10
    bpy.context.scene.cursor_location = new_pos
    _addon().save_cursor_position()
    _addon().set_ct_intensity()
    return new_pos
Esempio n. 2
0
def slices_were_clicked():
    if WhereAmIPanel.slicer_state is None:
        return
    screen = bpy.data.screens['Neuro']
    images_names = ['mri_sagital.png', 'mri_coronal.png', 'mri_axial.png']
    for area in screen.areas:
        if area.type == 'IMAGE_EDITOR':
            active_image = area.spaces.active.image
            if active_image is not None:
                pos = tuple(area.spaces.active.cursor_location)
                if pos != WhereAmIPanel.slices_cursor_pos[active_image.name]:
                    print(active_image.name, pos)
                    image_ind = images_names.index(active_image.name)
                    new_pos = slicer.on_click(image_ind, pos,
                                              WhereAmIPanel.slicer_state)
                    x, y, z = apply_trans(_trans().vox2ras_tkr,
                                          np.array([new_pos])).astype(
                                              np.int)[0] / 10
                    bpy.context.scene.cursor_location = (x, y, z)
                    _addon().save_cursor_position()
    save_slices_cursor_pos()