Skip to content

Fix V1 (spike-detection-only) burst analysis: load spike_times.npy when sorting is unavailable#170

Draft
mandarmp with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-burst-analysis-spike-time-issue
Draft

Fix V1 (spike-detection-only) burst analysis: load spike_times.npy when sorting is unavailable#170
mandarmp with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-burst-analysis-spike-time-issue

Conversation

Copilot AI commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

When running in spike-detection-only mode (skip_spikesorting=True), burst analysis always failed with "No spike times found" despite spikes being detected and saved to disk.

Root cause

_spike_detection_only() saves spike times to spike_times.npy but never sets self.sorting. _run_burst_analysis() gated all spike time loading behind if self.sorting:, so the else branch immediately returned an error — the saved file was never consulted.

A secondary issue: the function body was indented at 12 spaces instead of 8, and the except block was at a mismatched level, causing an IndentationError that made the entire module unparseable.

Changes

  • Fix indentation — corrected _run_burst_analysis body to 8-space indent; try/except now properly paired at the same level
  • Load spike_times.npy when self.sorting is None — the else branch now loads from the file written by _spike_detection_only, filters by ids_list if provided, and emits distinct error messages for each failure mode (file missing / file empty / empty after filtering):
else:
    spike_times_file = self.output_dir / "spike_times.npy"
    if spike_times_file.exists():
        spike_times = np.load(spike_times_file, allow_pickle=True).item()
        if not spike_times:
            self.logger.error("No spike times found in saved spike_times.npy file.")
            return
        if ids_list is not None:
            spike_times = {uid: spike_times[uid] for uid in ids_list if uid in spike_times}
        if not spike_times:
            self.logger.error("No spike times found for burst analysis after filtering by ids_list.")
            return
    else:
        self.logger.error("No spike times found for burst analysis.")
        return

Copilot AI and others added 2 commits April 28, 2026 06:52
…entation and load spike_times.npy when self.sorting is None

Agent-Logs-Url: https://github.com/roybens/MEA_Analysis/sessions/c62d626f-541c-4707-b60b-95aa7c72cc78

Co-authored-by: mandarmp <33731455+mandarmp@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix burst analysis failing with no spike times found Fix V1 (spike-detection-only) burst analysis: load spike_times.npy when sorting is unavailable Apr 28, 2026
Copilot AI requested a review from mandarmp April 28, 2026 06:54
@mandarmp mandarmp force-pushed the copilot/fix-burst-analysis-spike-time-issue branch from e8da8c9 to f19b58c Compare April 28, 2026 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

V1 analysis failing with no spiketimes found for burst analysis despite spike

2 participants