Skip to content

Instantly share code, notes, and snippets.

View kingjr's full-sized avatar

Jean-Rémi KING kingjr

View GitHub Profile
def plot_evoked_img(evoked, picks=None, exclude='bads', unit=True, show=True,
ylim=None, proj=False, xlim='tight', hline=None, units=None,
scalings=None, titles=None, axes=None):
"""Plot evoked data as an image (chan x time) where color index amplitude
Parameters
----------
evoked : instance of Evoked
The evoked data
@kingjr
kingjr / plot_decoding_time_generalization_advanced.py
Created June 1, 2014 20:36
Set of temporal generalization examples using MNE-python & sklearn
"""
========================================================
Decoding sensor space data with over-time generalization
========================================================
This example runs the analysis computed in:
Jean-Remi King, Alexandre Gramfort, Aaron Schurger, Lionel Naccache
and Stanislas Dehaene, "Two distinct dynamic modes subtend the detection of
unexpected sounds", PLOS ONE, 2013
@kingjr
kingjr / Plot_decoding_time_generalization_ProbasDistance.py
Created June 2, 2014 09:00
Why are probabilistic outputs better than non-probabilistic ones?
"""
==========================
Better with probabilities?
==========================
Comparing classification performance of SVC versus SVC+Platt
using an MEG example from MNE-python.
"""
# Authors: Jean-Remi King <[email protected]>
#
@kingjr
kingjr / example_univariate_gat.py
Last active August 29, 2015 14:07
This example illustrate how a simple univariate analysis can be applied to performe a generalization across time analysis, and thus help the reader conceptualize what is at stake in the analysis
# Authors: Jean-Remi King <[email protected]>
"""
This example illustrate how a simple univariate analysis can be applied to
performe a generalization across time analysis, and thus help the reader
conceptualize what is at stake in the analysis"""
import numpy as np
from sklearn.preprocessing import StandardScaler
from sklearn.svm import SVC
import numpy as np
from matplotlib.colors import LinearSegmentedColormap
class nlcmap(LinearSegmentedColormap):
"""
nlcmap - a nonlinear cmap from specified levels
Copyright (c) 2006-2007, Robert Hetland <[email protected]>
Release under MIT license.
@kingjr
kingjr / example_lda_heteregeneous_subsampling.py
Created November 20, 2014 11:20
Test to see how subsampling can increase decoding scores
import numpy as np
from sklearn.cross_validation import cross_val_score, KFold
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.lda import LDA
def add_information(X, SNR, prop):
''' Introduce differences between
Input
# Authors: Jean-Remi King <[email protected]>
#
# License: BSD (3-clause)
""" This aims at showing how the MNE GAT object can be used to score different
subsets of data"""
import copy
import numpy as np
import mne
# Author: Jean-Remi King <[email protected]>
#
# License: BSD (3-clause)
import numpy as np
import matplotlib.pyplot as plt
from mne import read_evokeds
from mne.datasets.megsim import load_data
from mne.viz.topomap import _griddata, _prepare_topo_plot
"""
===================================
WIP Prepare multiconditions events
===================================
"""
# Authors: Jean-Remi King <[email protected]>
#
# License: BSD (3-clause)
@kingjr
kingjr / svc_light_example.py
Last active August 29, 2015 14:20
This aims at reproducing the sklearn.svm.SVC object without having to store 'support_vectors_' and '_dual_coef_'
# Author: Jean-Remi King <[email protected]>
#
# License: BSD (3-clause)
import warnings
import numpy as np
import scipy.sparse as sp
from sklearn.svm import SVC, LinearSVC
from sklearn.datasets import make_classification
from sklearn.calibration import CalibratedClassifierCV