Skip to content

Instantly share code, notes, and snippets.

View cjayb's full-sized avatar

Christopher J. Bailey cjayb

  • Norlys
  • Denmark
View GitHub Profile
import mne
raw=mne.io.Raw('/aux/Lau/timingChris/PROJ0156_SUBJ0001_SER001_FILESNO001.fif',preload=False)
pick_misc = mne.pick_channels(raw.info['ch_names'], include='MISC001')
events = mne.find_events(raw, stim_channel='STI101', min_duration=0.002, consecutive=True)
# hvis 232 skal fjernes, kan det goeres saaledes
incl_range = range(100,300)
incl_range.remove(232)
@cjayb
cjayb / pyo with jack on mac
Last active August 29, 2015 14:14
pyo on mac with jack
# if python from brew, otherwise might not work
brew install portaudio portmidi libsndfile liblo jack
brew link portaudio portmidi libsndfile liblo
cd ~/Sites/tmp
svn checkout http://pyo.googlecode.com/svn/trunk/ pyo-read-only
@cjayb
cjayb / gist:35ba19f40cc3df47a824
Last active August 29, 2015 14:17 — forked from larsoner/gist:bbac101d50176611136b
Savizky-Golay example from Eric89GXL
# -*- coding: utf-8 -*-
"""
Examine if a 2x window length is appropriate for savgol filtering.
"""
from scipy.signal import savgol_filter
from scipy import fftpack
import numpy as np
import matplotlib.pyplot as plt
plt.ion()
@cjayb
cjayb / plot_mpl_colors.py
Created March 23, 2015 05:24
Named colors in matplotlib
# copy from http://stackoverflow.com/questions/22408237/named-colors-in-matplotlib
# credits to BoshWash
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import matplotlib.colors as colors
import math
fig = plt.figure()
ax = fig.add_subplot(111)
@cjayb
cjayb / surr_demo_fsaverage.sh
Last active August 29, 2015 14:17
Using fsaverage as surrogate anatomy in MNE
#!/bin/bash -x
#
# This script tests the use of the fsaverage brain with MEG
# subjects lacking an individual MRI. In particular, I have
# been unable to change the number of vertices on the resulting
# surface using the --spacing option (mne_setup_source_space,
# mne_do_forward_solution).
#
# The steps here are mainly based on a document created by Matti Hamalainen,
@cjayb
cjayb / test_pick_forward_channels_gist.py
Created June 22, 2015 09:12
demonstration (test) of channel picking in fwd['sol'] vs. fwd['info']
from os import path as op
from os import rmdir
import mne
from mne.datasets import testing
from mne.utils import _TempDir
sample_path = op.join(testing.data_path(download=False), 'MEG', 'sample')
raw_fname = op.join(sample_path, 'sample_audvis_trunc_raw.fif')
trans_fname = op.join(sample_path, 'sample_audvis_trunc-trans.fif')
@cjayb
cjayb / test_fwd_ordering_gist.py
Created June 23, 2015 10:19
fishyness in fwd['sol'] vs. fwd['info'] ordering of channels
from os import path as op
import mne
from mne.datasets import testing
import numpy as np
import matplotlib.pyplot as plt
sample_path = op.join(testing.data_path(download=False), 'MEG', 'sample')
raw_fname = op.join(sample_path, 'sample_audvis_trunc_raw.fif')
trans_fname = op.join(sample_path, 'sample_audvis_trunc-trans.fif')
@cjayb
cjayb / call_by_object_example.py
Last active September 23, 2015 06:32
Call-by-object parameter passing in Python
# Passing a mutable object to a function is like passing a C-pointer to
# the memory location of the object -> mutating memory inside the function
# will be "visible" outside the function too.
# Since each function has its own _namespace_, mangling the variable
# is equivalent to moving the pointer away from the passed-in location
# so any changes to the parameter variable remain within the scope of
# the function.
outer_list = [1,2,3,4]
@cjayb
cjayb / simulate_dipoles_to_evoked.py
Last active February 10, 2016 15:13
Dipole modeling and topomaps
from os import path as op
import numpy as np
# from scipy import linalg
import mne
data_path = mne.datasets.sample.data_path()
subjects_dir = op.join(data_path, 'subjects')
fname_ave = op.join(data_path, 'MEG', 'sample', 'sample_audvis-ave.fif')
fname_cov = op.join(data_path, 'MEG', 'sample', 'sample_audvis-cov.fif')
@cjayb
cjayb / walkthrough_PR_3461.ipynb
Created July 27, 2016 09:25
walkthrough_PR_3461 (notebook)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.