Ejemplo n.º 1
0
def plot_noise_covariance(name, save_dir, lowpass, subject, save_plots,
                          figures_path):

    noise_covariance = io.read_noise_covariance(name, save_dir, lowpass)
    info = io.read_info(name, save_dir)

    fig_cov = noise_covariance.plot(info, show_svd=False)

    if save_plots:
        save_path = join(figures_path, subject, 'noise_covariance', name + \
                    filter_string(lowpass) + '.jpg')
        fig_cov[0].savefig(save_path, dpi=600)
        print 'figure: ' + save_path + ' has been saved'
    else:
        print 'Not saving plots; set "save_plots" to "True" to save'
def plot_transformation(name, save_dir, subject, subjects_dir, save_plots,
                        figures_path):
        info = io.read_info(name, save_dir)
        trans = io.read_transformation(name, save_dir)
        
        mne.viz.plot_alignment(info, trans, subject, subjects_dir,
                               surfaces=['head-dense', 'inner_skull', 'brain'])#,
#                               skull=['inner_skull', 'outer_skull'],
#                               brain=True)
                                   
        mayavi.mlab.view(0, -90)                                   
                           
        if save_plots:
            save_path = join(figures_path, subject, 'transformation', name + \
                            '.jpg')
            mayavi.mlab.savefig(save_path)
            print 'figure: ' + save_path + ' has been saved'
        else:
            print 'Not saving plots; set "save_plots" to "True" to save'
Ejemplo n.º 3
0
def create_inverse_operator(name, save_dir, lowpass, overwrite):

    inverse_operator_name = name + filter_string(lowpass) + '-inv.fif'
    inverse_operator_path = join(save_dir, inverse_operator_name)

    if overwrite or not isfile(inverse_operator_path):

        info = io.read_info(name, save_dir)
        noise_covariance = io.read_noise_covariance(name, save_dir, lowpass)
        forward = io.read_forward(name, save_dir)

        inverse_operator = mne.minimum_norm.make_inverse_operator(
            info, forward, noise_covariance)

        mne.minimum_norm.write_inverse_operator(inverse_operator_path,
                                                inverse_operator)

    else:
        print('inverse operator file: '+ inverse_operator_path + \
            ' already exists')
Ejemplo n.º 4
0
def create_forward_solution(name, save_dir, subject, subjects_dir,
                            overwrite):

    forward_name = name + '-fwd.fif'
    forward_path = join(save_dir, forward_name)

    if overwrite or not isfile(forward_path):

        info = io.read_info(name, save_dir)
        trans = io.read_transformation(name, save_dir)
        bem = io.read_bem_solution(subject, subjects_dir)
        source_space = io.read_source_space(subject, subjects_dir)

        forward = mne.make_forward_solution(info, trans, source_space, bem,
                                              n_jobs=1)
        
        mne.write_forward_solution(forward_path, forward, overwrite)
        
    else:
        print('forward solution: ' + forward_path + ' already exists')