[med-svn] [python-mne] 137/353: factorize activate_proj function

Yaroslav Halchenko debian at onerussian.com
Fri Nov 27 17:24:45 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 517749c68092b978015f54cfd236fb89b86c3a97
Author: Alexandre Gramfort <alexandre.gramfort at inria.fr>
Date:   Thu Apr 12 09:17:16 2012 +0200

    factorize activate_proj function
---
 mne/epochs.py      |  6 ++----
 mne/fiff/evoked.py |  7 ++-----
 mne/fiff/proj.py   | 17 +++++++++++++++++
 mne/proj.py        |  1 +
 4 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/mne/epochs.py b/mne/epochs.py
index e0cdc4d..9116241 100644
--- a/mne/epochs.py
+++ b/mne/epochs.py
@@ -9,6 +9,7 @@ import fiff
 import warnings
 from .fiff import Evoked
 from .fiff.pick import pick_types, channel_indices_by_type
+from .fiff.proj import activate_proj
 from .baseline import rescale
 
 
@@ -142,10 +143,7 @@ class Epochs(object):
             self.proj = None
         else:
             #   Activate the projection items
-            for proj in self.info['projs']:
-                proj['active'] = True
-
-            print '%d projection items activated' % len(self.info['projs'])
+            self.info['projs'] = activate_proj(self.info['projs'], copy=False)
 
             # Add EEG ref reference proj
             print "Adding average EEG reference projection."
diff --git a/mne/fiff/evoked.py b/mne/fiff/evoked.py
index 643f77b..5ea12f0 100644
--- a/mne/fiff/evoked.py
+++ b/mne/fiff/evoked.py
@@ -11,7 +11,7 @@ from .open import fiff_open
 from .tag import read_tag
 from .tree import dir_tree_find
 from .meas_info import read_meas_info, write_meas_info
-from .proj import make_projector_info
+from .proj import make_projector_info, activate_proj
 from ..baseline import rescale
 
 from .write import start_file, start_block, end_file, end_block, \
@@ -219,10 +219,7 @@ class Evoked(object):
             self.proj = None
         else:
             #   Activate the projection items
-            for proj in info['projs']:
-                proj['active'] = True
-
-            print '%d projection items activated' % len(info['projs'])
+            info['projs'] = activate_proj(info['projs'], copy=False)
 
             #   Create the projector
             proj, nproj = make_projector_info(info)
diff --git a/mne/fiff/proj.py b/mne/fiff/proj.py
index f8ee02c..87bd2a4 100644
--- a/mne/fiff/proj.py
+++ b/mne/fiff/proj.py
@@ -331,3 +331,20 @@ def compute_spatial_vectors(epochs, n_grad=2, n_mag=2, n_eeg=2):
     """
     import mne  # XXX : ugly due to circular mess in imports
     return mne.compute_proj_epochs(epochs, n_grad, n_mag, n_eeg)
+
+
+def activate_proj(projs, copy=True):
+    """Set all projections to active
+
+    Useful before passing them to make_projector
+    """
+    if copy:
+        projs = deepcopy(projs)
+
+    #   Activate the projection items
+    for proj in projs:
+        proj['active'] = True
+
+    print '%d projection items activated' % len(projs)
+
+    return projs
diff --git a/mne/proj.py b/mne/proj.py
index 6c3c5b6..fabcc90 100644
--- a/mne/proj.py
+++ b/mne/proj.py
@@ -2,6 +2,7 @@
 #
 # License: BSD (3-clause)
 
+from copy import deepcopy
 import numpy as np
 from scipy import linalg
 

-- 
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