From e2c1cf8f09093197c21847ae5ee249d58329406b Mon Sep 17 00:00:00 2001 From: zm711 <92116279+zm711@users.noreply.github.com> Date: Wed, 28 Aug 2024 14:41:09 -0400 Subject: [PATCH] fix medrawio for slice --- neo/rawio/medrawio.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/neo/rawio/medrawio.py b/neo/rawio/medrawio.py index 373477b17..454981dd8 100644 --- a/neo/rawio/medrawio.py +++ b/neo/rawio/medrawio.py @@ -240,9 +240,18 @@ def _get_analogsignal_chunk(self, block_index, seg_index, i_start, i_stop, strea self.sess.set_channel_active(self._stream_info[stream_index]["raw_chans"]) num_channels = len(self._stream_info[stream_index]["raw_chans"]) self.sess.set_reference_channel(self._stream_info[stream_index]["raw_chans"][0]) + + # in the case we have a slice or we give an ArrayLike we need to iterate through the channels + # in order to activate them. else: - if any(channel_indexes < 0): - raise IndexError(f"Can not index negative channels: {channel_indexes}") + if isinstance(channel_indexes, slice): + start = channel_indexes.start or 0 + stop = channel_indexes.stop or len(self._stream_info[stream_index]["raw_chans"]) + step = channel_indexes.step or 1 + channel_indexes = [ch for ch in range(start, stop, step)] + else: + if any(channel_indexes < 0): + raise IndexError(f"Can not index negative channels: {channel_indexes}") # Set all channels to be inactive, then selectively set some of them to be active self.sess.set_channel_inactive("all") for i, channel_idx in enumerate(channel_indexes):