Skip to content

Fix channel order bug and make select_channels private#4712

Open
chrishalcrow wants to merge 8 commits into
SpikeInterface:mainfrom
chrishalcrow:select-channel-fixes
Open

Fix channel order bug and make select_channels private#4712
chrishalcrow wants to merge 8 commits into
SpikeInterface:mainfrom
chrishalcrow:select-channel-fixes

Conversation

@chrishalcrow

@chrishalcrow chrishalcrow commented Jul 24, 2026

Copy link
Copy Markdown
Member

Fixes a channel order bug in the sparsity mask for the new select_channels method for analyzers.

Discussed with @alejoe91 and decided to keep this method private for now - we hope users will access through the split_by method rather than directly.

Fixed waveforms and pca selection.

Todo: add tests for waveforms and pca.

@chrishalcrow chrishalcrow added the core Changes to core module label Jul 24, 2026

@alejoe91 alejoe91 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Renaming

Comment thread src/spikeinterface/postprocessing/principal_component.py Outdated
Comment thread src/spikeinterface/postprocessing/principal_component.py Outdated
Comment thread src/spikeinterface/postprocessing/principal_component.py Outdated
@chrishalcrow
chrishalcrow marked this pull request as ready for review July 24, 2026 12:20

# Select channels, in a non-monotonic way
select_channel_ids = np.array(["3", "8", "7"])
analyzer_seleted = sorting_analyzer._select_channels(channel_ids=select_channel_ids)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
analyzer_seleted = sorting_analyzer._select_channels(channel_ids=select_channel_ids)
analyzer_selected = sorting_analyzer._select_channels(channel_ids=select_channel_ids)

:)

wrong_channel_ids = [ch for ch in channel_ids if ch not in self.channel_ids]
raise ValueError(f"Some channel_ids are not in the current channel_ids: {wrong_channel_ids}")

select_channel_indices_in_old_recording = [np.where(self.channel_ids == id)[0][0] for id in channel_ids]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
select_channel_indices_in_old_recording = [np.where(self.channel_ids == id)[0][0] for id in channel_ids]
select_channel_indices_in_old_recording = self.channel_ids_to_indices(channek_ids)

Why not this? self is still the old analyzer and it keeps the order, right?

@alejoe91 alejoe91 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Another couple of minor comments :)

@alejoe91 alejoe91 added this to the 0.105.0 milestone Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Changes to core module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants