[med-svn] [python-mne] 09/52: ENH : avoid allocating memory for all epochs (even bads)

Yaroslav Halchenko debian at onerussian.com
Fri Nov 27 17:23:44 UTC 2015


This is an automated email from the git hooks/post-receive script.

yoh pushed a commit to annotated tag v0.2
in repository python-mne.

commit a27f90060f1c41184508ff203ca43994f26ebbb4
Author: Alexandre Gramfort <alexandre.gramfort at inria.fr>
Date:   Tue Sep 27 22:41:45 2011 -0400

    ENH : avoid allocating memory for all epochs (even bads)
---
 mne/epochs.py | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/mne/epochs.py b/mne/epochs.py
index d07d414..c1c324b 100644
--- a/mne/epochs.py
+++ b/mne/epochs.py
@@ -232,18 +232,16 @@ class Epochs(object):
         n_channels = len(self.ch_names)
         n_times = len(self.times)
         n_events = len(self.events)
-        data = np.empty((n_events, n_channels, n_times))
-        cnt = 0
+        data = list()
         n_reject = 0
         for k in range(n_events):
             e = self._get_epoch_from_disk(k)
             if self._is_good_epoch(e):
-                data[cnt] = self._get_epoch_from_disk(k)
-                cnt += 1
+                data.append(self._get_epoch_from_disk(k))
             else:
                 n_reject += 1
         print "Rejecting %d epochs." % n_reject
-        return data[:cnt]
+        return np.array(data)
 
     def _is_good_epoch(self, data):
         """Determine is epoch is good

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