Skip to content

Add option to use ref_channel_ids in global common reference#3139

Merged
alejoe91 merged 1 commit intoSpikeInterface:mainfrom
alejoe91:cmr-select-channels
Jul 8, 2024
Merged

Add option to use ref_channel_ids in global common reference#3139
alejoe91 merged 1 commit intoSpikeInterface:mainfrom
alejoe91:cmr-select-channels

Conversation

@alejoe91
Copy link
Copy Markdown
Member

@alejoe91 alejoe91 commented Jul 4, 2024

Fixes #2985

Add the option to select a subset of channels when reference is global via the ref_channel_ids argument.

@alejoe91 alejoe91 added the preprocessing Related to preprocessing module label Jul 4, 2024
@alejoe91 alejoe91 requested a review from h-mayorquin July 4, 2024 10:22
alejoe91 added a commit to alejoe91/spikeinterface that referenced this pull request Jul 4, 2024
@alejoe91 alejoe91 added this to the 0.101.0 milestone Jul 4, 2024
Copy link
Copy Markdown
Collaborator

@h-mayorquin h-mayorquin left a comment

Choose a reason for hiding this comment

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

OK, initially I felt that we were caving to adding yet another keyword for yet another specific case but after reading this I think you hit the jackpot.

This falls naturally in the semantics of ref_channel_ids, it involves minimal code changes and within the complexities of the interaction between groups and ref_channel_ids it is relatively easy to document and the explanation does not feel convoluted.

As an aside you can support exactly the use case in #2985 as a side effect of this.

Great!


traces = recording.get_traces()
assert np.allclose(traces, rec_cmr.get_traces() + np.median(traces, axis=1, keepdims=True), atol=0.01)
assert np.allclose(traces, rec_cmr_ref.get_traces() + np.median(traces[:, :3], axis=1, keepdims=True), atol=0.01)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I had to run this to understand it but makes sense.

def _generate_test_recording():
recording = generate_recording(durations=[1.0], num_channels=4)
recording = recording.channel_slice(recording.channel_ids, np.array(["a", "b", "c", "d"]))
recording = recording.rename_channels(np.array(["a", "b", "c", "d"]))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yei!

@alejoe91 alejoe91 merged commit e08059f into SpikeInterface:main Jul 8, 2024
alejoe91 added a commit that referenced this pull request Jul 8, 2024
@alejoe91 alejoe91 deleted the cmr-select-channels branch March 20, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preprocessing Related to preprocessing module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature request: bad channel exclusion from common_reference function

2 participants