Skip to content

Commit

Permalink
blackrockrawio - fix backwards compatibility by retrieving 'timestamp…
Browse files Browse the repository at this point in the history
…_resolution' from another location for older file spec.
  • Loading branch information
cboulay committed Oct 23, 2023
1 parent e294bb1 commit 1cc5621
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion neo/rawio/blackrockrawio.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,12 @@ def _parse_header(self):
for data_bl in range(self._nb_segment):
t_stop = 0.
for nsx_nb in self.nsx_to_load:
ts_res = self.__nsx_basic_header[nsx_nb]['timestamp_resolution']
if 'timestamp_resolution' in self.__nsx_basic_header[nsx_nb].dtype.names:
ts_res = self.__nsx_basic_header[nsx_nb]['timestamp_resolution']
elif spec == '2.1':
ts_res = self.__nsx_params[spec](nsx_nb)['timestamp_resolution']
else:
ts_res = 30_000
period = self.__nsx_basic_header[nsx_nb]['period']
sec_per_samp = period / 30_000
n_samples = self.nsx_datas[nsx_nb][data_bl].shape[0]
Expand Down Expand Up @@ -827,6 +832,8 @@ def __read_nsx_header_variant_a(self, nsx_nb):
('channel_count', 'uint32')]

nsx_basic_header = np.fromfile(filename, count=1, dtype=dt0)[0]
# Note: it is not possible to use recfunctions to append_fields of 'timestamp_resolution',
# because the size of this object is used as the header size in later read operations.

# "extended" header (last field of file_id: NEURALCD)
# (to facilitate compatibility with higher file specs)
Expand Down

0 comments on commit 1cc5621

Please sign in to comment.