Esempio n. 1
0
def render_movie(subject_fname):
    args = read_args(su.get_python_argv())
    if args.debug:
        su.debug()
    if args.rel_output_path:
        mmvt_dir = op.join(su.get_links_dir(), 'mmvt')
        if args.output_path == '':
            args.output_path = args.play_type
        args.output_path = op.join(mmvt_dir, args.subject, 'movies',
                                   args.output_path)
    su.make_dir(args.output_path)
    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)
    mmvt.set_light_layers_depth(args.light_layers)
    mmvt.set_brain_transparency(args.brain_trans)
    mmvt.filter_nodes(args.filter_nodes)
    mark_electrodes(mmvt, args)
    camera_fname = su.load_camera(mmvt, mmvt_dir, args)
    if not op.isfile(op.join(args.output_path, 'data.pkl')):
        try:
            mmvt.capture_graph(args.play_type, args.output_path,
                               args.selection_type)
        except:
            print("Graph couldn't be captured!")
    su.save_blend_file(subject_fname)
    mmvt.render_movie(args.play_type, args.play_from, args.play_to,
                      camera_fname, args.play_dt, args.set_to_camera_mode)
    su.exit_blender()
Esempio n. 2
0
def render_image(subject_fname):
    args = read_args(su.get_python_argv())
    if args.output_path == '':
        mmvt_dir = op.join(su.get_links_dir(), 'mmvt')
        args.output_path = op.join(mmvt_dir, args.subject, 'figures')
    su.make_dir(args.output_path)
    mmvt = su.init_mmvt_addon()
    mmvt.set_render_quality(args.quality)
    mmvt.set_render_output_path(args.output_path)
    mmvt.set_render_smooth_figure(args.smooth_figure)
    if not args.hide_lh is None:
        mmvt.show_hide_hemi(args.hide_lh, 'lh')
    if not args.hide_rh is None:
        mmvt.show_hide_hemi(args.hide_rh, 'rh')
    if not args.hide_subs is None:
        mmvt.show_hide_sub_corticals(args.hide_subs)
    if not args.show_elecs is None:
        mmvt.show_electrodes(args.show_elecs)
    if not args.show_only_lead is None:
        print('Showing only the current lead: {}'.format(args.show_only_lead))
        mmvt.set_show_only_lead(args.show_only_lead)
    if args.curr_elec not in ['', 'None']:
        print('Setting current electrode to {}'.format(args.curr_elec))
        mmvt.set_current_electrode(args.curr_elec)
    if op.isfile(op.join(args.output_path, 'camera.pkl')):
        mmvt.load_camera()
    else:
        cont = input('No camera file was detected in the output folder, continue?')
        if not su.is_true(cont):
            return
    # su.save_blend_file(subject_fname)
    mmvt.render_image(args.image_name, args.output_path, args.quality, args.smooth_figure, render_background=False)
    su.exit_blender()
Esempio n. 3
0
def pre_blender_call(args):
    if args.output_path == '':
        mmvt_dir = su.get_link_dir(su.get_links_dir(), 'mmvt')
        args.output_path = op.join(mmvt_dir, args.subject, 'figures')
    su.make_dir(args.output_path)
    args.log_fname = op.join(args.output_path, 'mmvt_calls.log')
    args.images_log_fname = op.join(args.output_path, 'images_names.txt')
    if op.isfile(args.log_fname):
        os.remove(args.log_fname)
    return args
Esempio n. 4
0
def render_image(subject_fname):
    args = read_args(su.get_python_argv())
    if args.output_path == '':
        mmvt_dir = op.join(su.get_links_dir(), 'mmvt')
        args.output_path = op.join(mmvt_dir, args.subject, 'figures')
    su.make_dir(args.output_path)
    mmvt = su.init_mmvt_addon()
    mmvt.set_render_quality(args.quality)
    mmvt.set_render_output_path(args.output_path)
    mmvt.set_render_smooth_figure(args.smooth_figure)
    if not args.hide_lh is None:
        mmvt.show_hide_hemi(args.hide_lh, 'lh')
    if not args.hide_rh is None:
        mmvt.show_hide_hemi(args.hide_rh, 'rh')
    if not args.hide_subs is None:
        mmvt.show_hide_sub_corticals(args.hide_subs)
    if not args.show_elecs is None:
        mmvt.show_electrodes(args.show_elecs)
    if not args.show_only_lead is None:
        print('Showing only the current lead: {}'.format(args.show_only_lead))
        mmvt.set_show_only_lead(args.show_only_lead)
    if args.curr_elec not in ['', 'None']:
        print('Setting current electrode to {}'.format(args.curr_elec))
        mmvt.set_current_electrode(args.curr_elec)
    if not args.show_connections is None:
        mmvt.show_hide_connections(args.show_connections)
    if op.isfile(op.join(args.output_path, 'camera.pkl')):
        mmvt.load_camera()
    else:
        cont = input(
            'No camera file was detected in the output folder, continue?')
        if not su.is_true(cont):
            return
    # su.save_blend_file(subject_fname)
    mmvt.render_image(args.image_name,
                      args.output_path,
                      args.quality,
                      args.smooth_figure,
                      render_background=False)
    su.exit_blender()
