Skip to content

Instantly share code, notes, and snippets.

View agramfort's full-sized avatar

Alexandre Gramfort agramfort

View GitHub Profile
@agramfort
agramfort / pythreejs_test.ipynb
Created April 4, 2017 22:48
MNE + pythreejs
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@agramfort
agramfort / miss_val_bench.py
Created February 8, 2016 15:56 — forked from raghavrv/.gitignore
RF Missing Value Benchmark script
import numpy as np
from sklearn.datasets import fetch_covtype
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import StratifiedShuffleSplit
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import Imputer
from sklearn.model_selection import cross_val_score
rng = np.random.RandomState(0)
@agramfort
agramfort / lasso_ista_fista.py
Created January 31, 2016 14:33
Lasso with ISTA and FISTA
#!/usr/bin/env python
#
# Solve LASSO regression problem with ISTA and FISTA
# iterative solvers.
# Author : Alexandre Gramfort, [email protected]
# License BSD
import time
from math import sqrt
import time
import numpy as np
from scipy import linalg, io, sparse
import matplotlib.pyplot as plt
from sklearn.externals.joblib import Memory
from sklearn.linear_model import lasso_path
from sklearn.datasets.mldata import fetch_mldata
from sklearn import datasets
@agramfort
agramfort / demo_neo_mne.py
Created October 15, 2014 15:09
NEO + MNE Integration Demo
import os
import neo
import numpy as np
import mne
dirname = './data_Micromed/'
trc_filename = 'EEG_33.TRC'
fname = os.path.join(dirname, trc_filename)
def raw_from_neo(fname):
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
@agramfort
agramfort / pdc_dtf.py
Created March 30, 2014 16:33
Partial Directed Coherence and Direct Transfer Function using MVAR processes
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Implements Partial Directed Coherence and Direct Transfer Function
using MVAR processes.
Reference
---------
Luiz A. Baccala and Koichi Sameshima. Partial directed coherence:
a new concept in neural structure determination.
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'
@agramfort
agramfort / output.txt
Created March 16, 2014 08:05
Test effect of nave on dSPM
returns:
27.0745537031
365.073216463
27.1356784749
#%% 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'