@@ -136,28 +136,36 @@ def _get_analogsignal_chunk(self, block_index, seg_index, i_start, i_stop, strea
136136
137137 # newer style data returns an initial flat array (n_samples * n_channels)
138138 # we iterate through channels rather than slicing
139+ # Due to the fact that Neo and SpikeInterface tend to prefer slices we need to add
140+ # some careful checks around slicing of None in the case we need to iterate through
141+ # channels. First check if None. Then check if slice and only if slice check that it is slice(None)
139142 else :
140143 if channel_indexes is None :
141144 channel_indexes = [ch for ch in range (self ._num_channels )]
145+ elif isinstance (channel_indexes , slice ):
146+ start = channel_indexes .start or 0
147+ stop = channel_indexes .stop or self ._num_channels
148+ step = channel_indexes .step or 1
149+ channel_indexes = [ch for ch in range (start , stop , step )]
142150
143- sig_chunk = np .zeros ((i_stop - i_start , len (channel_indexes )))
151+ sig_chunk = np .zeros ((i_stop - i_start , len (channel_indexes )))
144152 # iterate through channels to prevent loading all channels into memory which can cause
145153 # memory exhaustion. See https://github.com/SpikeInterface/spikeinterface/issues/3303
146154 for index , channel_index in enumerate (channel_indexes ):
147- sig_chunk [:, index ] = data [channel_index :: self ._num_channels ]
155+ sig_chunk [:, index ] = data [channel_index :: self ._num_channels ]
148156
149157 return sig_chunk
150158
151159
152- def open_biocam_file_header (filename )-> dict :
160+ def open_biocam_file_header (filename ) -> dict :
153161 """Open a Biocam hdf5 file, read and return the recording info, pick the correct method to access raw data,
154162 and return this to the caller
155-
163+
156164 Parameters
157165 ----------
158166 filename: str
159167 The file to be parsed
160-
168+
161169 Returns
162170 -------
163171 dict
@@ -244,7 +252,7 @@ def open_biocam_file_header(filename)-> dict:
244252 num_channels_x = num_channels_y = int (np .sqrt (num_channels ))
245253 else :
246254 raise NeoReadWriteError ("No Well found in the file" )
247-
255+
248256 if num_channels_x * num_channels_y != num_channels :
249257 raise NeoReadWriteError (f"Cannot determine structure of the MEA plate with { num_channels } channels" )
250258 channels = 1 + np .concatenate (np .transpose (np .meshgrid (range (num_channels_x ), range (num_channels_y ))))
@@ -268,6 +276,7 @@ def open_biocam_file_header(filename)-> dict:
268276######################################################################
269277# Helper functions to obtain the raw data split by Biocam version.
270278
279+
271280# return the full array for the old datasets
272281def readHDF5t_100 (rf , t0 , t1 , nch ):
273282 return rf ["3BData/Raw" ][t0 :t1 ]
0 commit comments