Created
November 3, 2014 17:22
-
-
Save dengemann/dfa01ebd8c14a2316477 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Authors: Denis Engemann <denis.engemann@gmail.com> | |
# Lakshmi Krishnan <lakshmik@umd.edu> | |
# License: BSD (3-clause) | |
import mne | |
import numpy as np | |
from scipy import io | |
# x,y convention is inverted in Mat file | |
mat = io.loadmat('electrode_loc/chanlocs.mat',chars_as_strings=1) | |
ch_info = mat['chanlocs'] | |
# stupid type problem on reading mat file + reorder dims | |
pos = np.array([np.array([float(f) for f in ch_info[k][0]]) for k in | |
('Y', 'X', 'Z')]).T | |
pos[:, 0] *= -1 # flip | |
# assemble info | |
ch_names = ch_info['labels'][0] | |
ch_names = [str(x[0][:]) for x in ch_names] | |
ch_types = ['eeg'] * len(ch_names) | |
info = mne.create_info(ch_names=ch_names, ch_types=ch_types, sfreq=1000) | |
# ceate random data and put in Evoked | |
rng = np.random.RandomState(seed=42) | |
data = rng.randn(64)[:, None] | |
evoked = mne.EvokedArray(data=data, info=info, tmin=0) | |
# create custom montage | |
from mne.montages.montage import Montage | |
montage = Montage(pos=pos, ch_names=ch_names, kind='custom-montage', | |
selection=np.arange(64)) | |
# apply to evked | |
mne.montages.apply_montage(evoked.info, montage) | |
# plot | |
evoked.plot_topomap(ch_type='eeg', times=[0], size=5, show_names=True, scale=1, | |
unit='Arb.Un.', contours=0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment