Skip to content

Fix single-interval ConsolidateIntervals indexing - #31

Merged
ryanharvey1 merged 1 commit into
masterfrom
codex/fix-single-interval-consolidation
Sep 30, 2026
Merged

ryanharvey1 merged 1 commit into
masterfrom
codex/fix-single-interval-consolidation

Conversation

@ryanharvey1

Copy link
Copy Markdown
Member

A single 1-by-2 interval makes length(intervals) return 2, so ConsolidateIntervals attempts to access done(2) even though there is only one interval. This causes CleanLFP and callers such as auto_theta_cycles to fail when exactly one artefact is detected.

Use size(intervals,1) in both consolidation loops to iterate over interval rows. Add eight regression tests covering single row and column intervals, strict mode, empty input, overlap consolidation and target mapping, touching bounds, and CleanLFP with one amplitude artefact, one derivative artefact, or no artefacts.

Validation: reproduced the original indexing error before the fix; all eight tests pass after the fix in MATLAB R2025a.

results = runtests('test/test_ConsolidateIntervals.m');
assertSuccess(results);

@ryanharvey1
ryanharvey1 merged commit 6e15f43 into master Sep 30, 2026
1 check passed
@ryanharvey1
ryanharvey1 deleted the codex/fix-single-interval-consolidation branch September 30, 2026 20:08
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.

1 participant