Skip to content

Commit b32247d

Browse files
committed
improve erro furhter
1 parent ad70604 commit b32247d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

neo/rawio/blackrockrawio.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ def _parse_header(self):
336336
# E.g. it is 1 for 30_000, 3 for 10_000, etc
337337
nsx_period = self._nsx_basic_header[nsx_nb]["period"]
338338
sampling_rate = 30_000.0 / nsx_period
339-
self._nsx_sampling_frequency[nsx_nb] = sampling_rate
339+
self._nsx_sampling_frequency[nsx_nb] = float(sampling_rate)
340340

341341

342342
# Parase data packages
@@ -398,7 +398,8 @@ def _parse_header(self):
398398
self._match_nsx_and_nev_segment_ids(nsx_nb)
399399

400400
self.nsx_datas = {}
401-
self.sig_sampling_rates = {}
401+
# Keep public attribute for backward compatibility but let's use the private one and maybe deprecate this at some point
402+
self.sig_sampling_rates = {nsx_number: self._nsx_sampling_frequency[nsx_number] for nsx_number in self.nsx_to_load}
402403
if len(self.nsx_to_load) > 0:
403404
for nsx_nb in self.nsx_to_load:
404405
basic_header = self._nsx_basic_header[nsx_nb]
@@ -415,8 +416,7 @@ def _parse_header(self):
415416
_data_reader_fun = self._nsx_data_reader[spec_version]
416417
self.nsx_datas[nsx_nb] = _data_reader_fun(nsx_nb)
417418

418-
sr = float(self.main_sampling_rate / basic_header["period"])
419-
self.sig_sampling_rates[nsx_nb] = sr
419+
sr = self._nsx_sampling_frequency[nsx_nb]
420420

421421
if spec_version in ["2.2", "2.3", "3.0"]:
422422
ext_header = self._nsx_ext_header[nsx_nb]
@@ -485,7 +485,7 @@ def _parse_header(self):
485485
length = self.nsx_datas[nsx_nb][data_bl].shape[0]
486486
if self._nsx_data_header[nsx_nb] is None:
487487
t_start = 0.0
488-
t_stop = max(t_stop, length / self.sig_sampling_rates[nsx_nb])
488+
t_stop = max(t_stop, length / self._nsx_sampling_frequency[nsx_nb])
489489
else:
490490
timestamps = self._nsx_data_header[nsx_nb][data_bl]["timestamp"]
491491
if hasattr(timestamps, "size") and timestamps.size == length:
@@ -494,7 +494,7 @@ def _parse_header(self):
494494
t_stop = max(t_stop, timestamps[-1] / ts_res + sec_per_samp)
495495
else:
496496
t_start = timestamps / ts_res
497-
t_stop = max(t_stop, t_start + length / self.sig_sampling_rates[nsx_nb])
497+
t_stop = max(t_stop, t_start + length / self._nsx_sampling_frequency[nsx_nb])
498498
self._sigs_t_starts[nsx_nb].append(t_start)
499499

500500
if self._avail_files["nev"]:
@@ -1094,7 +1094,7 @@ def _read_nsx_dataheader_spec_v30_ptp(
10941094
threshold_ms = segmentation_threshold * 1000
10951095

10961096
segmentation_report_message = (
1097-
f"\nFound {len(gap_sample_indices)} gaps where samples are farther apart than {threshold_ms:.3f} ms.\n"
1097+
f"\nFound {len(gap_sample_indices)} gaps for nsx {nsx_nb} where samples are farther apart than {threshold_ms:.3f} ms.\n"
10981098
f"Data will be segmented at these locations to create {len(segment_start_indices)} segments.\n\n"
10991099
"Gap Details:\n"
11001100
"+-----------------+-----------------------+-----------------------+\n"
@@ -1184,7 +1184,7 @@ def _read_nsx_data_spec_v30_ptp(self, nsx_nb):
11841184
("reserved", "uint8"),
11851185
("timestamps", "uint64"),
11861186
("num_data_points", "uint32"),
1187-
("samples", "int16", self._nsx_basic_header[nsx_nb]["channel_count"]),
1187+
("samples", "int16", (self._nsx_basic_header[nsx_nb]["channel_count"],)),
11881188
]
11891189

11901190
data = {}

0 commit comments

Comments
 (0)