Skip to content

Commit e2c1cf8

Browse files
committed
fix medrawio for slice
1 parent ea7d84f commit e2c1cf8

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

neo/rawio/medrawio.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,18 @@ def _get_analogsignal_chunk(self, block_index, seg_index, i_start, i_stop, strea
240240
self.sess.set_channel_active(self._stream_info[stream_index]["raw_chans"])
241241
num_channels = len(self._stream_info[stream_index]["raw_chans"])
242242
self.sess.set_reference_channel(self._stream_info[stream_index]["raw_chans"][0])
243+
244+
# in the case we have a slice or we give an ArrayLike we need to iterate through the channels
245+
# in order to activate them.
243246
else:
244-
if any(channel_indexes < 0):
245-
raise IndexError(f"Can not index negative channels: {channel_indexes}")
247+
if isinstance(channel_indexes, slice):
248+
start = channel_indexes.start or 0
249+
stop = channel_indexes.stop or len(self._stream_info[stream_index]["raw_chans"])
250+
step = channel_indexes.step or 1
251+
channel_indexes = [ch for ch in range(start, stop, step)]
252+
else:
253+
if any(channel_indexes < 0):
254+
raise IndexError(f"Can not index negative channels: {channel_indexes}")
246255
# Set all channels to be inactive, then selectively set some of them to be active
247256
self.sess.set_channel_inactive("all")
248257
for i, channel_idx in enumerate(channel_indexes):

0 commit comments

Comments
 (0)