Skip to content

Instantly share code, notes, and snippets.

View wmvanvliet's full-sized avatar

Marijn van Vliet wmvanvliet

View GitHub Profile
@wmvanvliet
wmvanvliet / EOG regression exploration.ipynb
Created August 25, 2022 10:46
Exploration of regression methods for correcting EOG artifacts in EEG data.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wmvanvliet
wmvanvliet / aoc2021.py
Last active December 25, 2021 08:34
Solutions to Advent of Code 2021 using the Python ecosystem
import numpy as np
import pandas as pd
import string
from collections import deque, Counter, defaultdict
from copy import deepcopy
from itertools import chain
from scipy.signal import convolve2d
from scipy.spatial import distance
from tqdm import tqdm
import matplotlib.pyplot as plt
channels:
- conda-forge
- omnia
- bioconda
dependencies:
- modeller
- mdtraj
- plyfile
- snakemake
@wmvanvliet
wmvanvliet / test_docstring_highlighting.py
Created April 13, 2021 10:59
Test cases for python docstring highlighting
"""
This should be a docstring.
Second line of the docstring.
"""
"""This should not be a docstring."""
b"""This should not be a docstring."""
r"""This should not be a docstring."""
"This should not be a docstring."
"""
Test whether modifying the batch size changes the result
Authors: Marijn van Vliet <[email protected]>
"""
import torch
from torch.utils.data import DataLoader
from torchvision import datasets, transforms
import numpy as np
@wmvanvliet
wmvanvliet / dip_plot_test.py
Last active August 28, 2020 10:20
Testing plotting of dipoles using MNE-Python and PySurfer
import mne
import surfer
from mayavi import mlab
# Various filenames we'll be needing
data_path = mne.datasets.sample.data_path()
subjects_dir = f'{data_path}/subjects'
fname_trans = f'{data_path}/MEG/sample/sample_audvis_raw-trans.fif'
fname_cov = f'{data_path}/MEG/sample/sample_audvis-cov.fif'
fname_evokeds = f'{data_path}/MEG/sample/sample_audvis-ave.fif'
@wmvanvliet
wmvanvliet / pep8-toggle.vim
Last active May 5, 2020 19:40
Vim keybinding for toggling PEP8 linting
" Linter (provided through ALE)
let g:ale_lint_on_text_changed = 'never'
let g:ale_lint_on_save = 1
let g:ale_linters = {
\ 'python': ['flake8'],
\}
" By default, don't worry about PEP8
let g:ale_python_flake8_options = "--ignore=E2,E3,E4,E5,E7,W"
let g:python_highlight_space_errors = 0
import mne
import numpy as np
import mne_rsa
dsms_file = np.load('pilot2_dsms.npz')
meg_dsms = dsms_file['dsms']
model_dsms = ... # Up to you to create
# RSA: compare all MEG DSMs to all model DSMs
rsa_results = mne_rsa.rsa(meg_dsms, model_dsms, metric='spearman')
@wmvanvliet
wmvanvliet / without_mri.py
Created February 12, 2020 16:22
Performing MEG source estimation without an MRI, using the 'fsaverage' template MRI instead
import mne
# MEG data we take from the MNE-Sample dataset
data_path = mne.datasets.sample.data_path()
subjects_dir = f'{data_path}/subjects'
evoked = mne.read_evokeds(f'{data_path}/MEG/sample/sample_audvis-ave.fif', condition='Left Auditory').apply_baseline()
noise_cov = mne.read_cov(f'{data_path}/MEG/sample/sample_audvis-cov.fif')
# MRI data we will take from the 'fsaverage' template brain
fs_dir = mne.datasets.fetch_fsaverage(verbose=True) # Download the files
@wmvanvliet
wmvanvliet / sphere_model.py
Last active February 12, 2020 16:13
Here's something you shouldn't do with MNE-Python
import mne
from mayavi import mlab
data_path = mne.datasets.sample.data_path()
subjects_dir = f'{data_path}/subjects'
evoked = mne.read_evokeds(f'{data_path}/MEG/sample/sample_audvis-ave.fif', condition='Left Auditory').apply_baseline()
noise_cov = mne.read_cov(f'{data_path}/MEG/sample/sample_audvis-cov.fif')
bem = mne.make_sphere_model(r0='auto', head_radius='auto', info=evoked.info)
src = mne.setup_volume_source_space(bem=bem)