Skip to content

Commit

Permalink
Merge pull request #1011 from ajb5d/fix-findpeaks_neurokit_index_error
Browse files Browse the repository at this point in the history
[Fix] findpeaks neurokit index error
  • Loading branch information
DominiqueMakowski authored Jul 19, 2024
2 parents c37621e + d38318f commit bc3f4f1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions neurokit2/ecg/ecg_findpeaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1245,6 +1245,10 @@ def _ecg_findpeaks_visibilitygraph(
weights = np.zeros(N) # Empty array to store the weights
BETA = 0.55 # Target number of nonzero elements in the resulting weight vector

# if the input signal is flat, return an empty array, otherwise the visiblity graph will fail
if np.max(signal) == np.min(signal):
return np.array([])

# If input length is smaller than window, compute only one segment of this length
if N < M:
M, R = N, N
Expand Down
4 changes: 2 additions & 2 deletions tests/tests_ecg_findpeaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ 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)

@pytest.mark.parametrize("method",["neurokit", "pantompkins", "nabian", "gamboa",
"slopesumfunction", "wqrs", "hamilton", "christov",
"engzee", "manikandan", "elgendi", "kalidas",
"martinez", "rodrigues",])
"martinez", "rodrigues", "vgraph"])
def test_ecg_findpeaks_all_methods_handle_empty_input(method):
method_func = _ecg_findpeaks_findmethod(method)
# The test here is implicit: no exceptions means that it passed,
Expand Down

0 comments on commit bc3f4f1

Please sign in to comment.