Example #1
0
import numpy as np

from jumeg import get_jumeg_path
from jumeg.connectivity import plot_grouped_causality_circle
import yaml

# load the yaml grouping of Freesurfer labels
yaml_fname = get_jumeg_path() + '/data/desikan_aparc_cortex_based_grouping.yaml'
labels_fname = get_jumeg_path() + '/data/desikan_label_names.yaml'
replacer_dict_fname = get_jumeg_path() + '/data/replacer_dictionaries.yaml'

with open(labels_fname, 'r') as f:
    label_names = yaml.safe_load(f)['label_names']

with open(replacer_dict_fname, 'r') as f:
    replacer_dict = yaml.safe_load(f)['replacer_dict_aparc']

# make a random causality matrix
n_nodes = 68  # currently needs to be always this number
caus = np.random.random((n_nodes, n_nodes))
caus[np.diag_indices_from(caus)] = 0.
caus[caus < 0.7] = 0.

plot_grouped_causality_circle(caus, yaml_fname, label_names, n_lines=10,
                              labels_mode='replace', replacer_dict=replacer_dict,
                              out_fname='fig_causality_circle.png',
                              colormap='Blues', colorbar=True,
                              figsize=(6, 6), show=False,
                              arrowstyle='->,head_length=1,head_width=1')
    cau,
    surr,
    freqs,
    nfft=nfft,
    sfreq=epochs.info['sfreq'],
    surr_thresh=surr_thresh)

print('Shape of causality matrix: ', caus.shape)

# get label names used for plotting
labels_fname = get_jumeg_path() + '/examples/label_names.list'
yaml_fname = get_jumeg_path() + '/examples/aparc_cortex_based_grouping.yaml'

with open(labels_fname, 'r') as f:
    label_names = pickle.load(f)

plot_grouped_causality_circle(caus[0],
                              yaml_fname,
                              label_names,
                              n_lines=10,
                              labels_mode='cortex_only',
                              out_fname='causality_sample.png',
                              colormap='Blues',
                              colorbar=True,
                              figsize=(10, 6),
                              show=False)

t_end = time.time()
total_time_taken = t_end - t_start
print('Total time taken in minutes: %f' % (total_time_taken / 60.))
Example #3
0
    freqs,
    nfft=nfft,
    sfreq=epochs.info['sfreq'],
    surr_thresh=surr_thresh)

print(('Shape of causality matrix: ', caus.shape))

# read the label names used for plotting
# with open(labels_fname, 'r') as f:
#     label_names = pickle.load(f)

with open(labels_fname, 'r') as f:
    label_names = yaml.safe_load(f)['label_names']

plot_grouped_causality_circle(caus[0],
                              yaml_fname,
                              label_names,
                              n_lines=10,
                              labels_mode=None,
                              replacer_dict=None,
                              out_fname='causality_sample.png',
                              colormap='Blues',
                              colorbar=True,
                              arrowstyle='->,head_length=1,head_width=1',
                              figsize=(10, 6),
                              show=False)

t_end = time.time()
total_time_taken = t_end - t_start
print(('Total time taken in minutes: %f' % (total_time_taken / 60.)))