Note

Click here to download the full example code

This example computes the all-to-all connectivity between 75 regions in a mixed source space based on dSPM inverse solutions and a FreeSurfer cortical parcellation. The connectivity is visualized using a circular graph which is ordered based on the locations of the regions.

```
# Author: Annalisa Pascarella <a.pascarella@iac.cnr.it>
#
# License: BSD (3-clause)
import os.path as op
import numpy as np
import mne
import matplotlib.pyplot as plt
from mne.datasets import sample
from mne import setup_volume_source_space, setup_source_space
from mne import make_forward_solution
from mne.io import read_raw_fif
from mne.minimum_norm import make_inverse_operator, apply_inverse_epochs
from mne.connectivity import spectral_connectivity
from mne.viz import circular_layout, plot_connectivity_circle
# Set dir
data_path = sample.data_path()
subject = 'sample'
data_dir = op.join(data_path, 'MEG', subject)
subjects_dir = op.join(data_path, 'subjects')
bem_dir = op.join(subjects_dir, subject, 'bem')
# Set file names
fname_aseg = op.join(subjects_dir, subject, 'mri', 'aseg.mgz')
fname_model = op.join(bem_dir, '%s-5120-bem.fif' % subject)
fname_bem = op.join(bem_dir, '%s-5120-bem-sol.fif' % subject)
fname_raw = data_dir + '/sample_audvis_filt-0-40_raw.fif'
fname_trans = data_dir + '/sample_audvis_raw-trans.fif'
fname_cov = data_dir + '/ernoise-cov.fif'
fname_event = data_dir + '/sample_audvis_filt-0-40_raw-eve.fif'
# List of sub structures we are interested in. We select only the
# sub structures we want to include in the source space
labels_vol = ['Left-Amygdala',
'Left-Thalamus-Proper',
'Left-Cerebellum-Cortex',
'Brain-Stem',
'Right-Amygdala',
'Right-Thalamus-Proper',
'Right-Cerebellum-Cortex']
# Setup a surface-based source space, oct5 is not very dense (just used
# to speed up this example; we recommend oct6 in actual analyses)
src = setup_source_space(subject, subjects_dir=subjects_dir,
spacing='oct5', add_dist=False)
# Setup a volume source space
# set pos=10.0 for speed, not very accurate; we recommend something smaller
# like 5.0 in actual analyses:
vol_src = setup_volume_source_space(
subject, mri=fname_aseg, pos=10.0, bem=fname_model,
add_interpolator=False, # just for speed, usually use True
volume_label=labels_vol, subjects_dir=subjects_dir)
# Generate the mixed source space
src += vol_src
# compute the fwd matrix
fwd = make_forward_solution(fname_raw, fname_trans, src, fname_bem,
mindist=5.0, # ignore sources<=5mm from innerskull
meg=True, eeg=False, n_jobs=1)
# Load data
raw = read_raw_fif(fname_raw, preload=True)
noise_cov = mne.read_cov(fname_cov)
events = mne.read_events(fname_event)
# Add a bad channel
raw.info['bads'] += ['MEG 2443']
# Pick MEG channels
picks = mne.pick_types(raw.info, meg=True, eeg=False, stim=False, eog=True,
exclude='bads')
# Define epochs for left-auditory condition
event_id, tmin, tmax = 1, -0.2, 0.5
epochs = mne.Epochs(raw, events, event_id, tmin, tmax, picks=picks,
baseline=(None, 0), reject=dict(mag=4e-12, grad=4000e-13,
eog=150e-6))
# Compute inverse solution and for each epoch
snr = 1.0 # use smaller SNR for raw data
inv_method = 'dSPM'
parc = 'aparc' # the parcellation to use, e.g., 'aparc' 'aparc.a2009s'
lambda2 = 1.0 / snr ** 2
# Compute inverse operator
inverse_operator = make_inverse_operator(raw.info, fwd, noise_cov,
depth=None, fixed=False)
stcs = apply_inverse_epochs(epochs, inverse_operator, lambda2, inv_method,
pick_ori=None, return_generator=True)
# Get labels for FreeSurfer 'aparc' cortical parcellation with 34 labels/hemi
labels_parc = mne.read_labels_from_annot(subject, parc=parc,
subjects_dir=subjects_dir)
# Average the source estimates within each label of the cortical parcellation
# and each sub structures contained in the src space
# If mode = 'mean_flip' this option is used only for the cortical label
src = inverse_operator['src']
label_ts = mne.extract_label_time_course(stcs, labels_parc, src,
mode='mean_flip',
allow_empty=True,
return_generator=False)
# We compute the connectivity in the alpha band and plot it using a circular
# graph layout
fmin = 8.
fmax = 13.
sfreq = raw.info['sfreq'] # the sampling frequency
con, freqs, times, n_epochs, n_tapers = spectral_connectivity(
label_ts, method='pli', mode='multitaper', sfreq=sfreq, fmin=fmin,
fmax=fmax, faverage=True, mt_adaptive=True, n_jobs=1)
# We create a list of Label containing also the sub structures
labels_aseg = mne.get_volume_labels_from_src(src, subject, subjects_dir)
labels = labels_parc + labels_aseg
# read colors
node_colors = [label.color for label in labels]
# We reorder the labels based on their location in the left hemi
label_names = [label.name for label in labels]
lh_labels = [name for name in label_names if name.endswith('lh')]
rh_labels = [name for name in label_names if name.endswith('rh')]
# Get the y-location of the label
label_ypos_lh = list()
for name in lh_labels:
idx = label_names.index(name)
ypos = np.mean(labels[idx].pos[:, 1])
label_ypos_lh.append(ypos)
try:
idx = label_names.index('Brain-Stem')
except ValueError:
pass
else:
ypos = np.mean(labels[idx].pos[:, 1])
lh_labels.append('Brain-Stem')
label_ypos_lh.append(ypos)
# Reorder the labels based on their location
lh_labels = [label for (yp, label) in sorted(zip(label_ypos_lh, lh_labels))]
# For the right hemi
rh_labels = [label[:-2] + 'rh' for label in lh_labels
if label != 'Brain-Stem' and label[:-2] + 'rh' in rh_labels]
# Save the plot order
node_order = list()
node_order = lh_labels[::-1] + rh_labels
node_angles = circular_layout(label_names, node_order, start_pos=90,
group_boundaries=[0, len(label_names) // 2])
# Plot the graph using node colors from the FreeSurfer parcellation. We only
# show the 300 strongest connections.
conmat = con[:, :, 0]
fig = plt.figure(num=None, figsize=(8, 8), facecolor='black')
plot_connectivity_circle(conmat, label_names, n_lines=300,
node_angles=node_angles, node_colors=node_colors,
title='All-to-All Connectivity left-Auditory '
'Condition (PLI)', fig=fig, interactive=False)
```

