Created
June 22, 2015 09:12
-
-
Save cjayb/60ce9a543a4665348ad4 to your computer and use it in GitHub Desktop.
demonstration (test) of channel picking in fwd['sol'] vs. fwd['info']
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
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') | |
sample_bem_path = op.join(testing.data_path(download=False), 'subjects', | |
'sample', 'bem') | |
bem_fname = op.join(sample_bem_path, 'sample-320-320-320-bem-sol.fif') | |
src_fname = op.join(sample_bem_path, 'sample-oct-2-src.fif') | |
raw = mne.io.Raw(raw_fname, preload=True, proj=True) | |
# reorder info-struct, don't worry about the data as it won't be used! | |
# new order: EOG, EEG, MEG, STI | |
new_order = [375] + range(315, 375) + range(0,306) + range(306, 315) | |
# Are these the only two that need reordering? | |
raw.info['ch_names'] = [raw.info['ch_names'][n] for n in new_order] | |
raw.info['chs'] = [raw.info['chs'][n] for n in new_order] | |
fwd = mne.make_forward_solution(raw.info, trans_fname, src_fname, | |
bem_fname, eeg=True, mindist=5.0) | |
fwd = mne.convert_forward_solution(fwd, surf_ori=True) | |
print "Now sol and info keys will contain different channel orderings" | |
print ''''fwd['sol']['row_names'][:5]''' | |
print fwd['sol']['row_names'][:5] | |
print ''''fwd['info']['ch_names'][:5]''' | |
print fwd['info']['ch_names'][:5] | |
print 'Note that picking EEG type will now return a fwd with MEG channels' | |
print 'fwd_picked = mne.pick_types_forward(fwd, meg=False, eeg=True)' | |
fwd_picked = mne.pick_types_forward(fwd, meg=False, eeg=True) | |
print fwd_picked | |
print 'And sensititivy map calculation (average ref-part) will fail:' | |
try: | |
eeg_map = mne.sensitivity_map(fwd, ch_type='eeg', mode='fixed') | |
except ValueError, e: | |
print '\nValueError:', e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment