Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add get_channel_locations to the base recording api #3403

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/spikeinterface/core/baserecording.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,30 @@ def _select_segments(self, segment_indices):

return SelectSegmentRecording(self, segment_indices=segment_indices)

def get_channel_locations(
self,
channel_ids: list | np.ndarray | tuple | None = None,
axes: "xy" | "yz" | "xz" = "xy",
h-mayorquin marked this conversation as resolved.
Show resolved Hide resolved
) -> np.ndarray:
"""
Get the physical locations of specified channels.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is likely improvement enough for merging, but since contact vs channel is still a point of confusion for many users we may want to workshop better ways to talk about channel_locations for public functions.


Parameters
----------
channel_ids : array-like, optional
The IDs of the channels for which to retrieve locations. If None, retrieves locations
for all available channels. Default is None.
axes : str, optional
h-mayorquin marked this conversation as resolved.
Show resolved Hide resolved
The spatial axes to return, specified as a string (e.g., "xy", "xyz"). Default is "xy".

Returns
-------
np.ndarray
A 2D or 3D array of shape (n_channels, n_dimensions) containing the locations of the channels.
The number of dimensions depends on the `axes` argument (e.g., 2 for "xy", 3 for "xyz").
"""
return super().get_channel_locations(channel_ids=channel_ids, axes=axes)

def is_binary_compatible(self) -> bool:
"""
Checks if the recording is "binary" compatible.
Expand Down
2 changes: 1 addition & 1 deletion src/spikeinterface/core/baserecordingsnippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def set_channel_locations(self, locations, channel_ids=None):
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"):
def get_channel_locations(self, channel_ids=None, axes: str = "xy") -> np.ndarray:
if channel_ids is None:
channel_ids = self.get_channel_ids()
channel_indices = self.ids_to_indices(channel_ids)
Expand Down
Loading