Skip to content

Instantly share code, notes, and snippets.

View larsoner's full-sized avatar

Eric Larson larsoner

View GitHub Profile
import numpy as np
import matplotlib.pyplot as plt
def _create_filter_response(sfreq, lowpass, highpass, lowpass_width=5.,
highpass_width=0.5):
"""Create a frequency response"""
filter_size = 4096
filter_taper_size = 2048
resp_size = (filter_size + 2 * filter_taper_size) // 2 + 1
import numpy as np
import mne
def dipole_fwhm(dip, tmin=None, tmax=None, gof_thresh=0.):
"""Compute the time interval of full-width half-maximum of a dipole
.. note:: This only considers the max(), not the min(), so if you're
interested in large negative values, you could do
``dip.data = -dip.data``.
Parameters
@larsoner
larsoner / warp.py
Last active September 27, 2016 18:19
from copy import deepcopy
import mne
from mne.bem import _fit_sph_harm_to_headshape, _transform_sph
from mne.surface import _tessellate_sphere_surf
raw = mne.io.read_raw_fif(mne.datasets.sample.data_path() +
'/MEG/sample/sample_audvis_raw.fif')
# For a visual explanation of the order, see:
@larsoner
larsoner / utmp_track.py
Created October 5, 2016 07:38
Script to track user login/logout using UTMP
# -*- coding: utf-8 -*-
import utmp
import tabulate
from warnings import warn
def time_str(dt):
"""Convert datetime object to date-time string."""
return dt.strftime('%Y/%m/%d %H:%M:%S')
# -*- coding: utf-8 -*-
"""
PySurfer-like plotting using VisPy scene.
"""
import numpy as np
from vispy import scene, app
import mne
import nibabel
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
from scipy.signal import butter, lfilter
from scipy import linalg
from scipy.fftpack import fft, ifft
import mne
@larsoner
larsoner / rf_aliasing.py
Created January 9, 2017 16:09
Test of aliasing in receptive field estimation
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Fri Dec 30 16:03:52 2016
@author: larsoner
"""
import numpy as np
from mne.decoding import ReceptiveField
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import numpy as np
from scipy.signal import firwin, firwin2, freqz
from scipy.io import loadmat
import matplotlib.pyplot as plt
@larsoner
larsoner / mgh_montages.py
Last active October 31, 2022 16:53
Transcribe MGH montages to standard electrode names.
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Manually enter MGH 70- and 60-channel cap names and convert to montages.
"""
from pathlib import Path
import numpy as np
import mne
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Use glass brain plotting for surface STCs.
"""
import os.path as op
import numpy as np
from scipy import sparse
import mne