Out:

```
Setting up the source space with the following parameters:
SUBJECTS_DIR = /home/circleci/mne_data/MNE-sample-data/subjects
Subject = sample
Surface = white
Octahedron subdivision grade 5
>>> 1. Creating the source space...
Doing the octahedral vertex picking...
Loading /home/circleci/mne_data/MNE-sample-data/subjects/sample/surf/lh.white...
Mapping lh sample -> oct (5) ...
Triangle neighbors and vertex normals...
Loading geometry from /home/circleci/mne_data/MNE-sample-data/subjects/sample/surf/lh.sphere...
Setting up the triangulation for the decimated surface...
loaded lh.white 1026/155407 selected to source space (oct = 5)
Loading /home/circleci/mne_data/MNE-sample-data/subjects/sample/surf/rh.white...
Mapping rh sample -> oct (5) ...
Triangle neighbors and vertex normals...
Loading geometry from /home/circleci/mne_data/MNE-sample-data/subjects/sample/surf/rh.sphere...
Setting up the triangulation for the decimated surface...
loaded rh.white 1026/156866 selected to source space (oct = 5)
You are now one step closer to computing the gain matrix
BEM file : /home/circleci/mne_data/MNE-sample-data/subjects/sample/bem/sample-5120-bem.fif
grid : 10.0 mm
mindist : 5.0 mm
MRI volume : /home/circleci/mne_data/MNE-sample-data/subjects/sample/mri/aseg.mgz
Loaded inner skull from /home/circleci/mne_data/MNE-sample-data/subjects/sample/bem/sample-5120-bem.fif (2562 nodes)
Surface CM = ( 0.7 -10.0 44.3) mm
Surface fits inside a sphere with radius 91.8 mm
Surface extent:
x = -66.7 ... 68.8 mm
y = -88.0 ... 79.0 mm
z = -44.5 ... 105.8 mm
Grid extent:
x = -70.0 ... 70.0 mm
y = -90.0 ... 80.0 mm
z = -50.0 ... 110.0 mm
4590 sources before omitting any.
2961 sources after omitting infeasible sources.
Source spaces are in MRI coordinates.
Checking that the sources are inside the bounding surface and at least 5.0 mm away (will take a few...)
1372 source space points omitted because they are outside the inner skull surface.
283 source space points omitted because of the 5.0-mm distance limit.
Thank you for waiting.
1306 sources remaining after excluding the sources outside the surface and less than 5.0 mm inside.
Selecting voxels from Left-Amygdala
2 sources remaining after excluding sources too far from VOI voxels
Adjusting the neighborhood info...
Surface CM = ( 0.7 -10.0 44.3) mm
Surface fits inside a sphere with radius 91.8 mm
Surface extent:
x = -66.7 ... 68.8 mm
y = -88.0 ... 79.0 mm
z = -44.5 ... 105.8 mm
Grid extent:
x = -70.0 ... 70.0 mm
y = -90.0 ... 80.0 mm
z = -50.0 ... 110.0 mm
4590 sources before omitting any.
2961 sources after omitting infeasible sources.
Source spaces are in MRI coordinates.
Checking that the sources are inside the bounding surface and at least 5.0 mm away (will take a few...)
1372 source space points omitted because they are outside the inner skull surface.
283 source space points omitted because of the 5.0-mm distance limit.
Thank you for waiting.
1306 sources remaining after excluding the sources outside the surface and less than 5.0 mm inside.
Selecting voxels from Left-Thalamus-Proper
9 sources remaining after excluding sources too far from VOI voxels
Adjusting the neighborhood info...
Surface CM = ( 0.7 -10.0 44.3) mm
Surface fits inside a sphere with radius 91.8 mm
Surface extent:
x = -66.7 ... 68.8 mm
y = -88.0 ... 79.0 mm
z = -44.5 ... 105.8 mm
Grid extent:
x = -70.0 ... 70.0 mm
y = -90.0 ... 80.0 mm
z = -50.0 ... 110.0 mm
4590 sources before omitting any.
2961 sources after omitting infeasible sources.
Source spaces are in MRI coordinates.
Checking that the sources are inside the bounding surface and at least 5.0 mm away (will take a few...)
1372 source space points omitted because they are outside the inner skull surface.
283 source space points omitted because of the 5.0-mm distance limit.
Thank you for waiting.
1306 sources remaining after excluding the sources outside the surface and less than 5.0 mm inside.
Selecting voxels from Left-Cerebellum-Cortex
33 sources remaining after excluding sources too far from VOI voxels
Adjusting the neighborhood info...
Surface CM = ( 0.7 -10.0 44.3) mm
Surface fits inside a sphere with radius 91.8 mm
Surface extent:
x = -66.7 ... 68.8 mm
y = -88.0 ... 79.0 mm
z = -44.5 ... 105.8 mm
Grid extent:
x = -70.0 ... 70.0 mm
y = -90.0 ... 80.0 mm
z = -50.0 ... 110.0 mm
4590 sources before omitting any.
2961 sources after omitting infeasible sources.
Source spaces are in MRI coordinates.
Checking that the sources are inside the bounding surface and at least 5.0 mm away (will take a few...)
1372 source space points omitted because they are outside the inner skull surface.
283 source space points omitted because of the 5.0-mm distance limit.
Thank you for waiting.
1306 sources remaining after excluding the sources outside the surface and less than 5.0 mm inside.
Selecting voxels from Brain-Stem
21 sources remaining after excluding sources too far from VOI voxels
Adjusting the neighborhood info...
Surface CM = ( 0.7 -10.0 44.3) mm
Surface fits inside a sphere with radius 91.8 mm
Surface extent:
x = -66.7 ... 68.8 mm
y = -88.0 ... 79.0 mm
z = -44.5 ... 105.8 mm
Grid extent:
x = -70.0 ... 70.0 mm
y = -90.0 ... 80.0 mm
z = -50.0 ... 110.0 mm
4590 sources before omitting any.
2961 sources after omitting infeasible sources.
Source spaces are in MRI coordinates.
Checking that the sources are inside the bounding surface and at least 5.0 mm away (will take a few...)
1372 source space points omitted because they are outside the inner skull surface.
283 source space points omitted because of the 5.0-mm distance limit.
Thank you for waiting.
1306 sources remaining after excluding the sources outside the surface and less than 5.0 mm inside.
Selecting voxels from Right-Amygdala
1 sources remaining after excluding sources too far from VOI voxels
Adjusting the neighborhood info...
Surface CM = ( 0.7 -10.0 44.3) mm
Surface fits inside a sphere with radius 91.8 mm
Surface extent:
x = -66.7 ... 68.8 mm
y = -88.0 ... 79.0 mm
z = -44.5 ... 105.8 mm
Grid extent:
x = -70.0 ... 70.0 mm
y = -90.0 ... 80.0 mm
z = -50.0 ... 110.0 mm
4590 sources before omitting any.
2961 sources after omitting infeasible sources.
Source spaces are in MRI coordinates.
Checking that the sources are inside the bounding surface and at least 5.0 mm away (will take a few...)
1372 source space points omitted because they are outside the inner skull surface.
283 source space points omitted because of the 5.0-mm distance limit.
Thank you for waiting.
1306 sources remaining after excluding the sources outside the surface and less than 5.0 mm inside.
Selecting voxels from Right-Thalamus-Proper
7 sources remaining after excluding sources too far from VOI voxels
Adjusting the neighborhood info...
Surface CM = ( 0.7 -10.0 44.3) mm
Surface fits inside a sphere with radius 91.8 mm
Surface extent:
x = -66.7 ... 68.8 mm
y = -88.0 ... 79.0 mm
z = -44.5 ... 105.8 mm
Grid extent:
x = -70.0 ... 70.0 mm
y = -90.0 ... 80.0 mm
z = -50.0 ... 110.0 mm
4590 sources before omitting any.
2961 sources after omitting infeasible sources.
Source spaces are in MRI coordinates.
Checking that the sources are inside the bounding surface and at least 5.0 mm away (will take a few...)
1372 source space points omitted because they are outside the inner skull surface.
283 source space points omitted because of the 5.0-mm distance limit.
Thank you for waiting.
1306 sources remaining after excluding the sources outside the surface and less than 5.0 mm inside.
Selecting voxels from Right-Cerebellum-Cortex
44 sources remaining after excluding sources too far from VOI voxels
Adjusting the neighborhood info...
Reading /home/circleci/mne_data/MNE-sample-data/subjects/sample/mri/aseg.mgz...
Reading /home/circleci/mne_data/MNE-sample-data/subjects/sample/mri/aseg.mgz...
Reading /home/circleci/mne_data/MNE-sample-data/subjects/sample/mri/aseg.mgz...
Reading /home/circleci/mne_data/MNE-sample-data/subjects/sample/mri/aseg.mgz...
Reading /home/circleci/mne_data/MNE-sample-data/subjects/sample/mri/aseg.mgz...
Reading /home/circleci/mne_data/MNE-sample-data/subjects/sample/mri/aseg.mgz...
Reading /home/circleci/mne_data/MNE-sample-data/subjects/sample/mri/aseg.mgz...
Source space : <SourceSpaces: [<surface (lh), n_vertices=155407, n_used=1026, coordinate_frame=MRI (surface RAS)>, <surface (rh), n_vertices=156866, n_used=1026, coordinate_frame=MRI (surface RAS)>, <volume (Left-Amygdala), n_used=2, coordinate_frame=MRI (surface RAS)>, <volume (Left-Thalamus-Proper), n_used=9, coordinate_frame=MRI (surface RAS)>, <volume (Left-Cerebellum-Cortex), n_used=33, coordinate_frame=MRI (surface RAS)>, <volume (Brain-Stem), n_used=21, coordinate_frame=MRI (surface RAS)>, <volume (Right-Amygdala), n_used=1, coordinate_frame=MRI (surface RAS)>, <volume (Right-Thalamus-Proper), n_used=7, coordinate_frame=MRI (surface RAS)>, <volume (Right-Cerebellum-Cortex), n_used=44, coordinate_frame=MRI (surface RAS)>]>
MRI -> head transform : /home/circleci/mne_data/MNE-sample-data/MEG/sample/sample_audvis_raw-trans.fif
Measurement data : sample_audvis_filt-0-40_raw.fif
Conductor model : /home/circleci/mne_data/MNE-sample-data/subjects/sample/bem/sample-5120-bem-sol.fif
Accurate field computations
Do computations in head coordinates
Free source orientations
Read 9 source spaces a total of 2169 active source locations
Coordinate transformation: MRI (surface RAS) -> head
0.999310 0.009985 -0.035787 -3.17 mm
0.012759 0.812405 0.582954 6.86 mm
0.034894 -0.583008 0.811716 28.88 mm
0.000000 0.000000 0.000000 1.00
Read 306 MEG channels from info
84 coil definitions read
Coordinate transformation: MEG device -> head
0.991420 -0.039936 -0.124467 -6.13 mm
0.060661 0.984012 0.167456 0.06 mm
0.115790 -0.173570 0.977991 64.74 mm
0.000000 0.000000 0.000000 1.00
MEG coil definitions created in head coordinates.
Source spaces are now in head coordinates.
Setting up the BEM model using /home/circleci/mne_data/MNE-sample-data/subjects/sample/bem/sample-5120-bem-sol.fif...
Loading surfaces...
Homogeneous model surface loaded.
Loading the solution matrix...
Loaded linear_collocation BEM solution from /home/circleci/mne_data/MNE-sample-data/subjects/sample/bem/sample-5120-bem-sol.fif
Employing the head->MRI coordinate transform with the BEM model.
BEM model sample-5120-bem-sol.fif is now set up
Source spaces are in head coordinates.
Checking that the sources are inside the bounding surface and at least 5.0 mm away (will take a few...)
84 source space point omitted because of the 5.0-mm distance limit.
84 source space point omitted because of the 5.0-mm distance limit.
Thank you for waiting.
Setting up compensation data...
No compensation set. Nothing more to do.
Composing the field computation matrix...
Computing MEG at 2001 source locations (free orientations)...
Finished.
Opening raw data file /home/circleci/mne_data/MNE-sample-data/MEG/sample/sample_audvis_filt-0-40_raw.fif...
Read a total of 4 projection items:
PCA-v1 (1 x 102) idle
PCA-v2 (1 x 102) idle
PCA-v3 (1 x 102) idle
Average EEG reference (1 x 60) idle
Range : 6450 ... 48149 = 42.956 ... 320.665 secs
Ready.
Current compensation grade : 0
Reading 0 ... 41699 = 0.000 ... 277.709 secs...
306 x 306 full covariance (kind = 1) found.
Read a total of 3 projection items:
PCA-v1 (1 x 102) active
PCA-v2 (1 x 102) active
PCA-v3 (1 x 102) active
72 matching events found
Applying baseline correction (mode: mean)
Not setting metadata
Created an SSP operator (subspace dimension = 3)
4 projection items activated
info["bads"] and noise_cov["bads"] do not match, excluding bad channels from both
Computing inverse operator with 305 channels.
Created an SSP operator (subspace dimension = 3)
estimated rank (mag + grad): 302
Setting small MEG eigenvalues to zero.
Not doing PCA for MEG.
Created the whitener using a noise covariance matrix with rank 302 (3 small eigenvalues omitted)
Computing inverse operator with 305 channels.
Creating the source covariance matrix
Whitening the forward solution.
Adjusting source covariance matrix.
Computing SVD of whitened and weighted lead field matrix.
largest singular value = 6.38137
scaling factor to adjust the trace = 1.17172e+21
Reading labels from parcellation...
read 34 labels from /home/circleci/mne_data/MNE-sample-data/subjects/sample/label/lh.aparc.annot
read 34 labels from /home/circleci/mne_data/MNE-sample-data/subjects/sample/label/rh.aparc.annot
Preparing the inverse operator for use...
Scaled noise and source covariance from nave = 1 to nave = 1
Created the regularized inverter
Created an SSP operator (subspace dimension = 3)
Created the whitener using a noise covariance matrix with rank 302 (3 small eigenvalues omitted)
Computing noise-normalization factors (dSPM)...
[done]
Picked 305 channels from the data
Computing inverse...
Eigenleads need to be weighted ...
Processing epoch : 1
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 2
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 3
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 4
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 5
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 6
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 7
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 8
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 9
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 10
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Rejecting epoch based on EOG : ['EOG 061']
Processing epoch : 11
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 12
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 13
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Rejecting epoch based on EOG : ['EOG 061']
Rejecting epoch based on EOG : ['EOG 061']
Processing epoch : 14
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 15
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 16
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 17
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Rejecting epoch based on EOG : ['EOG 061']
Processing epoch : 18
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 19
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 20
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Rejecting epoch based on EOG : ['EOG 061']
Processing epoch : 21
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 22
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 23
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Rejecting epoch based on MAG : ['MEG 1711']
Processing epoch : 24
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 25
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 26
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 27
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 28
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Rejecting epoch based on EOG : ['EOG 061']
Processing epoch : 29
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 30
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 31
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Rejecting epoch based on EOG : ['EOG 061']
Processing epoch : 32
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 33
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Rejecting epoch based on EOG : ['EOG 061']
Processing epoch : 34
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 35
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Rejecting epoch based on EOG : ['EOG 061']
Rejecting epoch based on EOG : ['EOG 061']
Processing epoch : 36
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Rejecting epoch based on EOG : ['EOG 061']
Rejecting epoch based on EOG : ['EOG 061']
Processing epoch : 37
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 38
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 39
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 40
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 41
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 42
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 43
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 44
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Rejecting epoch based on EOG : ['EOG 061']
Processing epoch : 45
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Rejecting epoch based on EOG : ['EOG 061']
Processing epoch : 46
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 47
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 48
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Rejecting epoch based on EOG : ['EOG 061']
Rejecting epoch based on EOG : ['EOG 061']
Processing epoch : 49
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 50
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 51
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 52
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 53
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 54
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
Processing epoch : 55
combining the current components...
Extracting time courses for 75 labels (mode: mean_flip)
[done]
Connectivity computation...
only using indices for lower-triangular matrix
computing connectivity for 2775 connections
using t=0.000s..0.699s for estimation (106 points)
frequencies: 8.5Hz..12.7Hz (4 points)
connectivity scores will be averaged for each band
Using multitaper spectrum estimation with 7 DPSS windows
the following metrics will be computed: PLI
computing connectivity for epoch 1
computing connectivity for epoch 2
computing connectivity for epoch 3
computing connectivity for epoch 4
computing connectivity for epoch 5
computing connectivity for epoch 6
computing connectivity for epoch 7
computing connectivity for epoch 8
computing connectivity for epoch 9
computing connectivity for epoch 10
computing connectivity for epoch 11
computing connectivity for epoch 12
computing connectivity for epoch 13
computing connectivity for epoch 14
computing connectivity for epoch 15
computing connectivity for epoch 16
computing connectivity for epoch 17
computing connectivity for epoch 18
computing connectivity for epoch 19
computing connectivity for epoch 20
computing connectivity for epoch 21
computing connectivity for epoch 22
computing connectivity for epoch 23
computing connectivity for epoch 24
computing connectivity for epoch 25
computing connectivity for epoch 26
computing connectivity for epoch 27
computing connectivity for epoch 28
computing connectivity for epoch 29
computing connectivity for epoch 30
computing connectivity for epoch 31
computing connectivity for epoch 32
computing connectivity for epoch 33
computing connectivity for epoch 34
computing connectivity for epoch 35
computing connectivity for epoch 36
computing connectivity for epoch 37
computing connectivity for epoch 38
computing connectivity for epoch 39
computing connectivity for epoch 40
computing connectivity for epoch 41
computing connectivity for epoch 42
computing connectivity for epoch 43
computing connectivity for epoch 44
computing connectivity for epoch 45
computing connectivity for epoch 46
computing connectivity for epoch 47
computing connectivity for epoch 48
computing connectivity for epoch 49
computing connectivity for epoch 50
computing connectivity for epoch 51
computing connectivity for epoch 52
computing connectivity for epoch 53
computing connectivity for epoch 54
computing connectivity for epoch 55
assembling connectivity matrix (filling the upper triangular region of the matrix)
[Connectivity computation done]
```

By default matplotlib does not save using the facecolor, even though this was set when the figure was generated. If not set via savefig, the labels, title, and legend will be cut off from the output png file.

```
# fname_fig = data_path + '/MEG/sample/plot_mixed_connect.png'
# plt.savefig(fname_fig, facecolor='black')
```

**Total running time of the script:** ( 1 minutes 39.908 seconds)

**Estimated memory usage:** 1727 MB