Skip to content

Instantly share code, notes, and snippets.

View wmvanvliet's full-sized avatar

Marijn van Vliet wmvanvliet

View GitHub Profile
@wmvanvliet
wmvanvliet / plot_dics_source_power.py
Created January 6, 2020 08:27
Demonstrate DICS whitening
"""
.. _ex-inverse-source-power:
=========================================
Compute source power using DICS beamfomer
=========================================
Compute a Dynamic Imaging of Coherent Sources (DICS) [1]_ filter from
single-trial activity to estimate source power across a frequency band. This
example demonstrates how to source localize the event-related synchronization
import subprocess
import os
import mne
mne.set_log_level(False)
fname = 'bids/sub-{subject:02d}/ses-{session:02d}/meg/sub-{subject:02d}_ses-{session:02d}_task-naming_run-{run:02d}_meg.fif'
for subject in range(1, 21):
for session in range(1, 3):
{"embeddings": [{"tensorName": "aalto85", "sensorShape": [123, 85], "tensorPath": "/u/45/vanvlm1/unix/public_html/aaltonorms/aalto85/vectors.tsv", "metadataPath": "/u/45/vanvlm1/unix/public_html/aaltonorms/aalto85/metadata.tsv"}, {"tensorName": "aaltoprod", "sensorShape": [300, 5683], "tensorPath": "/u/45/vanvlm1/unix/public_html/aaltonorms/aaltoprod/vectors.tsv", "metadataPath": "/u/45/vanvlm1/unix/public_html/aaltonorms/aaltoprod/metadata.tsv"}, {"tensorName": "cmu", "sensorShape": [1000, 229], "tensorPath": "/u/45/vanvlm1/unix/public_html/aaltonorms/cmu/vectors.tsv", "metadataPath": "/u/45/vanvlm1/unix/public_html/aaltonorms/cmu/metadata.tsv"}, {"tensorName": "cslb", "sensorShape": [638, 2725], "tensorPath": "/u/45/vanvlm1/unix/public_html/aaltonorms/cslb/vectors.tsv", "metadataPath": "/u/45/vanvlm1/unix/public_html/aaltonorms/cslb/metadata.tsv"}, {"tensorName": "vinson", "sensorShape": [395, 1029], "tensorPath": "/u/45/vanvlm1/unix/public_html/aaltonorms/vinson/vectors.tsv", "metadataPath": "/u/45/vanvlm1
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wmvanvliet
wmvanvliet / swarmplot_example.py
Last active August 28, 2018 12:39
Example of how to plot a swarm plot using seaborn
# encoding: utf-8
# Import required Python modules for this example
import pandas as pd
import seaborn as sb
from matplotlib import pyplot as plt
from matplotlib.ticker import MultipleLocator
# Reading the data
dataframe = pd.read_table('Sensory_measurement.txt', index_col=0)
@wmvanvliet
wmvanvliet / csd_linearity.py
Last active July 27, 2018 06:05
Applying SSP to CSD matrix
"""
Test whether applying SSP to a CSD matrix is the same as computing the CSD
matrix on data where the SSP has already been applied.
author: Marijn van Vliet <[email protected]>
"""
import numpy as np
import mne
# Be quiet
@wmvanvliet
wmvanvliet / fnames.py
Last active April 11, 2018 11:18
Small utiliy for managing lists of filenames. It is essentially a wrapper around string.format(), adding a few niceties.
"""Utility class to manage a list of filenames.
Use the `add` method to add new filenames. You specify a short "alias" for
them, which you can use to retrieve the full filename later:
>>> fname = FileNames()
>>> fname.add('my_file', '/path/to/file1')
>>> fname.my_file
'/path/to/file1'
@wmvanvliet
wmvanvliet / normalize_forward_solution.py
Created February 20, 2018 03:18
Normalization of a forward solution
@verbose
def normalize_forward_solution(forward, depth=0.8, limit_depth_chs=True, loose=0.2,
use_cps=True, projs=None, verbose=None):
"""Normalize a forward solution.
Parameters
----------
forward : instance of Forward
Forward solution to normalize.
depth : None | float in [0, 1]
@wmvanvliet
wmvanvliet / adaptive_mean.py
Last active February 19, 2018 23:10
Calculate adaptive mean amplitude
import os.path as op
import numpy as np
import mne
from mne.datasets import sample
# Import sample data
path = op.join(sample.data_path(), 'MEG', 'sample')
raw = mne.io.read_raw_fif(op.join(path, 'sample_audvis_filt-0-40_raw.fif'))
events = mne.read_events(op.join(path, 'sample_audvis_filt-0-40_raw-eve.fif'))
epochs = mne.Epochs(raw, events, [1, 2], tmin=-0.2, tmax=1.0, preload=True)
@wmvanvliet
wmvanvliet / pick_vertices.py
Last active August 2, 2017 12:39
API proposal for picking vertices
# PROPOSED FUNCTIONS
select_vertices_in_label(inst, label):
"""Return the vertno of the vertices that lie within one of the labels."""
select_vertices_in_sensor_range(inst, max_dist, info=None):
"""Return the vertno of the vertices which nearest sensor is no further away than max_dist."""
restrict_vertices(inst, vertices):
"""Restrict the vertices in a Forward, SourceSpaces or SourceEstimate object to the given vertno."""