Skip to content

Instantly share code, notes, and snippets.

View wmvanvliet's full-sized avatar

Marijn van Vliet wmvanvliet

View GitHub Profile
@wmvanvliet
wmvanvliet / _interactive
Created May 21, 2024 08:08
Script to request a node through SLURM and create an interactive TMUX session on it
#!/bin/bash
# Start tmux
tmux new -d -s "slurm$SLURM_JOB_ID"
# Make job wait for user to connect
sleep 8h
@wmvanvliet
wmvanvliet / plot_cluster.py
Created May 10, 2024 08:06
Plotting clusters coming out of the cluster-based permutation tests.
"""Plot a cluster.
Plot the spatial extend of a cluster (as those returned from the cluster-based
permutation stats) on a brain.
Author: Marijn van Vliet <w.m.vanvliet@gmail.com>
"""
import mne
import numpy as np
@wmvanvliet
wmvanvliet / cluster_plotting_example.py
Last active March 12, 2024 09:48
Plot the spatial extent of a cluster (as those returned from the cluster-based permutation stats) on a brain.
"""
Plot the spatial extent of a cluster (as those returned from the cluster-based
permutation stats) on a brain.
Author: Marijn van Vliet <w.m.vanvliet@gmail.com>
"""
import mne
import numpy as np
@wmvanvliet
wmvanvliet / mous_trans.py
Created October 13, 2023 10:10
Obtain head -> MRI transform for the MOUS dataset (DSC_3011020.09_236) for use with MNE-Python.
"""
Obtain head -> MRI transform for the MOUS dataset for use with MNE-Python.
If you want to analyze the "Mother of all unification studies" dataset with
FreeSurfer and MNE-Python, you will need the MRI->HEAD coordinate
transformations. In the original dataset, the T1w_space_CTF.nii files contain
this information, but it takes some doing to distill this into a transform
object as used by MNE-Python.
This script assumes you have ran FreeSurfer on the T1w.nii files of all the
@wmvanvliet
wmvanvliet / events.py
Last active May 6, 2023 11:16
Proposal for an event API for MNE-Python
"""
Proposal for an event API for MNE-Python.
-----------------------------------------
We want figures to be able to communicate with each other, such that a change
in one figure can trigger a change in another figure. For example, moving the
time cursor in a Brain plot can update the current time in an evoked plot.
Another scenario is two drawing routines drawing into the same window. For
example, one function is drawing a source estimate, while another is drawing
magnetic field lines. The event system will allow both drawing routines to
@wmvanvliet
wmvanvliet / template.rs
Created November 29, 2022 08:31
Advent of Code template for Rust
use std::io::{self, Read};
// This reads in the puzzle input from stdin. So you would call this program like:
// cat input | cargo run
// It then feeds the input as a string to the functions that solve both parts of the puzzle.
fn main() {
let mut input = String::new();
io::stdin().read_to_string(&mut input).unwrap();
println!("Part 1 answer: {}", part1(strip_bom(&input)));
println!("Part 2 answer: {}", part2(strip_bom(&input)));
@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."