@@ -54,15 +54,16 @@ def _parse_header(self):
5454 self ._sampling_rate = self ._header_dict ["sampling_rate" ]
5555 self ._filehandle = self ._header_dict ["file_handle" ]
5656 self ._read_function = self ._header_dict ["read_function" ]
57+ self ._channels = self ._header_dict ["channels" ]
5758 channel_locations = self ._header_dict ["locations" ]
5859 gain = self ._header_dict ["gain" ]
5960 offset = self ._header_dict ["offset" ]
6061
6162 signal_streams = np .array ([('Signals' , '0' )], dtype = _signal_stream_dtype )
6263
6364 sig_channels = []
64- for c in range (self ._num_channels ):
65- ch_name = 'ch{}' . format ( c )
65+ for c , chan in enumerate (self ._channels ):
66+ ch_name = f 'ch{ chan [ 0 ] } - { chan [ 1 ] } '
6667 chan_id = str (c + 1 )
6768 sr = self ._sampling_rate # Hz
6869 dtype = "uint16"
@@ -140,26 +141,24 @@ def open_biocam_file_header(filename, mea_pitch, verbose=False):
140141 n_frames = rec_vars ['NRecFrames' ][0 ]
141142 sampling_rate = rec_vars ['SamplingRate' ][0 ]
142143 signal_inv = rec_vars ['SignalInversion' ][0 ]
143- # Read chip variables
144- chip_vars = rf .require_group ('3BRecInfo/3BMeaChip/' )
145- n_cols = chip_vars ['NCols' ][0 ]
144+
146145 # Get the actual number of channels used in the recording
147146 file_format = rf ['3BData' ].attrs .get ('Version' , None )
148147 format_100 = False
149148 if file_format == 100 :
150149 n_channels = len (rf ['3BData/Raw' ][0 ])
151150 format_100 = True
152151 elif file_format in (101 , 102 ) or file_format is None :
153- n_channels = int (1. * rf ['3BData/Raw' ].shape [0 ] / n_frames )
152+ n_channels = int (rf ['3BData/Raw' ].shape [0 ] / n_frames )
154153 else :
155154 raise Exception ('Unknown data file format.' )
156155
157156 # get channel locations
158- rows = ( rf ['3BRecInfo/3BMeaStreams/Raw/Chs' ][()][ 'Row' ] - 1 ) * mea_pitch
159- cols = ( rf [ '3BRecInfo/3BMeaStreams/Raw/Chs' ][()][ 'Col' ] - 1 ) * mea_pitch
160- locations = np . vstack (( rows , cols )). T
161- # assign channel numbers
162- ch_indices = np . array ([( x - 1 ) + ( y - 1 ) * n_cols for ( y , x ) in locations ])
157+ channels = rf ['3BRecInfo/3BMeaStreams/Raw/Chs' ][:]
158+ rows = channels [ 'Row' ] - 1
159+ cols = channels [ 'Col' ] - 1
160+ locations = np . vstack (( rows , cols )). T * mea_pitch
161+
163162 # determine correct function to read data
164163 if format_100 :
165164 if signal_inv == 1 :
@@ -180,8 +179,8 @@ def open_biocam_file_header(filename, mea_pitch, verbose=False):
180179 offset = min_uv
181180
182181 return dict (file_handle = rf , num_frames = n_frames , sampling_rate = sampling_rate , num_channels = n_channels ,
183- channel_inds = ch_indices , file_format = file_format , signal_inv = signal_inv ,
184- locations = locations , read_function = read_function , gain = gain , offset = offset )
182+ channels = channels , file_format = file_format , signal_inv = signal_inv , locations = locations ,
183+ read_function = read_function , gain = gain , offset = offset )
185184
186185
187186def readHDF5t_100 (rf , t0 , t1 , nch ):
0 commit comments