Skip to content

Commit

Permalink
fix medrawio for slice
Browse files Browse the repository at this point in the history
  • Loading branch information
zm711 committed Aug 28, 2024
1 parent ea7d84f commit e2c1cf8
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions neo/rawio/medrawio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit e2c1cf8

Please sign in to comment.