[med-svn] [python-mne] 117/353: compute sample mean over epochs, can only handle single event type

Yaroslav Halchenko debian at onerussian.com
Fri Nov 27 17:24:40 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 a61c248b97abb61decab4e5b6eed65c18556ea61
Author: Martin Luessi <mluessi at nmr.mgh.harvard.edu>
Date:   Mon Mar 12 15:18:47 2012 -0400

    compute sample mean over epochs, can only handle single event type
---
 mne/cov.py                           |  13 ++++++++-----
 mne/fiff/tests/data/test_raw-eve.fif | Bin 927 -> 927 bytes
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/mne/cov.py b/mne/cov.py
index b0776fd..053a261 100644
--- a/mne/cov.py
+++ b/mne/cov.py
@@ -252,7 +252,7 @@ def compute_covariance(epochs, keep_sample_mean=True):
     for e in epochs:
         e = e[picks_meeg]
         if not keep_sample_mean:
-            data_mean += np.sum(e, axis=1)[:, np.newaxis]
+            data_mean += e
         data += np.dot(e, e.T)
         n_samples += e.shape[1]
         n_epochs += 1
@@ -262,14 +262,17 @@ def compute_covariance(epochs, keep_sample_mean=True):
                          ' matrix : %d samples' % n_samples)
 
     if keep_sample_mean:
-        data /= n_samples
+        nfree = n_samples
+        data /= nfree
     else:
-        data /= n_samples - 1
-        data -= n_samples / (1.0 - n_samples) * np.dot(data_mean, data_mean.T)
+        n_samples_epoch = n_samples / n_epochs
+        nfree = n_samples_epoch * (n_epochs - 1)
+        data /= nfree
+        data -= 1.0 / nfree * np.dot(data_mean, data_mean.T)
     cov = Covariance(None)
     cov.data = data
     cov.ch_names = ch_names
-    cov.nfree = n_samples
+    cov.nfree = nfree
 
     # XXX : do not compute eig and eigvec now (think it's better...)
     eig = None
diff --git a/mne/fiff/tests/data/test_raw-eve.fif b/mne/fiff/tests/data/test_raw-eve.fif
index f81fd0d..4e2f4e6 100755
Binary files a/mne/fiff/tests/data/test_raw-eve.fif and b/mne/fiff/tests/data/test_raw-eve.fif differ

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