Skip to content

Commit

Permalink
Make _set_probes private (#2949)
Browse files Browse the repository at this point in the history
* make _set_probes private

* fix spikegadgets

* add deprecation

* Heberto improvement

Co-authored-by: Heberto Mayorquin <[email protected]>

* Update src/spikeinterface/extractors/neoextractors/spikegadgets.py

---------

Co-authored-by: Heberto Mayorquin <[email protected]>
Co-authored-by: Alessio Buccino <[email protected]>
  • Loading branch information
3 people authored Jun 5, 2024
1 parent 7f1f424 commit 8bbccab
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
23 changes: 19 additions & 4 deletions src/spikeinterface/core/baserecordingsnippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ def set_probe(self, probe, group_mode="by_probe", in_place=False):
assert isinstance(probe, Probe), "must give Probe"
probegroup = ProbeGroup()
probegroup.add_probe(probe)
return self.set_probes(probegroup, group_mode=group_mode, in_place=in_place)
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):
return self.set_probes(probegroup, group_mode=group_mode, in_place=in_place)
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="by_probe", 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.
Expand Down Expand Up @@ -233,6 +233,21 @@ def set_probes(self, probe_or_probegroup, group_mode="by_probe", in_place=False)

return sub_recording

def set_probes(self, probe_or_probegroup, group_mode="by_probe", in_place=False):

warning_msg = (
"`set_probes` is now a private function and the public function will be "
"removed in 0.103.0. Please use `set_probe` or `set_probegroups` instead"
)

warn(warning_msg, category=DeprecationWarning, stacklevel=2)

sub_recording = self._set_probes(
probe_or_probegroup=probe_or_probegroup, group_mode=group_mode, in_place=in_place
)

return sub_recording

def get_probe(self):
probes = self.get_probes()
assert len(probes) == 1, "there are several probe use .get_probes() or get_probegroup()"
Expand Down Expand Up @@ -329,7 +344,7 @@ def set_dummy_probe_from_locations(self, locations, shape="circle", shape_params

def set_channel_locations(self, locations, channel_ids=None):
if self.get_property("contact_vector") is not None:
raise ValueError("set_channel_locations(..) destroy the probe description, prefer set_probes(..)")
raise ValueError("set_channel_locations(..) destroys the probe description, prefer _set_probes(..)")
self.set_property("location", locations, ids=channel_ids)

def get_channel_locations(self, channel_ids=None, axes: str = "xy"):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(self, file_path, stream_id=None, stream_name=None, block_index=None
probegroup = probeinterface.read_spikegadgets(file_path, raise_error=False)

if probegroup is not None:
self.set_probes(probegroup, in_place=True)
self.set_probegroup(probegroup, in_place=True)

@classmethod
def map_to_neo_kwargs(cls, file_path):
Expand Down

0 comments on commit 8bbccab

Please sign in to comment.