@@ -136,28 +136,31 @@ 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 :
140- if (channel_indexes is None ) or (channel_indexes == slice (None )):
143+ if (channel_indexes is None ) or (isinstance ( channel_indexes , slice ) and channel_indexes == slice (None )):
141144 channel_indexes = [ch for ch in range (self ._num_channels )]
142145
143- sig_chunk = np .zeros ((i_stop - i_start , len (channel_indexes )))
146+ sig_chunk = np .zeros ((i_stop - i_start , len (channel_indexes )))
144147 # iterate through channels to prevent loading all channels into memory which can cause
145148 # memory exhaustion. See https://github.com/SpikeInterface/spikeinterface/issues/3303
146149 for index , channel_index in enumerate (channel_indexes ):
147- sig_chunk [:, index ] = data [channel_index :: self ._num_channels ]
150+ sig_chunk [:, index ] = data [channel_index :: self ._num_channels ]
148151
149152 return sig_chunk
150153
151154
152- def open_biocam_file_header (filename )-> dict :
155+ def open_biocam_file_header (filename ) -> dict :
153156 """Open a Biocam hdf5 file, read and return the recording info, pick the correct method to access raw data,
154157 and return this to the caller
155-
158+
156159 Parameters
157160 ----------
158161 filename: str
159162 The file to be parsed
160-
163+
161164 Returns
162165 -------
163166 dict
@@ -244,7 +247,7 @@ def open_biocam_file_header(filename)-> dict:
244247 num_channels_x = num_channels_y = int (np .sqrt (num_channels ))
245248 else :
246249 raise NeoReadWriteError ("No Well found in the file" )
247-
250+
248251 if num_channels_x * num_channels_y != num_channels :
249252 raise NeoReadWriteError (f"Cannot determine structure of the MEA plate with { num_channels } channels" )
250253 channels = 1 + np .concatenate (np .transpose (np .meshgrid (range (num_channels_x ), range (num_channels_y ))))
@@ -268,6 +271,7 @@ def open_biocam_file_header(filename)-> dict:
268271######################################################################
269272# Helper functions to obtain the raw data split by Biocam version.
270273
274+
271275# return the full array for the old datasets
272276def readHDF5t_100 (rf , t0 , t1 , nch ):
273277 return rf ["3BData/Raw" ][t0 :t1 ]
0 commit comments