Skip to content

Instantly share code, notes, and snippets.

View sylvchev's full-sized avatar

Sylvain Chevallier sylvchev

View GitHub Profile
@sylvchev
sylvchev / convert_gdf_to_mat.m
Created May 11, 2018 02:59
Convert EEG GDF file to matlab file (then python)
clear all
datadir='/path/to/data/ssvep-esta/';
for i = 2:2
subjdir = strcat(datadir, sprintf('subject%2.2d/', i));
files = dir(strcat(subjdir, '*.gdf'));
for f=1:length(files)
[s,h] = sload(strcat(subjdir, files(f).name));
EVENTTYP = h.EVENT.TYP;
EVENTPOS = h.EVENT.POS;
SampleRate = h.SampleRate;
@sylvchev
sylvchev / verif_weighted_mean_spd.py
Last active April 15, 2020 08:28
Verification regarding weighted means of SPD matrices
import pyriemann
import numpy as np
from pyriemann.utils.mean import mean_riemann
def generate_cov(Nt, Ne):
"""Generate a set of cavariances matrices for test purpose"""
rs = np.random.RandomState(1234)
diags = 2.0 + 0.1 * rs.randn(Nt, Ne)
A = 2*rs.rand(Ne, Ne) - 1
A /= np.atleast_2d(np.sqrt(np.sum(A**2, 1))).T
@sylvchev
sylvchev / clustering_sujet_stage.ipynb
Last active February 24, 2018 14:13
Analyse des sujets de stages pour un projet tutoré de l'IUT de Vélizy
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sylvchev
sylvchev / CMakeLists.txt
Last active January 20, 2017 09:35
Detect and estimate the pose of some objects with SURF keypoints
cmake_minimum_required(VERSION 2.8)
project( detection_pose_estimation_surf )
find_package( OpenCV REQUIRED )
add_executable( detection_pose_estimation_surf detection_pose_estimation_surf.cpp )
target_link_libraries( detection_pose_estimation_surf ${OpenCV_LIBS} )
@sylvchev
sylvchev / gentoo_chroot.sh
Created January 17, 2017 22:42
chrooting in a gentoo for installation purpose (from a debian-based system)
sudo su -
mkdir /mnt/gentoo && mount /dev/sda3 /mnt/gentoo/ && mount /dev/sda2 /mnt/gentoo/boot/ && mount /dev/sda1 /mnt/gentoo/mnt/efi && cp -L /etc/resolv.conf /mnt/gentoo/etc/ && mount -t proc proc /mnt/gentoo/proc && mount --rbind /sys /mnt/gentoo/sys && mount --make-rslave /mnt/gentoo/sys && rm /dev/shm && mkdir /dev/shm && mount -t tmpfs -o nosuid,nodev,noexec shm /dev/shm && chmod 1777 /dev/shm && mount --rbind /dev /mnt/gentoo/dev && mount --make-rslave /mnt/gentoo/dev && chroot /mnt/gentoo /bin/bash
. /etc/profile
exit
cd
umount -l /mnt/gentoo/dev{/shm,/pts,}
umount -R /mnt/gentoo
reboot
@sylvchev
sylvchev / .gitconfig
Last active June 22, 2021 09:10
git configuration
[user]
name = Sylvain Chevallier
email = sylvain.chevallier@uvsq.fr
[credential]
helper = cache --timeout=10000000
[github]
user = sylvchev
[push]
default = matching
[core]
@sylvchev
sylvchev / .emacs
Created June 21, 2016 11:59
emacs file
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(TeX-command-list
(quote
(("TeX" "%(PDF)%(tex) %S%(PDFout) \"\\input %t\"" TeX-run-TeX nil
(plain-tex-mode texinfo-mode ams-tex-mode)
:help "Run plain TeX")
@sylvchev
sylvchev / convert_eeg_mat_fif.py
Created May 2, 2016 15:59
EEG files save in GDF are convert in Matlab format with BioSig. This code convert the .mat files in pickled gzip and FIF files, ready to be used in Python with MNE.
from __future__ import print_function
from scipy.io import loadmat
from os import listdir
from numpy import nan_to_num
import pickle
import gzip
import sys
import mne
def convert_to_pz(fname):
@sylvchev
sylvchev / simple_cuda_fft.cu
Created April 29, 2016 06:41
Simple CUDA file for benchmarking cuFFT plan with different signal size, inspired by https://github.com/drufat/cuda-examples
// Simple benchmarking FFT with Cuda, building on https://github.com/drufat/cuda-examples
// compiles with nvcc -DSIGNAL_SIZE=2048 -m64 -gencode arch=compute_30,code=sm_30 -O2 -use_fast_math -I commoninclude -l cufft cudafft.cu -o cudaff
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <sys/time.h>
#include <cuda_runtime.h>
#include "helper_functions.h"
@sylvchev
sylvchev / plotCovarianceMNE.py
Created February 29, 2016 23:11
Opening and plotting coavriance matrices estimated from SSVEP dataset
import numpy as np
import mne
from sklearn.cross_validation import cross_val_score, KFold
from pyriemann.estimation import covariances
import matplotlib.pyplot as plt
tmin, tmax = 2., 5.
event_id = dict(resting=1, stim13=2, stim17=3, stim21=4)
data_path = './'
fname = 'subject12/record-[2014.03.10-19.17.37]'