Exemplo n.º 1
0
def import_electrodes(subject_fname):
    args = read_args(su.get_python_argv())
    mmvt = su.init_mmvt_addon()
    mmvt.import_electrodes(args.pos_file, args.bipolar, args.radius)
    mmvt.set_render_output_path = su.get_figures_dir(args)
    su.save_blend_file(subject_fname)
    su.exit_blender()
Exemplo n.º 2
0
def create_new_subject(subject_fname):
    args = read_args(su.get_python_argv())
    mmvt = su.init_mmvt_addon()
    mmvt.import_brain()
    mmvt.set_render_output_path = su.get_figures_dir(args)
    su.save_blend_file(subject_fname)
    su.exit_blender()
Exemplo n.º 3
0
def create_new_subject(subject_fname):
    args = read_args(su.get_python_argv())
    mmvt = su.init_mmvt_addon()
    mmvt.import_brain()
    mmvt.set_render_output_path = su.get_figures_dir(args)
    su.save_blend_file(subject_fname)
    su.exit_blender()
Exemplo n.º 4
0
def import_electrodes(subject_fname):
    args = read_args(su.get_python_argv())
    mmvt = su.init_mmvt_addon()
    mmvt.import_electrodes(args.pos_file, args.bipolar, args.radius)
    mmvt.set_render_output_path = su.get_figures_dir(args)
    su.save_blend_file(subject_fname)
    su.exit_blender()
Exemplo n.º 5
0
def import_meg(subject_fname):
    args = read_args(su.get_python_argv())
    mmvt = su.init_mmvt_addon()
    mmvt.add_data_to_parent_brain_obj(args.stat)
    mmvt.add_data_to_brain()
    mmvt.set_render_output_path = su.get_figures_dir(args)
    su.save_blend_file(subject_fname)
    su.exit_blender()
Exemplo n.º 6
0
def render_electrodes_probs(subject_fname):
    args = read_args(su.get_python_argv())
    figures_dir = su.get_figures_dir(args)
    if args.rel_output_path:
        args.output_path = op.join(figures_dir, args.output_path)
    su.make_dir(args.output_path)

    # Set the labeling file
    labeling_fname = '{}_{}_electrodes_cigar_r_*_l_*{}*.pkl'.format(
        args.subject, args.real_atlas, '_bipolar' if args.bipolar else '')
    labels_fol = op.join(su.get_mmvt_dir(), args.subject, 'electrodes')
    labeling_files = glob.glob(op.join(labels_fol, labeling_fname))
    if len(labeling_files) == 0:
        print('No labeling files in {}!'.format(labels_fol))
        return
    if len(labeling_files) > 1:
        print(
            'More than one labeling files in {}, please choose one using the --labeling flag'
            .format(labels_fol))
        return
    else:
        labeling_file = labeling_files[0]

    mmvt = su.init_mmvt_addon()
    mmvt.show_hide_hemi(args.hide_lh, 'lh')
    mmvt.show_hide_hemi(args.hide_rh, 'rh')
    mmvt.show_hide_sub_corticals(args.hide_subs)
    mmvt.set_render_quality(args.quality)
    mmvt.set_render_output_path(args.output_path)
    mmvt.set_render_smooth_figure(args.smooth_figure)
    if op.isfile(op.join(args.output_path, 'camera.pkl')):
        mmvt.load_camera()
    else:
        # Try to find the camera in the figures folder
        if op.isfile(op.join(figures_dir, 'camera.pkl')):
            mmvt.set_render_output_path(figures_dir)
            mmvt.load_camera()
            mmvt.set_render_output_path(args.output_path)
        else:
            cont = input(
                'No camera file was detected in the output folder, continue?')
            if not su.is_true(cont):
                return

    mmvt.set_electrodes_labeling_file(labeling_file)
    mmvt.show_electrodes()
    mmvt.color_the_relevant_lables(True)
    leads = mmvt.get_leads()
    for lead in leads:
        electrodes = mmvt.get_lead_electrodes(lead)
        for electrode in electrodes:
            print(electrode)
            mmvt.clear_cortex()
            mmvt.set_current_electrode(electrode, lead)
            mmvt.render_image(electrode)

    su.save_blend_file(subject_fname)
    su.exit_blender()
