Repository navigation
Fix channel order bug and make select_channels private
#4712
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
Changes from 8 commits
b84613b
f21e73f
cacbb31
66396fb
c9e1caa
9502b82
821aeb6
3132f3b
14d9a00
29a7d08
eb2c9f0
19e7243
94985b2
0ce2892
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -257,6 +257,44 @@ def _select_units_extension_data(self, unit_ids): | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| return new_data | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| def _select_channels_extension_data(self, channel_ids): | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| unit_ids = self.sorting_analyzer.unit_ids | ||||||||||||||||||||||
| old_unit_id_to_channel_ids = self.sorting_analyzer.sparsity.unit_id_to_channel_ids | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Compute how to slice the original sparsity to get the newly selected sparsity | ||||||||||||||||||||||
| unit_sparsity_slices = {} | ||||||||||||||||||||||
| for unit_id in unit_ids: | ||||||||||||||||||||||
| channel_indices = [] | ||||||||||||||||||||||
| unit_channel_ids = old_unit_id_to_channel_ids[unit_id] | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| for channel_id in channel_ids: | ||||||||||||||||||||||
| if channel_id in unit_channel_ids: | ||||||||||||||||||||||
| idx = np.where(old_unit_id_to_channel_ids[unit_id] == channel_id)[0][0] | ||||||||||||||||||||||
| channel_indices.append(idx) | ||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I think that this does the exact same thing, right?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need the old
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
See:
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oop - we're both wrong. The I've updated the variables names, which I think should help avoid confusion. |
||||||||||||||||||||||
| unit_sparsity_slices[unit_id] = np.array(channel_indices) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| old_waveforms = self.data["waveforms"] | ||||||||||||||||||||||
| random_spikes = self.sorting_analyzer.get_extension("random_spikes").get_random_spikes() | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| new_waveforms = np.zeros_like(old_waveforms) | ||||||||||||||||||||||
| max_num_active_channels = 0 | ||||||||||||||||||||||
| for waveform_index, (waveform, unit_index) in enumerate(zip(old_waveforms, random_spikes["unit_index"])): | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| unit_id = unit_ids[unit_index] | ||||||||||||||||||||||
| channel_slice = unit_sparsity_slices[unit_id] | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if len(channel_slice) > 0: | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| size_of_new_mask = len(channel_slice) | ||||||||||||||||||||||
| new_waveforms[waveform_index, :, :size_of_new_mask] = waveform[:, channel_slice] | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| max_num_active_channels = max(max_num_active_channels, size_of_new_mask) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| data = {"waveforms": new_waveforms[:, :, :max_num_active_channels]} | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| return data | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| def _merge_extension_data( | ||||||||||||||||||||||
| self, merge_unit_groups, new_unit_ids, new_sorting_analyzer, keep_mask=None, verbose=False, **job_kwargs | ||||||||||||||||||||||
| ): | ||||||||||||||||||||||
|
|
@@ -562,7 +600,7 @@ def _select_units_extension_data(self, unit_ids): | |||||||||||||||||||||
| return new_data | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| def _select_channels_extension_data(self, channel_ids): | ||||||||||||||||||||||
| keep_channel_indices = np.flatnonzero(np.isin(self.sorting_analyzer.channel_ids, channel_ids)) | ||||||||||||||||||||||
| keep_channel_indices = [np.where(self.sorting_analyzer.channel_ids == id)[0][0] for id in channel_ids] | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| new_data = {} | ||||||||||||||||||||||
| for key, arr in self.data.items(): | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.