Esempio n. 5
0
def mark_electrodes(mmvt, args):
    mmvt_dir = su.get_link_dir(su.get_links_dir(), 'mmvt')
    if len(args.mark_electrodes) == 0:
        return
    if args.mark_electrodes[0].startswith('file:'):
        electrodes_fname = args.mark_electrodes[0][len('file:'):]
        if not op.isfile(electrodes_fname):
            electrodes_fname = op.join(mmvt_dir, args.subject, 'electrodes',
                                       electrodes_fname)
        args.mark_electrodes = su.read_list_from_file(electrodes_fname)
    if not args.mark_other_electrodes:
        for elc_name in args.mark_electrodes:
            print('Marking electrode {}'.format(elc_name))
            mmvt.filter_electrode_or_sensor(elc_name,
                                            args.mark_electrodes_value)
    else:
        electrodes_names = mmvt.get_electrodes_names()
        for elc_name in electrodes_names:
            if elc_name not in args.mark_electrodes:
                print('Marking electrode {}'.format(elc_name))
                mmvt.filter_electrode_or_sensor(elc_name,
                                                args.mark_electrodes_value)
Esempio n. 6
0
def render_movie(subject_fname):
    args = read_args(su.get_python_argv())
    if args.rel_output_path:
        mmvt_dir = op.join(su.get_links_dir(), 'mmvt')
        args.output_path = op.join(mmvt_dir, args.subject, 'movies', args.output_path)
    su.make_dir(args.output_path)
    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:
        cont = input('No camera file was detected in the output folder, continue?')
        if not su.is_true(cont):
            return
    if not op.isfile(op.join(args.output_path, 'data.pkl')):
        mmvt.capture_graph(args.play_type, args.output_path, args.selection_type)
    su.save_blend_file(subject_fname)
    mmvt.render_movie(args.play_type, args.play_from, args.play_to, args.play_dt)
    su.exit_blender()
Esempio n. 7
0
def render_image_blender(subject_fname):
    args = read_args(su.get_python_argv())
    if args.debug:
        su.debug()
    mmvt_dir = su.get_link_dir(su.get_links_dir(), 'mmvt')
    subject = su.get_subject_name(subject_fname)
    if args.output_path == '':
        args.output_path = op.join(mmvt_dir, args.subject, 'figures')
    su.make_dir(args.output_path)
    mmvt = su.init_mmvt_addon()
    mmvt.set_render_quality(args.quality)
    mmvt.set_render_output_path(args.output_path)
    mmvt.set_render_smooth_figure(args.smooth_figure)
    if not args.hide_lh is None:
        mmvt.show_hide_hemi(args.hide_lh, 'lh')
    if not args.hide_rh is None:
        mmvt.show_hide_hemi(args.hide_rh, 'rh')
    if not args.hide_subs is None:
        mmvt.show_hide_sub_corticals(args.hide_subs)
    if not args.show_elecs is None:
        mmvt.show_electrodes(args.show_elecs)
    if not args.show_only_lead is None:
        print('Showing only the current lead: {}'.format(args.show_only_lead))
        mmvt.set_show_only_lead(args.show_only_lead)
    if args.curr_elec not in ['', 'None']:
        print('Setting current electrode to {}'.format(args.curr_elec))
        mmvt.set_current_electrode(args.curr_elec)
    if not args.show_connections is None:
        mmvt.show_hide_connections(args.show_connections)
        mmvt.filter_nodes(args.filter_nodes)
    if args.inflated:
        mmvt.show_inflated()
        mmvt.set_inflated_ratio = args.inflated_ratio
    mmvt.set_background_color(args.background_color)
    mmvt.set_lighting(args.lighting)
    for image_name, camera in zip(args.image_name, args.camera):
        if camera == '':
            camera = op.join(mmvt_dir, subject, 'camera', 'camera.pkl')
        print('Camera fname: {}'.format(camera))
        if op.isfile(camera):
            mmvt.load_camera(camera)
        else:
            camera = op.join(mmvt_dir, subject, 'camera', 'camera.pkl')
            print('Camera was not found, loading default camera')
            mmvt.load_camera(camera)
            # if args.interactive:
            #     cont = input('No camera file was detected in the output folder, continue?')
            #     if not su.is_true(cont):
            #         continue
            # else:
            #     su.stdout_print('No camera file was detected in the output folder!!!')
            #     continue
        # su.save_blend_file(subject_fname)
        print('Rendering {}->{}'.format(image_name, args.output_path))
        mmvt.render_image(image_name,
                          args.output_path,
                          args.quality,
                          args.smooth_figure,
                          render_background=False,
                          overwrite=args.overwrite)
    su.stdout_print('*** finish rendering! ***')
    su.exit_blender()