Skip to content

Commit 6eb09a6

Browse files
committed
propgate to children
1 parent b3ab028 commit 6eb09a6

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

src/spikeinterface/preprocessing/basepreprocessor.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ def __init__(self, recording, sampling_frequency=None, channel_ids=None, dtype=N
2121
recording.copy_metadata(self, only_main=False, ids=channel_ids)
2222
self._parent = recording
2323

24+
# Propagate the attached probegroup. copy_metadata only handles annotations
25+
# and properties; `_probegroup` is a direct attribute and needs its own path.
26+
# Subclasses that change channels (e.g. slicing) should override by slicing
27+
# the probegroup themselves via set_probegroup.
28+
if getattr(recording, "_probegroup", None) is not None and channel_ids is None:
29+
self._probegroup = recording._probegroup
30+
2431
# self._kwargs have to be handled in subclass
2532

2633

src/spikeinterface/preprocessing/tests/test_interpolate_bad_channels.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def test_compare_input_argument_ranges_against_ibl(shanks, p, sigma_um, num_chan
126126
# distribute default probe locations across 4 shanks if set
127127
rng = np.random.default_rng(seed=None)
128128
x = rng.choice(shanks, num_channels)
129-
probe = recording.get_probegroup().probes[0]
129+
probe = recording._probegroup.probes[0]
130130
probe._contact_positions[:, 0] = x
131131
recording._probegroup._build_contact_vector()
132132
recording.set_property("location", recording.get_channel_locations())
@@ -172,7 +172,7 @@ def test_output_values():
172172
[5, 5, 5, 7, 3],
173173
] # all others equal distance away.
174174
# Overwrite the probe information with the new locations
175-
probe = recording.get_probegroup().probes[0]
175+
probe = recording._probegroup.probes[0]
176176
for idx, (x, y) in enumerate(zip(*new_probe_locs)):
177177
probe._contact_positions[idx, 0] = x
178178
probe._contact_positions[idx, 1] = y
@@ -191,7 +191,7 @@ def test_output_values():
191191
# Shift the last channel position so that it is 4 units, rather than 2
192192
# away. Setting sigma_um = p = 1 allows easy calculation of the expected
193193
# weights.
194-
probe = recording.get_probegroup().probes[0]
194+
probe = recording._probegroup.probes[0]
195195
probe._contact_positions[-1, 0] = 5
196196
probe._contact_positions[-1, 1] = 9
197197
recording._probegroup._build_contact_vector()

0 commit comments

Comments
 (0)