Exemple #1
0
import os
import os.path as op

import matplotlib.pyplot as plt
import mne
import numpy as np

from jumeg.connectivity.con_utils import group_con_matrix_by_lobe
from jumeg.connectivity.con_viz import plot_grouped_causality_circle
from jumeg.jumeg_utils import get_jumeg_path

###############################################################################
# Load the grouping files
###############################################################################

grouping_yaml_fname = op.join(get_jumeg_path(), 'data',
                              'desikan_aparc_cortex_based_grouping_ck.yaml')
lobe_grouping_yaml_fname = op.join(get_jumeg_path(), 'data',
                                   'lobes_grouping.yaml')

###############################################################################
# Load anatomical labels
###############################################################################

subjects_dir = os.environ['SUBJECTS_DIR']

full_labels = mne.read_labels_from_annot(subject='fsaverage',
                                         parc='aparc',
                                         hemi='both',
                                         subjects_dir=subjects_dir)
from jumeg.connectivity.causality import (compute_order, do_mvar_evaluation,
                                          prepare_causality_matrix)
from jumeg.connectivity import (plot_grouped_connectivity_circle,
                                plot_grouped_causality_circle)

import scot
import scot.connectivity_statistics as scs
from scot.connectivity import connectivity
import pickle

import time
t_start = time.time()

print('Scot version -', scot.__version__)

yaml_fname = get_jumeg_path() + '/examples/aparc_cortex_based_grouping.yaml'
labels_fname = get_jumeg_path() + '/examples/label_names.list'

data_path = sample.data_path()
subjects_dir = data_path + '/subjects'
fname_inv = data_path + '/MEG/sample/sample_audvis-meg-oct-6-meg-inv.fif'
fname_raw = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw.fif'
fname_event = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw-eve.fif'

# Load data
inverse_operator = read_inverse_operator(fname_inv)
raw = mne.io.read_raw_fif(fname_raw)
events = mne.read_events(fname_event)

# Add a bad channel
raw.info['bads'] += ['MEG 2443']
from jumeg.connectivity.causality import (compute_order, do_mvar_evaluation,
                                          prepare_causality_matrix)
from jumeg.connectivity import (plot_grouped_connectivity_circle,
                                plot_grouped_causality_circle)

import scot
import scot.connectivity_statistics as scs
from scot.connectivity import connectivity
import yaml

import time
t_start = time.time()

print(('Scot version -', scot.__version__))

yaml_fname = get_jumeg_path(
) + '/data/desikan_aparc_cortex_based_grouping.yaml'
labels_fname = get_jumeg_path() + '/data/desikan_label_names.yaml'

data_path = sample.data_path()
subjects_dir = data_path + '/subjects'
fname_inv = data_path + '/MEG/sample/sample_audvis-meg-oct-6-meg-inv.fif'
fname_raw = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw.fif'
fname_event = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw-eve.fif'

# Load data
inverse_operator = read_inverse_operator(fname_inv)
raw = mne.io.read_raw_fif(fname_raw)
events = mne.read_events(fname_event)

# Add a bad channel
raw.info['bads'] += ['MEG 2443']
Exemple #4
0
# config
MLICA_threshold = 0.8
n_components = 60
njobs = 4  # for downsampling
tmin = 0
tmax = tmin + 15000
flow_ecg, fhigh_ecg = 8, 20
flow_eog, fhigh_eog = 1, 20
ecg_thresh, eog_thresh = 0.3, 0.3
ecg_ch = 'ECG 001'
eog1_ch = 'EOG 001'
eog2_ch = 'EOG 002'
reject = {'mag': 5e-12}
refnotch = [50., 100., 150., 200., 250., 300., 350., 400.]

data_path = op.join(get_jumeg_path(), 'data')
print data_path

# example filname
raw_fname = "/Volumes/megraid21/sripad/cau_fif_data/jumeg_test_data/" \
            "109925_CAU01A_100715_0842_2_c,rfDC-raw.fif"

# load the model for artifact rejection
# the details of the model is provided in the x_validation_shuffle_v4_split_23.txt
model_name = op.join(data_path, "dcnn_model.hdf5")

model = load_model(model_name)

# noise reducer
raw_nr = noise_reducer(raw_fname, reflp=5., return_raw=True)
import os.path as op
import numpy as np
import mne

from mne.datasets import sample
from jumeg.jumeg_utils import get_jumeg_path
from jumeg.connectivity import make_annot_from_csv

from nilearn import plotting
from surfer import Brain

data_path = sample.data_path()
subject = 'sample'
subjects_dir = data_path + '/subjects'
parc_fname = 'standard_garces_2016'
csv_fname = op.join(get_jumeg_path(), 'data', 'standard_rsns.csv')

# set make_annot to True to save the annotation to disk
labels, coords, _ = make_annot_from_csv(subject, subjects_dir, csv_fname,
                                        parc_fname=parc_fname, make_annot=False,
                                        return_label_coords=True)

# to plot mni coords on glass brain
n_nodes = np.array(coords).shape[0]
# make a random zero valued connectivity matrix
con = np.zeros((n_nodes, n_nodes))
# plot the connectome on a glass brain background
plotting.plot_connectome(con, coords)
plotting.show()

# plot the brain surface, foci and labels
Exemple #6
0
'''

import os.path as op
import numpy as np
import mne

from mne.datasets import sample
from jumeg.jumeg_utils import get_jumeg_path
from jumeg.connectivity import make_annot_from_csv
from jumeg.connectivity import plot_grouped_connectivity_circle

data_path = sample.data_path()
subject = 'sample'
subjects_dir = data_path + '/subjects'
parc_fname = 'standard_garces_2016'
csv_fname = op.join(get_jumeg_path(), 'data', 'standard_rsns.csv')

# set make_annot to True to save the annotation to disk
labels, coords, foci = make_annot_from_csv(subject,
                                           subjects_dir,
                                           csv_fname,
                                           parc_fname=parc_fname,
                                           make_annot=False,
                                           return_label_coords=True)

aparc = mne.read_labels_from_annot('sample', subjects_dir=subjects_dir)
aparc_names = [apa.name for apa in aparc]
lh_aparc = [mylab for mylab in aparc if mylab.hemi == 'lh']
rh_aparc = [mylab for mylab in aparc if mylab.hemi == 'rh']

# get the appropriate resting state labels