Skip to content

Instantly share code, notes, and snippets.

View agramfort's full-sized avatar

Alexandre Gramfort agramfort

View GitHub Profile
#%% import ####################################################################
import mne
import numpy as np
import os
from mne.datasets import sample
data_path = sample.data_path()
#%% load group avg data #######################################################
os.environ["SUBJECTS_DIR"] = data_path + '/subjects'
import numpy as np
from mayavi import mlab
from surfer import Brain
import mne
from mne.datasets import sample
data_path = sample.data_path()
subjects_dir = data_path + '/subjects'
import numpy as np
from scipy import signal
import mne
from mne import (read_forward_solution, read_cov, read_label,
pick_types_evoked, pick_types_forward, read_evokeds)
from mne.io import Raw
from mne.datasets import sample
from mne.time_frequency import iir_filter_raw, morlet
from mne.simulation import generate_sparse_stc
from scipy import stats
class GaussianKernelDensityEstimation(object):
"""docstring for GaussianKernelDensityEstimation"""
def __init__(self):
self.gkde = None
def fit(self, X):
"""docstring for fit"""
self.gkde = stats.gaussian_kde(X.T)
"""
==========================
Feature Selection Shootout
==========================
Illustration of feature selection with :
- RFE-SVC
- Anova-SVC
- L1-Logistic Regression
"""
"""
Author: Oliver Mitevski
References:
A Generalized Linear Model for Principal Component Analysis of Binary Data,
Andrew I. Schein; Lawrence K. Saul; Lyle H. Ungar
The code was translated and adapted from Jakob Verbeek's
"Hidden Markov models and mixtures for Binary PCA" implementation in MATLAB
@agramfort
agramfort / test_linear_svc.py
Created May 22, 2011 12:53
test LinearSVC variance pb
from pprint import pprint
import numpy as np
from scipy import sparse
from scikits.learn.grid_search import GridSearchCV
from scikits.learn.cross_val import StratifiedKFold
from scikits.learn.metrics import f1_score, classification_report
from scikits.learn import svm
from scikits.learn.linear_model import LogisticRegression
from scikits.learn.linear_model.sparse import LogisticRegression as SparseLogisticRegression
@agramfort
agramfort / gist:1108519
Created July 27, 2011 02:07
Testing the difference between two coefficients of correlation
"""Testing the difference between two coefficients of correlation
Following:
Thöni, H. (1977), Testing the Difference Between two Coefficients of Correlation.
Biometrical Journal, 19: 355–359. doi: 10.1002/bimj.4710190506
http://onlinelibrary.wiley.com/doi/10.1002/bimj.4710190506/abstract
"""
from math import log, sqrt
@agramfort
agramfort / om_viz.py
Created September 23, 2011 13:18
OpenMEEG data basic viewer based on Python and Mayavi2
#!/usr/bin/env python
"""
Simple viewer for tri mesh files and OpenMEEG geometry files
Usage
-----
om_viz.py model.geom mesh1.tri mesh2.tri dipoles.txt
@agramfort
agramfort / gist:1357024
Created November 11, 2011 02:41
parameter scaling by n_samples pb
import numpy as np
from scipy import linalg
from sklearn import datasets, svm, linear_model
from sklearn.svm import l1_min_c
iris = datasets.load_iris()
X = iris.data
y = iris.target