Align tools with Biosiglib v0.5.5 specs - #43
Merged
Conversation
… NaN handling in filtering functions and tests
… NaN handling in filtering functions and tests # Conflicts: # conformance.json
Contributor
There was a problem hiding this comment.
Pull request overview
Aligns Biosigmat’s MATLAB tool implementations and test coverage with Biosiglib v0.5.4 conformance cases, including updated NaN-segmentation behavior for nanfilter/nanfiltfilt, stricter finiteness requirements for snaptopeak, and segment-wise peak refinement in pantompkins. Also marks the corresponding tool specs as conformant in conformance.json.
Changes:
- Adds Biosiglib conformance-case driven tests for
medfiltThreshold,nanfilter,nanfiltfilt,lpdfilter, andsnaptopeak(including expected-error case coverage where applicable). - Refines NaN-handling by preserving boundary/long NaN gaps, interpolating only short internal gaps, and leaving too-short candidate segments as NaN for filtering operations.
- Updates
pantompkinsto refine peaks only within finite ECG segments and updates the conformance manifest to declare the five tool specs conformant.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/tools/snaptopeakTest.m | Adds Biosiglib conformance and expected-error parameterized coverage; improves path setup to use repo root. |
| test/tools/nanfiltfiltTest.m | Adds parameterized Biosiglib conformance-case coverage via shared base helper. |
| test/tools/nanfilterTest.m | Adds parameterized Biosiglib conformance-case coverage via shared base helper. |
| test/tools/medfiltThresholdTest.m | Adds Biosiglib conformance + expected-error coverage and makes fixtures/path handling repo-root based. |
| test/tools/lpdfilterTest.m | Adds Biosiglib conformance + expected-error coverage and makes fixtures/path handling repo-root based. |
| test/common/verifyBiosiglibExpectedOutputs.m | Makes expected-outputs verification robust to expected_outputs being a cell array vs struct array. |
| test/common/NanFilterTestBase.m | Adds a shared helper to run Biosiglib NaN-filtering conformance cases; updates path handling. |
| src/tools/snaptopeak.m | Tightens input validation to require finite ECG/detections and vector-shaped detections. |
| src/tools/private/processNanSignal.m | Updates core NaN-segmentation/interpolation logic and adds minimum-segment-length gating for filtering. |
| src/tools/nanfiltfilt.m | Uses the updated NaN processing with a filtfilt-specific minimum segment length. |
| src/tools/nanfilter.m | Uses the updated NaN processing with a filter-specific minimum segment length. |
| src/tools/medfiltThreshold.m | Tightens input validation (window >= 2, finite scalar params; reject Inf in x while allowing NaN). |
| src/ecg/pantompkins.m | Refines peaks only within finite ECG segments to avoid snapping across NaN/Inf gaps. |
| conformance.json | Declares the five tool specs conformant and maps them to MATLAB entry points. |
| caseDefinition, 'sampling_frequency'); | ||
| stopFrequency = loadBiosiglibConformanceInput( ... | ||
| caseDefinition, 'stop_frequency'); | ||
| parameters = caseDefinition.parameters; |
| function testBiosiglibConformanceCase(tc, validConformanceCaseId) | ||
| caseDefinition = loadBiosiglibConformanceCase(validConformanceCaseId); | ||
| x = loadBiosiglibConformanceInput(caseDefinition, 'x'); | ||
| parameters = caseDefinition.parameters; |
dcajal
force-pushed
the
agent/align-tools-v051
branch
from
July 8, 2026 13:20
8fe5bc0 to
a78af6b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
9844bd742d6c375f472dceb16adaae97e700509b). As of this update,origin/mainstill points to Biosiglib v0.5.4, so the postrelease propagation has not landed onmainyet.snaptopeakbehavior: NaN ECG gaps are hard finite-segment boundaries, NaN detections keep output alignment as NaN, detections on NaN ECG samples return NaN, and Inf/-Inf remain invalid.pantompkinsback to delegating segment refinement tosnaptopeak.snaptopeakconformance coverage for the new Biosiglib cases.Conformance Cases
tools.snap_to_peak.ecg_nan_segment_boundarytools.snap_to_peak.detection_nan_returns_nantools.snap_to_peak.detection_on_nan_ecg_returns_nanValidation
matlab -batch "addpath('scripts/local'); runTests('tools/snaptopeak'); runTests('ecg/pantompkins')"matlab -batch "addpath('scripts/local'); runTests('tools/medfiltThreshold'); runTests('tools/nanfilter'); runTests('tools/nanfiltfilt'); runTests('tools/lpdfilter'); runTests('tools/snaptopeak')"matlab -batch "addpath('scripts/local'); runTests"(188/188 passed).venv\Scripts\python.exe tools\validate_specs.py --manifest C:\Users\cajal\dev\biosig\biosigmat\conformance.jsongit diff --check