-
-
Notifications
You must be signed in to change notification settings - Fork 419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Fix] Return an empty array rather than throwing an exception if no QRS dat… #1007
[Fix] Return an empty array rather than throwing an exception if no QRS dat… #1007
Conversation
Thanks for opening this pull request! We'll make sure it's perfect before merging 🤗 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that you only put it on the neurokit method of the function i.e., |
@DerAndereJohannes @danibene I added tests for the other methods (at least checking that they don't crash when run on empty input). I made a couple of other fixes to ensure that most methods handle empty input. Two small things not addressed (But I wanted to record for posterity):
|
I think the failed test is related to visbilitygraph which has a numpy dependency issue (we don't require a specific numpy version, the scipy > 1.13 is pulling in numpy 2.0 which isn't compatible with ts2vg). I couldn't get it to run locally on my machine either (but figured it was worth a shot to see if it ran in CI). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making these changes! If you are unable to get the test working for the vgraph method, I think it is fine to merge without for now, as long as it is documented as a known issue.
I added a comment and refactored the test method to use the parameterized methods. |
@@ -23,6 +25,17 @@ def _read_csv_column(csv_name, column): | |||
csv_data = pd.read_csv(csv_path, header=None) | |||
return csv_data[column].to_numpy() | |||
|
|||
#vgraph is not included because it currently causes CI to fail (issue 1007) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#vgraph is not included because it currently causes CI to fail (issue 1007) | |
#vgraph is not included because it currently causes CI to fail (issue #1009) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
amazing, thanks all! |
Description
This PR aims fixes an error where running ecg_peakdetect on a signal without any QRS complexes would throw an exception rather than returning an empty array. There are a couple of issues (mostly closed due to inactivity) that relate to this: #580, #472, #134
Proposed Changes
I changed the
_ecg_findpeaks_neurokit()
function so that the length ofbeg_qrs
is checked before accessing the first element. If the array is empty then return an empty array rather than triggering a ValueException.Checklist
Here are some things to check before creating the PR. If you encounter any issues, do let us know :)