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

Fix: save a copy of group ids in CommonReferenceRecording #2215

Merged
merged 4 commits into from
Nov 22, 2023
Merged
Changes from 2 commits
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
22 changes: 16 additions & 6 deletions src/spikeinterface/preprocessing/common_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,17 @@ def __init__(

# tranforms groups (ids) to groups (indices)
if groups is not None:
groups = [self.ids_to_indices(g) for g in groups]
groups_inds = [self.ids_to_indices(g) for g in groups]
oaaij-gnahz marked this conversation as resolved.
Show resolved Hide resolved
else:
groups_inds = None
if ref_channel_ids is not None:
ref_channel_inds = self.ids_to_indices(ref_channel_ids)
else:
ref_channel_inds = None

for parent_segment in recording._recording_segments:
rec_segment = CommonReferenceRecordingSegment(
parent_segment, reference, operator, groups, ref_channel_inds, local_radius, neighbors, dtype_
parent_segment, reference, operator, groups_inds, ref_channel_inds, local_radius, neighbors, dtype_
)
self.add_recording_segment(rec_segment)

Expand All @@ -123,13 +125,21 @@ def __init__(

class CommonReferenceRecordingSegment(BasePreprocessorSegment):
def __init__(
self, parent_recording_segment, reference, operator, groups, ref_channel_inds, local_radius, neighbors, dtype
self,
parent_recording_segment,
reference,
operator,
groups_inds,
ref_channel_inds,
local_radius,
neighbors,
dtype,
):
BasePreprocessorSegment.__init__(self, parent_recording_segment)

self.reference = reference
self.operator = operator
self.groups = groups
self.groups_inds = groups_inds
self.ref_channel_inds = ref_channel_inds
self.local_radius = local_radius
self.neighbors = neighbors
Expand Down Expand Up @@ -175,8 +185,8 @@ def get_traces(self, start_frame, end_frame, channel_indices):
def _groups(self, channel_indices):
selected_groups = []
selected_channels = []
if self.groups:
for chan_inds in self.groups:
if self.groups_inds:
for chan_inds in self.groups_inds:
sel_inds = [ind for ind in channel_indices if ind in chan_inds]
# if no channels are in a group, do not return the group
if len(sel_inds) > 0:
Expand Down