Skip to content

Commit d7a7cbb

Browse files
committed
fix examples
1 parent 33bcfc7 commit d7a7cbb

File tree

2 files changed

+42
-34
lines changed

2 files changed

+42
-34
lines changed

README.rst

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -735,26 +735,6 @@ See code comments for details about the algorithm.
735735

736736
correct_peaks(x, peak_indices, min_gap, max_gap, smooth_window)
737737

738-
Example Usage:
739-
740-
::
741-
742-
import wfdb
743-
t0 = 10000
744-
tf = 20000
745-
sig, fields = wfdb.srdsamp('sampledata/100', sampfrom=t0, sampto=tf, channels=[0])
746-
record = wfdb.rdsamp("sampledata/100", sampfrom=t0, sampto=tf, channels=[0], physical=False)
747-
peak_indices = wfdb.processing.gqrs_detect(x=sig[:,0], frequency=fields['fs'],
748-
adcgain=record.adcgain[0], adczero=record.adczero[0],
749-
threshold=1.0)
750-
fs = fields['fs']
751-
min_bpm = 10
752-
max_bpm = 350
753-
min_gap = fs*60/min_bpm
754-
max_gap = fs*60/max_bpm
755-
new_indices = wfdb.processing.correct_peaks(x=sig[:,0], peak_indices=peak_indices,
756-
min_gap=min_gap, max_gap=max_gap, smooth_window=150)
757-
758738
Input arguments:
759739

760740
- ``x`` (required): The signal.
@@ -768,6 +748,28 @@ Output Arguments:
768748
- ``new_indices``: A python list containing the new peaks indices.
769749

770750

751+
Example Usage:
752+
753+
::
754+
755+
import wfdb
756+
t0 = 10000
757+
tf = 20000
758+
record = wfdb.rdsamp('sampledata/100', sampfrom=t0, sampto=tf, channels=[0])
759+
d_signal = record.adc()[:,0]
760+
peak_indices = wfdb.processing.gqrs_detect(d_signal, fs=record.fs,
761+
adcgain=record.adcgain[0],
762+
adczero=record.adczero[0],
763+
threshold=1.0)
764+
min_bpm = 10
765+
max_bpm = 350
766+
min_gap = record.fs*60/min_bpm
767+
max_gap = record.fs*60/max_bpm
768+
new_indices = wfdb.processing.correct_peaks(d_signal, peak_indices=peak_indices,
769+
min_gap=min_gap, max_gap=max_gap,
770+
smooth_window=150)
771+
772+
771773
Heart Rate
772774
~~~~~~~~~~~~~~
773775

@@ -777,18 +779,6 @@ Heart Rate
777779

778780
compute_hr(siglen, peak_indices, fs)
779781

780-
Example Usage:
781-
782-
::
783-
784-
import wfdb
785-
t0 = 10000
786-
tf = 20000
787-
sig, fields = wfdb.srdsamp('sampledata/100', sampfrom=t0, sampto=tf, channels=[0])
788-
record = wfdb.rdsamp("sampledata/100", sampfrom=t0, sampto=tf, channels=[0], physical=False)
789-
peak_indices = wfdb.processing.gqrs_detect(x=sig[:,0], frequency=fields['fs'], adcgain=record.adcgain[0], adczero=record.adczero[0], threshold=1.0)
790-
hr = compute_hr(siglen=tf-t0, peak_indices=peak_indices, fs=fields['fs'])
791-
792782
Input arguments:
793783

794784
- ``siglen`` (required): The length of the corresponding signal.
@@ -801,6 +791,22 @@ Output Arguments:
801791
- ``hr``: A numpy array of the instantaneous heart rate, with the length of the corresponding signal. Contains numpy.nan where heart rate could not be computed.
802792

803793

794+
Example Usage:
795+
796+
::
797+
798+
import wfdb
799+
t0 = 10000
800+
tf = 20000
801+
record = wfdb.rdsamp("sampledata/100", sampfrom=t0, sampto=tf, channels=[0])
802+
peak_indices = wfdb.processing.gqrs_detect(record.adc(), fs=record.fs,
803+
adcgain=record.adcgain[0],
804+
adczero=record.adczero[0],
805+
threshold=1.0)
806+
hr = wfdb.processing.compute_hr(siglen=tf-t0, peak_indices=peak_indices, fs=record.fs)
807+
808+
809+
804810

805811
Based on the original WFDB software package specifications
806812
----------------------------------------------------------

demo.ipynb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,9 @@
445445
{
446446
"cell_type": "code",
447447
"execution_count": null,
448-
"metadata": {},
448+
"metadata": {
449+
"collapsed": true
450+
},
449451
"outputs": [],
450452
"source": [
451453
"def peaks_hr(x, peak_indices, fs, title, figsize=(20, 10), saveto=None):\n",
@@ -488,7 +490,7 @@
488490
" print('gqrs detected peak indices:', peak_indices)\n",
489491
" peaks_hr(x=record.p_signals, peak_indices=peak_indices, fs=record.fs, title=\"GQRS peak detection on sampledata/100\")\n",
490492
" \n",
491-
" # Do peak detection with constraints\n",
493+
" # Correct the peaks by applying constraints\n",
492494
" min_bpm = 20\n",
493495
" max_bpm = 230\n",
494496
" min_gap = record.fs*60/min_bpm\n",

0 commit comments

Comments
 (0)