def render_electrodes_probs(subject_fname):
    args = read_args(su.get_python_argv())
    figures_dir = su.get_figures_dir(args)
    if args.rel_output_path:
        args.output_path = op.join(figures_dir, args.output_path)
    su.make_dir(args.output_path)

    # Set the labeling file
    labeling_fname = '{}_{}_electrodes_cigar_r_*_l_*{}*.pkl'.format(args.subject, args.real_atlas,
        '_bipolar' if args.bipolar else '')
    labels_fol = op.join(su.get_mmvt_dir(), args.subject, 'electrodes')
    labeling_files = glob.glob(op.join(labels_fol, labeling_fname))
    if len(labeling_files) == 0:
        print('No labeling files in {}!'.format(labels_fol))
        return
    if len(labeling_files) > 1:
        print('More than one labeling files in {}, please choose one using the --labeling flag'.format(labels_fol))
        return
    else:
        labeling_file = labeling_files[0]

    mmvt = su.init_mmvt_addon()
    mmvt.show_hide_hemi(args.hide_lh, 'lh')
    mmvt.show_hide_hemi(args.hide_rh, 'rh')
    mmvt.show_hide_sub_corticals(args.hide_subs)
    mmvt.set_render_quality(args.quality)
    mmvt.set_render_output_path(args.output_path)
    mmvt.set_render_smooth_figure(args.smooth_figure)
    if op.isfile(op.join(args.output_path, 'camera.pkl')):
        mmvt.load_camera()
    else:
        # Try to find the camera in the figures folder
        if op.isfile(op.join(figures_dir, 'camera.pkl')):
            mmvt.set_render_output_path(figures_dir)
            mmvt.load_camera()
            mmvt.set_render_output_path(args.output_path)
        else:
            cont = input('No camera file was detected in the output folder, continue?')
            if not su.is_true(cont):
                return

    mmvt.set_electrodes_labeling_file(labeling_file)
    mmvt.show_electrodes()
    mmvt.color_the_relevant_lables(True)
    leads = mmvt.get_leads()
    for lead in leads:
        electrodes = mmvt.get_lead_electrodes(lead)
        for electrode in electrodes:
            print(electrode)
            mmvt.clear_cortex()
            mmvt.set_current_electrode(electrode, lead)
            mmvt.render_image(electrode)

    su.save_blend_file(subject_fname)
    su.exit_blender()
def wrap_mmvt_calls(subject_fname):
    args = read_args(su.get_python_argv())
    mmvt = su.init_mmvt_addon()
    mmvt.import_brain()
    mmvt.set_render_output_path = su.get_figures_dir(args)
    su.save_blend_file(subject_fname)
    with open(args.log_fname, 'w') as text_file:
        print(args, file=text_file)
    try:
        su.exit_blender()
    except:
        pass
Exemplo n.º 9
0
def wrap_mmvt_calls(subject_fname):
    args = read_args(su.get_python_argv())
    if args.debug:
        su.debug()
    mmvt = su.init_mmvt_addon()
    mmvt.utils.write_to_stderr('{} Importing electrodes...'.format(
        args.subject))
    if args.overwrite:
        mmvt.utils.delete_hierarchy('Deep_electrodes')
    mmvt.import_electrodes(args.pos_file, mmvt.ELECTRODES_LAYER, args.bipolar,
                           args.radius)
    mmvt.set_render_output_path = su.get_figures_dir(args)
    su.save_blend_file(subject_fname)
    mmvt.utils.write_to_stderr('{} Done!'.format(args.subject))
    su.exit_blender()
Exemplo n.º 10
0
def import_meg(subject_fname):
    args = read_args(su.get_python_argv())
    mmvt = su.init_mmvt_addon()
    try:
        mmvt.add_data_to_parent_brain_obj(args.stat)
    except:
        logging.error('Error in add_data_to_parent_brain_obj!')
        logging.error(traceback.format_exc())
    try:
        mmvt.add_data_to_brain()
    except:
        logging.error('Error in add_data_to_brain!')
        logging.error(traceback.format_exc())
    try:
        mmvt.set_render_output_path = su.get_figures_dir(args)
    except:
        logging.error('Error in set_render_output_path!')
        logging.error(traceback.format_exc())
    try:
        su.save_blend_file(subject_fname)
    except:
        logging.error('Error in save_blend_file!')
        logging.error(traceback.format_exc())
    su.exit_blender()
Exemplo n.º 11
0
def import_meg(subject_fname):
    args = read_args(su.get_python_argv())
    mmvt = su.init_mmvt_addon()
    try:
        mmvt.add_data_to_parent_brain_obj(args.stat)
    except:
        logging.error('Error in add_data_to_parent_brain_obj!')
        logging.error(traceback.format_exc())
    try:
        mmvt.add_data_to_brain()
    except:
        logging.error('Error in add_data_to_brain!')
        logging.error(traceback.format_exc())
    try:
        mmvt.set_render_output_path = su.get_figures_dir(args)
    except:
        logging.error('Error in set_render_output_path!')
        logging.error(traceback.format_exc())
    try:
        su.save_blend_file(subject_fname)
    except:
        logging.error('Error in save_blend_file!')
        logging.error(traceback.format_exc())
    su.exit_blender()