Skip to content

Commit 9b4e048

Browse files
committed
finish PR
1 parent b409753 commit 9b4e048

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

neo/rawio/neuralynxrawio/neuralynxrawio.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,11 @@ def _build_stream_key(self, header_info, chan_index, gain):
240240

241241
input_inverted = header_info.get("input_inverted", False)
242242

243-
# Filter parameters (already normalized by NlxHeader)
243+
# Build filter parameters tuple (already normalized by NlxHeader)
244244
filter_params = []
245245
for key in self._filter_keys:
246-
value = header_info.get(key)
247-
if value is not None:
248-
filter_params.append((key, value))
246+
if key in header_info:
247+
filter_params.append((key, header_info[key]))
249248

250249
# Create hashable stream key
251250
stream_key = (
@@ -465,20 +464,20 @@ def _parse_header(self):
465464
event_channels = np.array(event_channels, dtype=_event_channel_dtype)
466465

467466
if signal_channels.size > 0:
468-
# Build filter configuration registry
469-
filter_configs = {} # filter_params_tuple -> filter_id
467+
# Build filter configuration registry: filter_id -> filter parameters dict
468+
# Use temporary dict to deduplicate filter configs while building
470469
_filter_configurations = {} # filter_id -> filter parameters dict
470+
seen_filters = {} # filter_params_tuple -> filter_id (temporary)
471471

472472
for stream_key, stream_info in stream_props.items():
473473
# Extract filter parameters from stream_key
474474
# stream_key = (sampling_rate, input_range, gain, input_inverted, filter_params_tuple)
475475
sampling_rate, input_range, gain, input_inverted, filter_params_tuple = stream_key
476476

477477
# Assign filter ID (deduplicated by filter_params_tuple)
478-
if filter_params_tuple not in filter_configs:
479-
filter_id = len(filter_configs)
480-
filter_configs[filter_params_tuple] = filter_id
481-
# Convert filter_params_tuple to dict for storage
478+
if filter_params_tuple not in seen_filters:
479+
filter_id = len(_filter_configurations)
480+
seen_filters[filter_params_tuple] = filter_id
482481
_filter_configurations[filter_id] = dict(filter_params_tuple)
483482

484483
# Store filter configurations as private instance attribute
@@ -497,7 +496,7 @@ def _parse_header(self):
497496

498497
# Unpack stream_key and format stream name
499498
sampling_rate, input_range, gain, input_inverted, filter_params_tuple = stream_key
500-
filter_id = filter_configs[filter_params_tuple]
499+
filter_id = seen_filters[filter_params_tuple]
501500
voltage_mv = int(input_range / 1000) if input_range is not None else 0
502501
stream_name = f"stream{stream_id}_{int(sampling_rate)}Hz_{voltage_mv}mVRange_f{filter_id}"
503502

0 commit comments

Comments
 (0)