Skip to content
This repository was archived by the owner on Aug 2, 2022. It is now read-only.

Commit 8ed06fb

Browse files
committed
modified emg.py to include 7 more onset detectors, included a new emg signal example with more activations and rest sequences, modified plotting.py to also plot the processed emg signal
1 parent b4c9f50 commit 8ed06fb

File tree

3 files changed

+64829
-7
lines changed

3 files changed

+64829
-7
lines changed

biosppy/plotting.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,10 @@ def plot_eda(ts=None,
400400

401401

402402
def plot_emg(ts=None,
403+
sampling_rate=None,
403404
raw=None,
404405
filtered=None,
406+
processed=None,
405407
onsets=None,
406408
path=None,
407409
show=False):
@@ -411,10 +413,14 @@ def plot_emg(ts=None,
411413
----------
412414
ts : array
413415
Signal time axis reference (seconds).
416+
sampling_rate : int, float
417+
Sampling frequency (Hz).
414418
raw : array
415419
Raw EMG signal.
416420
filtered : array
417421
Filtered EMG signal.
422+
processed : array
423+
Processed EMG signal according to the chosen onset detector.
418424
onsets : array
419425
Indices of EMG pulse onsets.
420426
path : str, optional
@@ -428,7 +434,7 @@ def plot_emg(ts=None,
428434
fig.suptitle('EMG Summary')
429435

430436
# raw signal
431-
ax1 = fig.add_subplot(211)
437+
ax1 = fig.add_subplot(311)
432438

433439
ax1.plot(ts, raw, linewidth=MAJOR_LW, label='Raw')
434440

@@ -437,7 +443,7 @@ def plot_emg(ts=None,
437443
ax1.grid()
438444

439445
# filtered signal with onsets
440-
ax2 = fig.add_subplot(212, sharex=ax1)
446+
ax2 = fig.add_subplot(312, sharex=ax1)
441447

442448
ymin = np.min(filtered)
443449
ymax = np.max(filtered)
@@ -456,6 +462,14 @@ def plot_emg(ts=None,
456462
ax2.legend()
457463
ax2.grid()
458464

465+
# processed signal
466+
ax3 = fig.add_subplot(313)
467+
ax3.plot(np.arange(len(processed))/sampling_rate, processed, linewidth=MAJOR_LW, label='Processed')
468+
ax3.set_xlabel('Time (s)')
469+
ax3.set_ylabel('Amplitude')
470+
ax3.legend()
471+
ax3.grid()
472+
459473
# make layout tight
460474
fig.tight_layout()
461475

0 commit comments

Comments
 (0)