Skip to content

Instantly share code, notes, and snippets.

View sylvchev's full-sized avatar

Sylvain Chevallier sylvchev

View GitHub Profile
@sylvchev
sylvchev / MLA-GD-strategies.ipynb
Last active February 8, 2024 16:50
MLA - gradient descent
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sylvchev
sylvchev / generate_spd_mat.py
Last active June 27, 2023 09:44
Generate SPD matrices for EEG-based BCI
import numpy as np
from numpy.random import chisquare
from scipy.stats import lognorm
import scipy as sp
import pyriemann
from sklearn.pipeline import Pipeline
from sklearn.decomposition import PCA
from pyriemann.tangentspace import TangentSpace
@sylvchev
sylvchev / CSP_filters.py
Last active March 26, 2023 00:14
CSP filter on EEG data with MNE and Pyriemann
from mne import create_info, EpochsArray
from mne.decoding import CSP as CSP_MNE
from moabb.datasets import BNCI2014001
from moabb.paradigms import LeftRightImagery
import numpy as np
from pyriemann.estimation import Covariances
from pyriemann.spatialfilters import CSP as CSP_Pyr
n_components=8
@sylvchev
sylvchev / ntx_hackathon_22_starting_kit.py
Created October 30, 2022 16:57
Starting kit for brain age prediction challenge for the NeuroTechX Hackathon 2022
######################################################################################################
# ________ _________ ___ ___ ___ ___ ________ ________ ___ __ _______ _______
# |\ ___ \|\___ ___\|\ \ / /|\ \|\ \|\ __ \|\ ____\|\ \|\ \ / ___ \ / ___ \
# \ \ \\ \ \|___ \ \_|\ \ \/ / | \ \\\ \ \ \|\ \ \ \___|\ \ \/ /|_/__/|_/ //__/|_/ /|
# \ \ \\ \ \ \ \ \ \ \ / / \ \ __ \ \ __ \ \ \ \ \ ___ \__|// / /__|// / /
# \ \ \\ \ \ \ \ \ / \/ \ \ \ \ \ \ \ \ \ \ \____\ \ \\ \ \ / /_/__ / /_/__
# \ \__\\ \__\ \ \__\/ /\ \ \ \__\ \__\ \__\ \__\ \_______\ \__\\ \__\|\________\\________\
# \|__| \|__| \|__/__/ /\ __\ \|__|\|__|\|__|\|__|\|_______|\|__| \|__| \|_______|\|_______|
# |__|/ \|__|
######################################################################################################
@sylvchev
sylvchev / mne_manual_annotation.py
Created November 15, 2021 12:01
Manually annotate raw MNE objects on GUI, save annotation file, create events from annotations.
from mne import find_events, events_from_annotations
import mne
# get some raw data, replace by your own files
from moabb.datasets import BNCI2014001
sessions = BNCI2014001().get_data(subjects=[1])
raw = sessions[1]['session_T']['run_1']
ev = find_events(raw)
# Annotate plot
@sylvchev
sylvchev / moabb_channel_order.py
Created September 1, 2021 17:17
Check channel order with MOABB
from moabb.datasets import Cho2017, BNCI2014001, PhysionetMI
from moabb.paradigms import MotorImagery
from moabb.datasets.utils import find_intersecting_channels
datasets = [Cho2017(), BNCI2014001(), PhysionetMI()]
common_channels, _ = find_intersecting_channels(datasets)
chans = common_channels[:3]
paradigm = MotorImagery(channels=chans)
@sylvchev
sylvchev / to_scikit_learn_API.ipynb
Created June 15, 2021 11:21 — forked from gemeinl/to_scikit_learn_API.ipynb
Braindecode with sci-kit learn pipeline chaining
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sylvchev
sylvchev / channel_selection_moabb.py
Created July 11, 2020 14:44
Channel selection in MOABB
import moabb
from moabb.datasets import BNCI2014001, Zhou2016
from moabb.paradigms import LeftRightImagery
from moabb.evaluations import WithinSessionEvaluation
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA
from sklearn.pipeline import make_pipeline
from mne.decoding import CSP
@sylvchev
sylvchev / environment.yml
Last active March 16, 2022 10:22
MOABB conda env
name: moabb
channels:
- conda-forge
- defaults
dependencies:
- python>=3.9
- numpy
- scipy
- scikit-learn
- mne
@sylvchev
sylvchev / compare_tex_file.py
Last active September 26, 2018 16:41
Shell script to compare tex files in python with difflib, output HTML file to highlight the difference.
#!/usr/bin/env python
import sys
import re
import difflib as dl
if __name__ == '__main__':
if len(sys.argv) < 3 or len(sys.argv) > 5:
print ("usage: %s file1 file2 [output.html]" % sys.argv[0])
sys.exit(0)