Add per-group ref_channel_ids to common_reference#4601
Open
grahamfindlay wants to merge 2 commits into
Open
Conversation
…ncing) With reference="global" + groups, common_reference referenced each group to its OWN channels and ignored ref_channel_ids, despite the docstring stating "a list of channels to be applied to each group is expected". This allows ref_channel_ids to be a list of per-group channel-id lists: the reference subtracted from each group is the operator (median/average) over that group's reference set, which may include channels OUTSIDE the group. This enables cross-group referencing (e.g. each tetrode referenced to the median of all channels on the other tetrodes). ref_channel_ids=None (default) keeps the previous own-group behavior.
The most principled reference for a tetrode may sometimes be the average/median of all OTHER tetrodes. In other words, each group is referenced to all channels NOT in it -- ref_channel_ids is each group's complement (with "global" reference and "groups"). Adds common_reference(..., ref_channel_ids="complement") as syntactic sugar for this.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
reference="global"andgroupspassed (i.e. notNone),common_reference()referenced each group to its own channels and ignoredref_channel_ids. I'm not sure if this was intended behavior or a bug. I think a bug, because the docstring stated "a list of channels to be applied to each group is expected", and I read that as "a list of channels per group to be applied to that group is expected". That would be useful for tetrode recordings, because the most principled reference for a tetrode may sometimes be the average/median of all OTHER tetrodes (i.e., don't subtract the tetrode's average/median from itself -- especially with small numbers of tetrodes, this could be dangerous).Therefore this PR has 2 commits. The second just introduces some convenient syntactic sugar for the functionality provided by the first.
ref_channel_idsto be a list of per-group channel-id lists: the reference subtracted from each group is the operator (median/average) over that group's reference set, which may include channels OUTSIDE the group. This enables cross-group referencing (e.g. each tetrode referenced to the median of all channels on the other tetrodes).ref_channel_ids=None(default) keeps the previous own-group behavior.common_reference(..., ref_channel_ids="complement")as syntacticsugar for referencing each group to all channels NOT in it -- it just auto-builds the correct
ref_channel_idsto accomplish this.So now if you have groups that represent the tetrodes, you can do tetrode-aware referencing with:
or