Skip to content

Add support for selecting R-peak segmenter in ecg() via string parameter#61

Merged
sofia3ms merged 2 commits intoscientisst:mainfrom
DWelloo:choose-r-detection-in-ecg
Jun 26, 2025
Merged

Add support for selecting R-peak segmenter in ecg() via string parameter#61
sofia3ms merged 2 commits intoscientisst:mainfrom
DWelloo:choose-r-detection-in-ecg

Conversation

@DWelloo
Copy link

@DWelloo DWelloo commented Jun 3, 2025

This PR introduces support for selecting the signal segmentation algorithm used in ecg() via a string parameter segmenter. Users can now specify algorithms like "hamilton", "ASI", "engzee", etc.
Additionally, segmenter-specific parameters (e.g. "threshold", "before", "tol") can be passed via **kwargs. A whitelist (ALLOWED_KWARGS) ensures only allowed keys are accepted. Invalid arguments raise an exception to prevent accidental or malicious misuse.
The logic is handled by a helper function call_segmenter() which performs argument filtering using Python’s inspect module.
Fallback to default (hamilton_segmenter) is provided if an unknown segmenter name is passed.

…s segmenter-specific parameters (such as 'Pth' in ASI_segmenter) through **kwargs. Created if-check to ensure only viable kwargs are allowed and a helper function 'call_segmenter' to control which kwargs are passed to the segmenter. In case of invalid segmenter name, default (hamilton) will be used.
@sofia3ms sofia3ms self-assigned this Jun 26, 2025
Copy link
Collaborator

@sofia3ms sofia3ms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dear @DWelloo ,

Amazing, a great new feature! Thank you for your contribution 😊

@sofia3ms sofia3ms merged commit b09ca33 into scientisst:main Jun 26, 2025
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.

2 participants