In this short tutorial, we will load some data stored into MATLAB files, and see how we can get help dyconnmap's functions.
First things first. We are going to use scipy's io
submodule to load our MATLAB workspace with some sample EEG signals.
import numpy as np
import scipy
from scipy import io
dyconnmap
supports the standard NumPy arrays, so, it's up to the user to import the data. For example, one could load a Nifti file (using i.e. nibabel) and fetch the internal structure that is a standard numpy array.
data = scipy.io.loadmat('sample_eeg/eyes_open.mat')
eeg = np.squeeze(data['eyes_open'])
fs = 160.0
num_trials = 101
num_samples_vis = 160 * 3
After loading the data, inspect them; find out home many channels and samples are available.
num_channels, num_samples = np.shape(eeg[0])
print("""
trials: {0}
channels: {1}
samples: {2}
""".format(num_trials, num_channels, num_samples))
trials: 101 channels: 64 samples: 9600
eeg1 = eeg[0]
dyconnmap's available submodules are
fc
for functional connectivitygraphs
for graph analysis,cluster
for clustering algorithmsts
for (symbolic) time seriesimport warnings
warnings.simplefilter(action='ignore', category=FutureWarning)
from dyconnmap.fc import iplv
Most estimators' functions signatures rely on the same inputs. One can reference to the docstrings or simply read the whole documentation with the command (i.e.) help(iplv)
.
help(iplv)
Help on function iplv in module dyconnmap.fc.iplv: iplv(data, fb, fs, pairs=None) Imaginary part of Phase Locking Value Compute the Imaginary part of Phase Locking Value for the given *data*, between the *pairs* (if given) of channels. Parameters ---------- data : array-like, shape(n_channels, n_samples) Multichannel recording data. fb : list of length 2 The low and high frequencies. fs : float Sampling frequency. pairs : array-like or `None` - If an `array-like` is given, notice that each element is a tuple of length two. - If `None` is passed, complete connectivity will be assumed. Returns ------- ts : array-like, shape(n_channels, n_channels, n_samples) Estimated IPLV time series. avg : array-like, shape = [n_electrodes, n_electrodes] Average IPLV.
The pairs
argument is optional, and usually is ignored.