Skip to content

Instantly share code, notes, and snippets.

"""
Reference
---------
[1] Mingzhou Ding, Yonghong Chen. Granger Causality: Basic Theory and Application
to Neuroscience.Elsevier Science, 7 February 2008.
"""
import scot
import numpy as np
from scipy import linalg
def compute_order(X, m_max):
@dongqunxi
dongqunxi / Functional lables from spatial-temporal clustering
Created August 11, 2016 16:07
Get functional labels with the help of spatial-temporal clustering.
# Generate source_estimate from significant clusters
stc = summarize_clusters_stc(clu, p_thre, tstep=tstep,
tmin=tmin, vertices=fsave_vertices,
subject='fsaverage')
# Generate thresholded source estimate
stc_sub = stc.copy().mean()
data = np.zeros(stc_sub.data.shape)
data[:, 0] = stc.data[:, 0]
abs_data = abs(data)
abs_data[abs_data < thr] = 0
@dongqunxi
dongqunxi / pdc_dtf.py
Last active August 29, 2015 14:12 — forked from agramfort/pdc_dtf.py
Try to realize the model order estimation across trials
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Implements Partial Directed Coherence and Direct Transfer Function
using multi-trials' MVAR processes.
Reference
---------
[1] Luiz A. Baccala and Koichi Sameshima. Partial directed coherence:
a new concept in neural structure determination.
#%% import ####################################################################
import mne
import numpy as np
import os
#%% load group avg data #######################################################
os.environ["SUBJECTS_DIR"] = \
"/freesurfer/RH4-x86_64-R530/subjects"
src_path = \
'/MNE-sample-data/subjects/fsaverage/bem/fsaverage-ico-5-src.fif';