Skip to content

Instantly share code, notes, and snippets.

@bloyl
bloyl / Test_returnGenerators.py
Created October 2, 2013 19:48
simple test of return generator code for apply_inverse_epochs.py
import numpy as np
import pylab as pl
import mne
from mne.datasets import sample
from mne.fiff import Raw, pick_types
from mne.minimum_norm import apply_inverse_epochs, read_inverse_operator
import time
from guppy import hpy
@bloyl
bloyl / computeIntegrationPoints.py
Last active November 30, 2016 17:11
Compute integration points according to the last # formula in section 25.4.62 in the "Handbook of Mathematical Functions: # With Formulas, Graphs, and Mathematical Tables" edited by Abramowitz and Stegun. # http://people.math.sfu.ca/~cbm/aands/abramowitz_and_stegun.pdf
import numpy as np
def computeIntegrationPoints(h, acc, base=None, shape='circle'):
# These coil definitions make use of integration points according to the
# last formula in section 25.4.62 in the "Handbook of Mathematical
# Functions: With Formulas, Graphs, and Mathematical Tables"
# edited by Abramowitz and Stegun.
# http://people.math.sfu.ca/~cbm/aands/abramowitz_and_stegun.pdf
import os.path as op
import matplotlib.pyplot as plt
import mne
data_path = mne.datasets.sample.data_path()
fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis-ave.fif')
evoked = mne.read_evokeds(fname, baseline=(None, 0), proj=True)
evoked_l_aud = evoked[0]
from mne import read_trans
from mne import io
import os.path as op
from mne.io.constants import FIFF
from mne.transforms import apply_trans, combine_transforms
ds_fname = 'test.ds'
meas_fname = '%s-info.fif' % op.splitext(ds_fname)[0]
import os.path as op
import numpy as np
import matplotlib.pyplot as plt
import mne
data_path = mne.datasets.sample.data_path()
fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis-ave.fif')
evoked = mne.read_evokeds(fname, baseline=(None, 0), proj=True)
"""
================================
Brainstorm resting state dataset
================================
Here we compute the resting state from raw for the
Brainstorm tutorial dataset. For comparison, see [1]_ and:
http://neuroimage.usc.edu/brainstorm/Tutorials/MedianNerveCtf
name: hnn
channels:
- defaults
dependencies:
- python>=3.6
- pip
- numpy
- scipy
- matplotlib
- cython
def plot_tfr(tfr, vmin, vmax, axes=None, colorbar=False, title=None,
set_chan_title=True, show=True):
from mne.viz.utils import center_cmap
from matplotlib import pyplot as plt
cmap = center_cmap(plt.cm.RdBu_r, vmin, vmax) # zero maps to white
n_chans = len(tfr.ch_names)
if axes is None:
if colorbar:
w_ratios = list(np.repeat(10, n_chans)) + [1]
fig, axes = plt.subplots(1, n_chans + 1, figsize=(12, 4),
@bloyl
bloyl / test_slicer_plot.py
Last active January 31, 2021 16:29
slicer plot test
import numpy as np
tbl_data = np.zeros((2, 100))
tbl_data[0] = 1000 + np.arange(100)
tbl_data[1] = 3 * np.arange(100)
tableNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLTableNode')
updateTableFromArray(tableNode, tbl_data.transpose())
tableNode.GetTable().GetColumn(0).SetName('X')
tableNode.GetTable().GetColumn(1).SetName('Y')