[med-svn] [python-mne] 34/376: better slicing for raw data

Yaroslav Halchenko debian at onerussian.com
Fri Nov 27 17:22:01 UTC 2015


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

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

commit 4da7024251710fad63cb97001f69ba9df4b099ad
Author: Alexandre Gramfort <alexandre.gramfort at inria.fr>
Date:   Fri Jan 14 17:24:37 2011 -0500

    better slicing for raw data
---
 examples/read_raw.py |  1 +
 mne/fiff/raw.py      | 12 ++++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/examples/read_raw.py b/examples/read_raw.py
index ca650ad..8d41748 100644
--- a/examples/read_raw.py
+++ b/examples/read_raw.py
@@ -13,6 +13,7 @@ meg_channels_idx = meg_channels_idx[:5] # take 5 first
 
 start, stop = raw.time_to_index(100, 115) # 100 s to 115 s data segment
 data, times = raw[meg_channels_idx, start:stop]
+# data, times = raw[:, start:stop] # read all channels
 
 raw.close()
 
diff --git a/mne/fiff/raw.py b/mne/fiff/raw.py
index cc3d030..44ea075 100644
--- a/mne/fiff/raw.py
+++ b/mne/fiff/raw.py
@@ -20,11 +20,19 @@ class Raw(dict):
         if isinstance(item, tuple): # slicing required
             if len(item) == 2: # channels and time instants
                 time_slice = item[1]
-                sel = item[0]
+                if isinstance(item[0], slice):
+                    start = item[0].start if item[0].start is not None else 0
+                    nchan = self['info']['nchan']
+                    stop = item[0].stop if item[0].stop is not None else nchan
+                    step = item[0].step if item[0].step is not None else 1
+                    sel = range(start, stop, step)
+                else:
+                    sel = item[0]
             else:
                 time_slice = item[0]
                 sel = None
-            start, stop, step = time_slice.start, time_slice.stop, time_slice.step
+            start, stop, step = time_slice.start, time_slice.stop, \
+                                time_slice.step
             if step is not None:
                 raise ValueError('step needs to be 1 : %d given' % step)
             return read_raw_segment(self, start=start, stop=stop, sel=sel)

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