`plot_potential_merges` draws the correlograms of other units when a merge group is not sorted

未关闭 适合新手
#5,007 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
74/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
data

调研方向

从 widgets/potential_merges.py 开始,检查 _update_plot,issue 指出了其中的选择顺序和组下拉菜单处理。查看 plot_potential_merges 的现有测试,并添加对未排序组以及包含连字符的单元 ID 的覆盖。当每个自相关图都与其单元标题匹配,且拼接后的 ID 无需 ValueError 即可正常工作时,任务便完成。

由索引模型根据 Issue 内容生成。

描述

I found this while reading widgets/potential_merges.py, not in my own analyses, so this is a "for the sake of improvement" report.

In _update_plot, the correlograms are selected with np.isin(unique_merge_units, plot_unit_ids), which follows the sorted order of unique_merge_units, while the titles follow the order of the merge group. For the group ["3", "1"], the autocorrelogram of unit 1 is drawn under the title of unit 3 and the reverse, without an error. Also, the group is rebuilt with split("-"), so unit ids containing "-", such as those made by merge_units(new_id_strategy="join"), raise a ValueError.

import matplotlib

matplotlib.use("module://ipympl.backend_nbagg")
import numpy as np
from spikeinterface.core import generate_ground_truth_recording, create_sorting_analyzer
from spikeinterface.widgets import plot_potential_merges

recording, sorting = generate_ground_truth_recording(durations=[20.0], num_channels=16, num_units=5, seed=0)
analyzer = create_sorting_analyzer(sorting, recording, sparse=False, format="memory")
analyzer.compute(["random_spikes", "templates", "spike_amplitudes", "correlograms"], progress_bar=False)
ccgs, _ = analyzer.get_extension("correlograms").get_data()
unit_ids = list(analyzer.unit_ids)

w = plot_potential_merges(analyzer, [["3", "1"]], backend="ipywidgets", display=False)
for k in range(2):
    drawn = np.array([bar.get_height() for bar in w.axes_cc[k, k].patches])
    match = [str(u) for i, u in enumerate(unit_ids) if np.array_equal(drawn, ccgs[i, i])]
    print("panel", w.axes_cc[0, k].get_title(), "shows the autocorrelogram of unit", match)
# panel 3 shows the autocorrelogram of unit ['1']  expected ['3']
# panel 1 shows the autocorrelogram of unit ['3']  expected ['1']

merged = analyzer.merge_units([["0", "1"]], new_id_strategy="join")
plot_potential_merges(merged, [["0-1", "2"]], backend="ipywidgets", display=False)
# ValueError: '0' is not in list

Fix: select the correlograms with the index of each unit of the group, in the group order, and keep the groups themselves for the dropdown instead of joined strings.

I can open a PR with a test if you agree.

主要语言
Python
星标
883
派生
291
平均合并
3 天 17 小时
30 天内合并 PR
40

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

SpikeInterface/spikeinterface 的其他 Issue

查看 SpikeInterface/spikeinterface 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。