From f258e2ea8149b9836cd1b8068872a6622eb95147 Mon Sep 17 00:00:00 2001 From: Samuel Garcia Date: Wed, 17 Dec 2025 21:21:14 +0100 Subject: [PATCH 01/10] Implement the by_side grouping with probes --- .../core/baserecordingsnippets.py | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/spikeinterface/core/baserecordingsnippets.py b/src/spikeinterface/core/baserecordingsnippets.py index 56f558bce7..526aa9bbc6 100644 --- a/src/spikeinterface/core/baserecordingsnippets.py +++ b/src/spikeinterface/core/baserecordingsnippets.py @@ -105,7 +105,7 @@ def _set_probes(self, probe_or_probegroup, group_mode="by_probe", in_place=False The probe(s) to be attached to the recording group_mode: "by_probe" | "by_shank", default: "by_probe" "by_probe" or "by_shank". Adds grouping property to the recording based on the probes ("by_probe") - or shanks ("by_shank") + or shanks ("by_shank") or by probe side ("by_side") in_place: bool False by default. Useful internally when extractor do self.set_probegroup(probe) @@ -115,7 +115,7 @@ def _set_probes(self, probe_or_probegroup, group_mode="by_probe", in_place=False sub_recording: BaseRecording A view of the recording (ChannelSlice or clone or itself) """ - assert group_mode in ("by_probe", "by_shank"), "'group_mode' can be 'by_probe' or 'by_shank'" + assert group_mode in ("by_probe", "by_shank", "by_side"), "'group_mode' can be 'by_probe' or 'by_shank' or 'by_side'" # handle several input possibilities if isinstance(probe_or_probegroup, Probe): @@ -213,6 +213,24 @@ def _set_probes(self, probe_or_probegroup, group_mode="by_probe", in_place=False probe_as_numpy_array["shank_ids"] == a["shank_ids"] ) groups[mask] = group + elif group_mode == "by_side": + assert all( + probe.contact_sides is not None for probe in probegroup.probes + ), "contact_sides is None in probe, you cannot group by side" + if probe.shank_ids is None: + for group, a in enumerate(np.unique(probe_as_numpy_array[["probe_index", "contact_sides"]])): + mask = (probe_as_numpy_array["probe_index"] == a["probe_index"]) & ( + probe_as_numpy_array["contact_sides"] == a["contact_sides"] + ) + groups[mask] = group + else: + for group, a in enumerate(np.unique(probe_as_numpy_array[["probe_index", "shank_ids", "contact_sides"]])): + mask = (probe_as_numpy_array["probe_index"] == a["probe_index"]) & ( + probe_as_numpy_array["shank_ids"] == a["shank_ids"]) & ( + probe_as_numpy_array["contact_sides"] == a["contact_sides"] + ) + groups[mask] = group + sub_recording.set_property("group", groups, ids=None) # add probe annotations to recording From d5f15d2a2b5dd00b66a31a0620e1374f02d96b98 Mon Sep 17 00:00:00 2001 From: Samuel Garcia Date: Fri, 19 Dec 2025 12:04:15 +0100 Subject: [PATCH 02/10] better handling of grouping when set_probe() add "auto" mode --- .../core/baserecordingsnippets.py | 72 +++++++++---------- .../core/tests/test_baserecording.py | 12 ++-- 2 files changed, 41 insertions(+), 43 deletions(-) diff --git a/src/spikeinterface/core/baserecordingsnippets.py b/src/spikeinterface/core/baserecordingsnippets.py index 526aa9bbc6..adfd493446 100644 --- a/src/spikeinterface/core/baserecordingsnippets.py +++ b/src/spikeinterface/core/baserecordingsnippets.py @@ -61,7 +61,7 @@ def is_filtered(self): # the is_filtered is handle with annotation return self._annotations.get("is_filtered", False) - def set_probe(self, probe, group_mode="by_probe", in_place=False): + def set_probe(self, probe, group_mode="auto", in_place=False): """ Attach a list of Probe object to a recording. @@ -69,9 +69,9 @@ def set_probe(self, probe, group_mode="by_probe", in_place=False): ---------- probe_or_probegroup: Probe, list of Probe, or ProbeGroup The probe(s) to be attached to the recording - group_mode: "by_probe" | "by_shank", default: "by_probe - "by_probe" or "by_shank". Adds grouping property to the recording based on the probes ("by_probe") - or shanks ("by_shanks") + group_mode: "auto" | "by_probe" | "by_shank" | "by_side", default: "auto" + How to add the "group" property. + "auto" is the best splitting possible that can be all at once when multiple, probe with multiple shanks and 2 sides. in_place: bool False by default. Useful internally when extractor do self.set_probegroup(probe) @@ -86,10 +86,10 @@ def set_probe(self, probe, group_mode="by_probe", in_place=False): probegroup.add_probe(probe) return self._set_probes(probegroup, group_mode=group_mode, in_place=in_place) - def set_probegroup(self, probegroup, group_mode="by_probe", in_place=False): + def set_probegroup(self, probegroup, group_mode="auto", in_place=False): return self._set_probes(probegroup, group_mode=group_mode, in_place=in_place) - def _set_probes(self, probe_or_probegroup, group_mode="by_probe", in_place=False): + def _set_probes(self, probe_or_probegroup, group_mode="auto", in_place=False): """ Attach a list of Probe objects to a recording. For this Probe.device_channel_indices is used to link contacts to recording channels. @@ -103,9 +103,9 @@ def _set_probes(self, probe_or_probegroup, group_mode="by_probe", in_place=False ---------- probe_or_probegroup: Probe, list of Probe, or ProbeGroup The probe(s) to be attached to the recording - group_mode: "by_probe" | "by_shank", default: "by_probe" - "by_probe" or "by_shank". Adds grouping property to the recording based on the probes ("by_probe") - or shanks ("by_shank") or by probe side ("by_side") + group_mode: "auto" | "by_probe" | "by_shank" | "by_side", default: "auto" + How to add the "group" property. + "auto" is the best splitting possible that can be all at once when multiple, probe with multiple shanks and 2 sides. in_place: bool False by default. Useful internally when extractor do self.set_probegroup(probe) @@ -115,7 +115,7 @@ def _set_probes(self, probe_or_probegroup, group_mode="by_probe", in_place=False sub_recording: BaseRecording A view of the recording (ChannelSlice or clone or itself) """ - assert group_mode in ("by_probe", "by_shank", "by_side"), "'group_mode' can be 'by_probe' or 'by_shank' or 'by_side'" + assert group_mode in ("auto", "by_probe", "by_shank", "by_side"), "'group_mode' can be 'auto' 'by_probe' 'by_shank' or 'by_side'" # handle several input possibilities if isinstance(probe_or_probegroup, Probe): @@ -199,38 +199,32 @@ def _set_probes(self, probe_or_probegroup, group_mode="by_probe", in_place=False sub_recording.set_property("location", locations, ids=None) # handle groups - groups = np.zeros(probe_as_numpy_array.size, dtype="int64") - if group_mode == "by_probe": - for group, probe_index in enumerate(np.unique(probe_as_numpy_array["probe_index"])): - mask = probe_as_numpy_array["probe_index"] == probe_index - groups[mask] = group + all_has_shank_id = all(probe.shank_ids is not None for probe in probegroup.probes) + all_has_contact_side = all(probe.contact_sides is not None for probe in probegroup.probes) + if group_mode == "auto": + group_keys = ["probe_index"] + if all_has_shank_id: + group_keys += ["shank_ids"] + if all_has_contact_side: + group_keys += ["contact_sides"] + elif group_mode == "by_probe": + group_keys = ["probe_index"] elif group_mode == "by_shank": - assert all( - probe.shank_ids is not None for probe in probegroup.probes - ), "shank_ids is None in probe, you cannot group by shank" - for group, a in enumerate(np.unique(probe_as_numpy_array[["probe_index", "shank_ids"]])): - mask = (probe_as_numpy_array["probe_index"] == a["probe_index"]) & ( - probe_as_numpy_array["shank_ids"] == a["shank_ids"] - ) - groups[mask] = group + assert all_has_shank_id, "shank_ids is None in probe, you cannot group by shank" + group_keys = ["probe_index", "shank_ids"] elif group_mode == "by_side": - assert all( - probe.contact_sides is not None for probe in probegroup.probes - ), "contact_sides is None in probe, you cannot group by side" - if probe.shank_ids is None: - for group, a in enumerate(np.unique(probe_as_numpy_array[["probe_index", "contact_sides"]])): - mask = (probe_as_numpy_array["probe_index"] == a["probe_index"]) & ( - probe_as_numpy_array["contact_sides"] == a["contact_sides"] - ) - groups[mask] = group + assert all_has_contact_side, "contact_sides is None in probe, you cannot group by side" + if all_has_shank_id: + group_keys = ["probe_index", "shank_ids", "contact_sides"] else: - for group, a in enumerate(np.unique(probe_as_numpy_array[["probe_index", "shank_ids", "contact_sides"]])): - mask = (probe_as_numpy_array["probe_index"] == a["probe_index"]) & ( - probe_as_numpy_array["shank_ids"] == a["shank_ids"]) & ( - probe_as_numpy_array["contact_sides"] == a["contact_sides"] - ) - groups[mask] = group - + group_keys = ["probe_index", "contact_sides"] + groups = np.zeros(probe_as_numpy_array.size, dtype="int64") + unique_keys = np.unique(probe_as_numpy_array[group_keys]) + for group, a in enumerate(unique_keys): + mask = np.ones(probe_as_numpy_array.size, dtype=bool) + for k in group_keys: + mask &= (probe_as_numpy_array[k] == a[k]) + groups[mask] = group sub_recording.set_property("group", groups, ids=None) # add probe annotations to recording diff --git a/src/spikeinterface/core/tests/test_baserecording.py b/src/spikeinterface/core/tests/test_baserecording.py index 9de800b33d..d4fa26f5f8 100644 --- a/src/spikeinterface/core/tests/test_baserecording.py +++ b/src/spikeinterface/core/tests/test_baserecording.py @@ -179,11 +179,15 @@ def test_BaseRecording(create_cache_folder): # set/get Probe only 2 channels probe = Probe(ndim=2) - positions = [[0.0, 0.0], [0.0, 15.0], [0, 30.0]] - probe.set_contacts(positions=positions, shapes="circle", shape_params={"radius": 5}) - probe.set_device_channel_indices([2, -1, 0]) + positions = [[0.0, 0.0], [0.0, 15.0], [0, 30.0], + [100.0, 0.0], [100.0, 15.0], [100.0, 30.0], + ] + probe.set_contacts(positions=positions, shapes="circle", shape_params={"radius": 5}, shank_ids=["a"]*3 + ["b"]*3) + probe.set_device_channel_indices([2, -1, 0, -1, -1, -1 ], ) probe.create_auto_shape() + print("ici", probe.shank_ids) + rec_p = rec.set_probe(probe, group_mode="by_shank") rec_p = rec.set_probe(probe, group_mode="by_probe") positions2 = rec_p.get_channel_locations() @@ -216,7 +220,7 @@ def test_BaseRecording(create_cache_folder): # set unconnected probe probe = Probe(ndim=2) positions = [[0.0, 0.0], [0.0, 15.0], [0, 30.0]] - probe.set_contacts(positions=positions, shapes="circle", shape_params={"radius": 5}) + probe.set_contacts(positions=positions, shapes="circle", shape_params={"radius": 5}, shank_ids=["a", "a", "a"]) probe.set_device_channel_indices([-1, -1, -1]) probe.create_auto_shape() From e30806624a7cd67c86d2ba3fcc156a871278852f Mon Sep 17 00:00:00 2001 From: Samuel Garcia Date: Tue, 23 Dec 2025 14:41:09 +0100 Subject: [PATCH 03/10] Better shank_ids and contact__sides testing --- src/spikeinterface/core/baserecordingsnippets.py | 5 +++-- src/spikeinterface/core/tests/test_baserecording.py | 2 -- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/spikeinterface/core/baserecordingsnippets.py b/src/spikeinterface/core/baserecordingsnippets.py index adfd493446..e2794f4eea 100644 --- a/src/spikeinterface/core/baserecordingsnippets.py +++ b/src/spikeinterface/core/baserecordingsnippets.py @@ -150,6 +150,7 @@ def _set_probes(self, probe_or_probegroup, group_mode="auto", in_place=False): warn("The given probes have unconnected contacts: they are removed") probe_as_numpy_array = probe_as_numpy_array[keep] + device_channel_indices = probe_as_numpy_array["device_channel_indices"] order = np.argsort(device_channel_indices) device_channel_indices = device_channel_indices[order] @@ -199,8 +200,8 @@ def _set_probes(self, probe_or_probegroup, group_mode="auto", in_place=False): sub_recording.set_property("location", locations, ids=None) # handle groups - all_has_shank_id = all(probe.shank_ids is not None for probe in probegroup.probes) - all_has_contact_side = all(probe.contact_sides is not None for probe in probegroup.probes) + all_has_shank_id = "shank_ids" in probe_as_numpy_array.dtype.fields + all_has_contact_side = "contact_sides" in probe_as_numpy_array.dtype.fields if group_mode == "auto": group_keys = ["probe_index"] if all_has_shank_id: diff --git a/src/spikeinterface/core/tests/test_baserecording.py b/src/spikeinterface/core/tests/test_baserecording.py index d4fa26f5f8..2272de76dc 100644 --- a/src/spikeinterface/core/tests/test_baserecording.py +++ b/src/spikeinterface/core/tests/test_baserecording.py @@ -186,8 +186,6 @@ def test_BaseRecording(create_cache_folder): probe.set_device_channel_indices([2, -1, 0, -1, -1, -1 ], ) probe.create_auto_shape() - print("ici", probe.shank_ids) - rec_p = rec.set_probe(probe, group_mode="by_shank") rec_p = rec.set_probe(probe, group_mode="by_probe") positions2 = rec_p.get_channel_locations() From bc5ac77cd597fa2b60a4f48fa5f957ab0f1eea22 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 23 Dec 2025 13:43:34 +0000 Subject: [PATCH 04/10] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../core/baserecordingsnippets.py | 9 +++++++-- .../core/tests/test_baserecording.py | 19 ++++++++++++++----- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/spikeinterface/core/baserecordingsnippets.py b/src/spikeinterface/core/baserecordingsnippets.py index e2794f4eea..8527e6dec2 100644 --- a/src/spikeinterface/core/baserecordingsnippets.py +++ b/src/spikeinterface/core/baserecordingsnippets.py @@ -115,7 +115,12 @@ def _set_probes(self, probe_or_probegroup, group_mode="auto", in_place=False): sub_recording: BaseRecording A view of the recording (ChannelSlice or clone or itself) """ - assert group_mode in ("auto", "by_probe", "by_shank", "by_side"), "'group_mode' can be 'auto' 'by_probe' 'by_shank' or 'by_side'" + assert group_mode in ( + "auto", + "by_probe", + "by_shank", + "by_side", + ), "'group_mode' can be 'auto' 'by_probe' 'by_shank' or 'by_side'" # handle several input possibilities if isinstance(probe_or_probegroup, Probe): @@ -224,7 +229,7 @@ def _set_probes(self, probe_or_probegroup, group_mode="auto", in_place=False): for group, a in enumerate(unique_keys): mask = np.ones(probe_as_numpy_array.size, dtype=bool) for k in group_keys: - mask &= (probe_as_numpy_array[k] == a[k]) + mask &= probe_as_numpy_array[k] == a[k] groups[mask] = group sub_recording.set_property("group", groups, ids=None) diff --git a/src/spikeinterface/core/tests/test_baserecording.py b/src/spikeinterface/core/tests/test_baserecording.py index 2272de76dc..ad69b32ecb 100644 --- a/src/spikeinterface/core/tests/test_baserecording.py +++ b/src/spikeinterface/core/tests/test_baserecording.py @@ -179,11 +179,20 @@ def test_BaseRecording(create_cache_folder): # set/get Probe only 2 channels probe = Probe(ndim=2) - positions = [[0.0, 0.0], [0.0, 15.0], [0, 30.0], - [100.0, 0.0], [100.0, 15.0], [100.0, 30.0], - ] - probe.set_contacts(positions=positions, shapes="circle", shape_params={"radius": 5}, shank_ids=["a"]*3 + ["b"]*3) - probe.set_device_channel_indices([2, -1, 0, -1, -1, -1 ], ) + positions = [ + [0.0, 0.0], + [0.0, 15.0], + [0, 30.0], + [100.0, 0.0], + [100.0, 15.0], + [100.0, 30.0], + ] + probe.set_contacts( + positions=positions, shapes="circle", shape_params={"radius": 5}, shank_ids=["a"] * 3 + ["b"] * 3 + ) + probe.set_device_channel_indices( + [2, -1, 0, -1, -1, -1], + ) probe.create_auto_shape() rec_p = rec.set_probe(probe, group_mode="by_shank") From e93ec62e0a8a3eb1973a27dbcf4e7b37fff2c798 Mon Sep 17 00:00:00 2001 From: Samuel Garcia Date: Tue, 23 Dec 2025 14:57:04 +0100 Subject: [PATCH 05/10] oups --- src/spikeinterface/core/tests/test_baserecording.py | 1 + src/spikeinterface/core/tests/test_basesnippets.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/spikeinterface/core/tests/test_baserecording.py b/src/spikeinterface/core/tests/test_baserecording.py index 2272de76dc..e24f63ae93 100644 --- a/src/spikeinterface/core/tests/test_baserecording.py +++ b/src/spikeinterface/core/tests/test_baserecording.py @@ -186,6 +186,7 @@ def test_BaseRecording(create_cache_folder): probe.set_device_channel_indices([2, -1, 0, -1, -1, -1 ], ) probe.create_auto_shape() + rec_p = rec.set_probe(probe, group_mode="auto") rec_p = rec.set_probe(probe, group_mode="by_shank") rec_p = rec.set_probe(probe, group_mode="by_probe") positions2 = rec_p.get_channel_locations() diff --git a/src/spikeinterface/core/tests/test_basesnippets.py b/src/spikeinterface/core/tests/test_basesnippets.py index 04ebd1bd1d..751a03460c 100644 --- a/src/spikeinterface/core/tests/test_basesnippets.py +++ b/src/spikeinterface/core/tests/test_basesnippets.py @@ -142,7 +142,7 @@ def test_BaseSnippets(create_cache_folder): probe.set_device_channel_indices([2, -1, 0]) probe.create_auto_shape() - snippets_p = snippets.set_probe(probe, group_mode="by_shank") + snippets_p = snippets.set_probe(probe, group_mode="auto") snippets_p = snippets.set_probe(probe, group_mode="by_probe") positions2 = snippets_p.get_channel_locations() assert np.array_equal(positions2, [[0, 30.0], [0.0, 0.0]]) From ccf5d7683172ff78df38bf75137d97cdc34c938b Mon Sep 17 00:00:00 2001 From: Samuel Garcia Date: Tue, 23 Dec 2025 15:14:15 +0100 Subject: [PATCH 06/10] more tests for probe grouping --- .../core/tests/test_baserecording.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/spikeinterface/core/tests/test_baserecording.py b/src/spikeinterface/core/tests/test_baserecording.py index 32d8629b5e..bf028b2c66 100644 --- a/src/spikeinterface/core/tests/test_baserecording.py +++ b/src/spikeinterface/core/tests/test_baserecording.py @@ -219,12 +219,33 @@ def test_BaseRecording(create_cache_folder): assert np.array_equal(traces2, rec_p.get_traces(segment_index=0)) + # from probeinterface.plotting import plot_probe_group, plot_probe # import matplotlib.pyplot as plt # plot_probe(probe) # plot_probe(probe2) # plt.show() + # test different group mode + probe = Probe(ndim=2) + positions_two_side = positions + positions + shank_ids= ["a", "a", "a", "b", "b", "b"] * 2 + contact_sides = ["front"] * 6 + ["back"] * 6 + probe.set_contacts(positions=positions_two_side, shapes="circle", shape_params={"radius": 5}, shank_ids=shank_ids, contact_sides=contact_sides) + probe.set_device_channel_indices(np.arange(12)) + probe.create_auto_shape() + traces = np.zeros((1000, 12), dtype="int16") + rec = NumpyRecording([traces], 30000.) + rec1 = rec.set_probe(probe, group_mode="auto") + assert np.unique(rec1.get_property("group")).size == 4 + rec2 = rec.set_probe(probe, group_mode="by_probe") + assert np.unique(rec2.get_property("group")).size == 1 + rec3 = rec.set_probe(probe, group_mode="by_shank") + assert np.unique(rec3.get_property("group")).size == 2 + rec4 = rec.set_probe(probe, group_mode="by_side") + assert np.unique(rec4.get_property("group")).size == 4 + + # set unconnected probe probe = Probe(ndim=2) positions = [[0.0, 0.0], [0.0, 15.0], [0, 30.0]] From 743e27e6e61cc75595eafe70f74f3918c3214749 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 23 Dec 2025 14:15:34 +0000 Subject: [PATCH 07/10] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../core/tests/test_baserecording.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/spikeinterface/core/tests/test_baserecording.py b/src/spikeinterface/core/tests/test_baserecording.py index bf028b2c66..1ebeb677c6 100644 --- a/src/spikeinterface/core/tests/test_baserecording.py +++ b/src/spikeinterface/core/tests/test_baserecording.py @@ -219,7 +219,6 @@ def test_BaseRecording(create_cache_folder): assert np.array_equal(traces2, rec_p.get_traces(segment_index=0)) - # from probeinterface.plotting import plot_probe_group, plot_probe # import matplotlib.pyplot as plt # plot_probe(probe) @@ -229,13 +228,19 @@ def test_BaseRecording(create_cache_folder): # test different group mode probe = Probe(ndim=2) positions_two_side = positions + positions - shank_ids= ["a", "a", "a", "b", "b", "b"] * 2 + shank_ids = ["a", "a", "a", "b", "b", "b"] * 2 contact_sides = ["front"] * 6 + ["back"] * 6 - probe.set_contacts(positions=positions_two_side, shapes="circle", shape_params={"radius": 5}, shank_ids=shank_ids, contact_sides=contact_sides) + probe.set_contacts( + positions=positions_two_side, + shapes="circle", + shape_params={"radius": 5}, + shank_ids=shank_ids, + contact_sides=contact_sides, + ) probe.set_device_channel_indices(np.arange(12)) probe.create_auto_shape() traces = np.zeros((1000, 12), dtype="int16") - rec = NumpyRecording([traces], 30000.) + rec = NumpyRecording([traces], 30000.0) rec1 = rec.set_probe(probe, group_mode="auto") assert np.unique(rec1.get_property("group")).size == 4 rec2 = rec.set_probe(probe, group_mode="by_probe") @@ -245,7 +250,6 @@ def test_BaseRecording(create_cache_folder): rec4 = rec.set_probe(probe, group_mode="by_side") assert np.unique(rec4.get_property("group")).size == 4 - # set unconnected probe probe = Probe(ndim=2) positions = [[0.0, 0.0], [0.0, 15.0], [0, 30.0]] From afc34c072983e2251401e506b3e4394ef006360f Mon Sep 17 00:00:00 2001 From: Samuel Garcia Date: Tue, 23 Dec 2025 15:17:08 +0100 Subject: [PATCH 08/10] yep --- src/spikeinterface/core/baserecordingsnippets.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/spikeinterface/core/baserecordingsnippets.py b/src/spikeinterface/core/baserecordingsnippets.py index 8527e6dec2..7eb7f3c7f7 100644 --- a/src/spikeinterface/core/baserecordingsnippets.py +++ b/src/spikeinterface/core/baserecordingsnippets.py @@ -205,22 +205,22 @@ def _set_probes(self, probe_or_probegroup, group_mode="auto", in_place=False): sub_recording.set_property("location", locations, ids=None) # handle groups - all_has_shank_id = "shank_ids" in probe_as_numpy_array.dtype.fields - all_has_contact_side = "contact_sides" in probe_as_numpy_array.dtype.fields + has_shank_id = "shank_ids" in probe_as_numpy_array.dtype.fields + has_contact_side = "contact_sides" in probe_as_numpy_array.dtype.fields if group_mode == "auto": group_keys = ["probe_index"] - if all_has_shank_id: + if has_shank_id: group_keys += ["shank_ids"] - if all_has_contact_side: + if has_contact_side: group_keys += ["contact_sides"] elif group_mode == "by_probe": group_keys = ["probe_index"] elif group_mode == "by_shank": - assert all_has_shank_id, "shank_ids is None in probe, you cannot group by shank" + assert has_shank_id, "shank_ids is None in probe, you cannot group by shank" group_keys = ["probe_index", "shank_ids"] elif group_mode == "by_side": - assert all_has_contact_side, "contact_sides is None in probe, you cannot group by side" - if all_has_shank_id: + assert has_contact_side, "contact_sides is None in probe, you cannot group by side" + if has_shank_id: group_keys = ["probe_index", "shank_ids", "contact_sides"] else: group_keys = ["probe_index", "contact_sides"] From ad8b1fc856766c9aa1b0033686360dd2f37a2199 Mon Sep 17 00:00:00 2001 From: Samuel Garcia Date: Tue, 23 Dec 2025 15:20:20 +0100 Subject: [PATCH 09/10] yep --- src/spikeinterface/core/baserecordingsnippets.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/spikeinterface/core/baserecordingsnippets.py b/src/spikeinterface/core/baserecordingsnippets.py index 7eb7f3c7f7..b2f7a40669 100644 --- a/src/spikeinterface/core/baserecordingsnippets.py +++ b/src/spikeinterface/core/baserecordingsnippets.py @@ -71,7 +71,7 @@ def set_probe(self, probe, group_mode="auto", in_place=False): The probe(s) to be attached to the recording group_mode: "auto" | "by_probe" | "by_shank" | "by_side", default: "auto" How to add the "group" property. - "auto" is the best splitting possible that can be all at once when multiple, probe with multiple shanks and 2 sides. + "auto" is the best splitting possible that can be all at once when multiple probes, multiple shanks and two sides are present. in_place: bool False by default. Useful internally when extractor do self.set_probegroup(probe) @@ -105,7 +105,7 @@ def _set_probes(self, probe_or_probegroup, group_mode="auto", in_place=False): The probe(s) to be attached to the recording group_mode: "auto" | "by_probe" | "by_shank" | "by_side", default: "auto" How to add the "group" property. - "auto" is the best splitting possible that can be all at once when multiple, probe with multiple shanks and 2 sides. + "auto" is the best splitting possible that can be all at once when multiple probes, multiple shanks and two sides are present. in_place: bool False by default. Useful internally when extractor do self.set_probegroup(probe) From a3b5012d565252017fba8d629773678ba31ccfdc Mon Sep 17 00:00:00 2001 From: Samuel Garcia Date: Tue, 23 Dec 2025 15:38:47 +0100 Subject: [PATCH 10/10] oups --- src/spikeinterface/sorters/tests/test_runsorter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spikeinterface/sorters/tests/test_runsorter.py b/src/spikeinterface/sorters/tests/test_runsorter.py index 67f0582b7c..332e6e857e 100644 --- a/src/spikeinterface/sorters/tests/test_runsorter.py +++ b/src/spikeinterface/sorters/tests/test_runsorter.py @@ -56,7 +56,7 @@ def test_run_sorter_dict(generate_recording, create_cache_folder): recording.set_property(key="split_property", values=[4, 4, "g", "g", 4, 4, 4, "g"]) dict_of_recordings = recording.split_by("split_property") - sorter_params = {"detection": {"detect_threshold": 4.9}} + sorter_params = {"detect_threshold": 4.9} folder = cache_folder / "sorting_tdc_local_dict"