|
23 | 23 | from urllib.request import urlopen |
24 | 24 |
|
25 | 25 | from .baserawio import (BaseRawIO, _signal_channel_dtype, _signal_stream_dtype, |
26 | | - _spike_channel_dtype, _event_channel_dtype) |
| 26 | + _spike_channel_dtype, _event_channel_dtype) |
27 | 27 |
|
28 | 28 | import numpy as np |
29 | 29 |
|
@@ -76,12 +76,13 @@ def _parse_header(self): |
76 | 76 | if len(rec_names) > 1: |
77 | 77 | if self.rec_name is None: |
78 | 78 | raise ValueError("Detected multiple recordings. Please select a single recording using" |
79 | | - f' the `rec_name` paramter.\nPossible rec_name {rec_names}') |
| 79 | + f' the `rec_name` paramter.\nPossible rec_name {rec_names}') |
80 | 80 | else: |
81 | 81 | self.rec_name = rec_names[0] |
82 | 82 | signal_streams.append((stream_id, stream_id)) |
83 | 83 | else: |
84 | | - raise NotImplementedError(f'This version {version} is not supported') |
| 84 | + raise NotImplementedError( |
| 85 | + f'This version {version} is not supported') |
85 | 86 | signal_streams = np.array(signal_streams, dtype=_signal_stream_dtype) |
86 | 87 |
|
87 | 88 | # create signal channels |
@@ -185,15 +186,25 @@ def _get_analogsignal_chunk(self, block_index, seg_index, i_start, i_stop, |
185 | 186 | if i_stop is None: |
186 | 187 | i_stop = sigs.shape[1] |
187 | 188 |
|
| 189 | + resorted_indexes = None |
188 | 190 | if channel_indexes is None: |
189 | 191 | channel_indexes = slice(None) |
| 192 | + else: |
| 193 | + if np.array(channel_indexes).size > 1 and np.any(np.diff(channel_indexes) < 0): |
| 194 | + # get around h5py constraint that it does not allow datasets |
| 195 | + # to be indexed out of order |
| 196 | + channel_indexes = np.sort(channel_indexes) |
| 197 | + resorted_indexes = np.array( |
| 198 | + [list(channel_indexes).index(ch) for ch in channel_indexes]) |
190 | 199 |
|
191 | 200 | try: |
192 | 201 | if self._old_format: |
193 | 202 | sigs = sigs[self._channel_slice, i_start:i_stop] |
194 | 203 | sigs = sigs[channel_indexes] |
195 | 204 | else: |
196 | 205 | sigs = sigs[channel_indexes, i_start:i_stop] |
| 206 | + if resorted_indexes is not None: |
| 207 | + sigs = sigs[resorted_indexes] |
197 | 208 | except OSError as e: |
198 | 209 | print('*' * 10) |
199 | 210 | print(_hdf_maxwell_error) |
|
0 commit comments