`BenchmarkStudy.create` reuses the main channels of another dataset

Open Beginner friendly
#4,990 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
88/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
data

Research direction

Start in benchmark/benchmark_base.py at BenchmarkStudy.create and trace how main_channel_indices is set before it is passed to create_sorting_analyzer. The issue provides a reproduction using SorterStudy.create with one dataset missing gt_unit_locations; first run that example and inspect the analyzer channel indices. Done when each dataset gets appropriate main channels and a regression test covers the missing-property case.

Written by the indexing model from the issue text.

Description

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

In BenchmarkStudy.create, main_channel_indices is only set when the ground truth sorting has the gt_unit_locations property, but it is always passed to create_sorting_analyzer (since #4734). A dataset without this property gets the main channels of the previous dataset, or an UnboundLocalError if it is the first one. The sparsity, templates and SNR are then wrong without an error.

import tempfile
from pathlib import Path
from spikeinterface.core import generate_ground_truth_recording
from spikeinterface.benchmark import SorterStudy

if __name__ == "__main__":
    datasets = {}
    for key, seed in (("a", 0), ("b", 5)):
        datasets[key] = generate_ground_truth_recording(num_channels=32, num_units=4, durations=[10.0], seed=seed)
    datasets["b"][1].delete_property("gt_unit_locations")
    cases = {key: {"label": key, "dataset": key, "params": {"sorter_name": "simple"}} for key in datasets}
    study = SorterStudy.create(Path(tempfile.mkdtemp()) / "study", datasets=datasets, cases=cases)
    print(study.analyzers["a"].main_channel_indices, study.analyzers["b"].main_channel_indices)

Both datasets get the same main channels. Fix: set main_channel_indices = None in the else branch, so that they are estimated. I have this locally with a test. Should I open a PR, or would you rather fix it yourselves?

Dominant language
Python
Stars
883
Forks
291
Avg merge
3d 17h
Merged PRs (30d)
40

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from SpikeInterface/spikeinterface

All issues in SpikeInterface/spikeinterface

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.