[med-svn] [python-mne] 53/353: ENH : raise Exception with inverse operator was computed with bad channels
Yaroslav Halchenko
debian at onerussian.com
Fri Nov 27 17:24:30 UTC 2015
This is an automated email from the git hooks/post-receive script.
yoh pushed a commit to tag 0.4
in repository python-mne.
commit 5b9793d5daaa58ca3f21425eb13ba3651efca7b7
Author: Alexandre Gramfort <alexandre.gramfort at inria.fr>
Date: Tue Jan 17 17:41:14 2012 +0100
ENH : raise Exception with inverse operator was computed with bad channels
---
mne/minimum_norm/inverse.py | 24 ++++++++++++++++++++----
mne/minimum_norm/time_frequency.py | 4 ++--
2 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/mne/minimum_norm/inverse.py b/mne/minimum_norm/inverse.py
index 3e2760f..7d331da 100644
--- a/mne/minimum_norm/inverse.py
+++ b/mne/minimum_norm/inverse.py
@@ -15,7 +15,6 @@ from ..fiff.tag import find_tag
from ..fiff.matrix import _read_named_matrix, _transpose_named_matrix
from ..fiff.proj import read_proj, make_projector
from ..fiff.tree import dir_tree_find
-from ..fiff.pick import pick_channels
from ..cov import read_cov, prepare_noise_cov
from ..forward import compute_depth_prior
@@ -25,6 +24,23 @@ from ..transforms import invert_transform, transform_source_space_to
from ..source_estimate import SourceEstimate
+def _pick_channels_inverse_operator(ch_names, inv):
+ """Gives the indices of the data channel to be used knowing
+ an inverse operator
+ """
+ sel = []
+ for name in inv['noise_cov']['names']:
+ if name in ch_names:
+ sel.append(ch_names.index(name))
+ else:
+ raise ValueError('The inverse operator was computed with '
+ 'channel %s which is not present in '
+ 'the data. You should compute a new inverse '
+ 'operator restricted to the good data '
+ 'channels.' % name)
+ return sel
+
+
def read_inverse_operator(fname):
"""Read the inverse operator decomposition from a FIF file
@@ -555,7 +571,7 @@ def apply_inverse(evoked, inverse_operator, lambda2, dSPM=True,
#
# Pick the correct channels from the data
#
- sel = pick_channels(evoked.ch_names, include=inv['noise_cov']['names'])
+ sel = _pick_channels_inverse_operator(evoked.ch_names, inv)
print 'Picked %d channels from the data' % len(sel)
print 'Computing inverse...',
@@ -625,7 +641,7 @@ def apply_inverse_raw(raw, inverse_operator, lambda2, dSPM=True,
#
# Pick the correct channels from the data
#
- sel = pick_channels(raw.ch_names, include=inv['noise_cov']['names'])
+ sel = _pick_channels_inverse_operator(raw.ch_names, inv)
print 'Picked %d channels from the data' % len(sel)
print 'Computing inverse...',
@@ -690,7 +706,7 @@ def apply_inverse_epochs(epochs, inverse_operator, lambda2, dSPM=True,
#
# Pick the correct channels from the data
#
- sel = pick_channels(epochs.ch_names, include=inv['noise_cov']['names'])
+ sel = _pick_channels_inverse_operator(epochs.ch_names, inv)
print 'Picked %d channels from the data' % len(sel)
print 'Computing inverse...',
diff --git a/mne/minimum_norm/time_frequency.py b/mne/minimum_norm/time_frequency.py
index 049d63a..8b049ba 100644
--- a/mne/minimum_norm/time_frequency.py
+++ b/mne/minimum_norm/time_frequency.py
@@ -9,7 +9,7 @@ from ..fiff.constants import FIFF
from ..time_frequency.tfr import cwt, morlet
from ..baseline import rescale
from .inverse import combine_xyz, prepare_inverse_operator, _assemble_kernel, \
- _make_stc
+ _make_stc, _pick_channels_inverse_operator
from ..parallel import parallel_func
@@ -180,7 +180,7 @@ def _source_induced_power(epochs, inverse_operator, frequencies, label=None,
#
# Pick the correct channels from the data
#
- sel = [epochs.ch_names.index(name) for name in inv['noise_cov']['names']]
+ sel = _pick_channels_inverse_operator(epochs.ch_names, inv)
print 'Picked %d channels from the data' % len(sel)
print 'Computing inverse...',
#
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/python-mne.git
More information about the debian-med-commit
mailing list