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

Commit

Permalink
Merge branch 'pr/17'
Browse files Browse the repository at this point in the history
  • Loading branch information
capcarr committed May 2, 2017
2 parents e51fcd2 + 1709dad commit da02d97
Show file tree
Hide file tree
Showing 3 changed files with 64,906 additions and 6 deletions.
30 changes: 26 additions & 4 deletions biosppy/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,11 @@ def plot_eda(ts=None,


def plot_emg(ts=None,
sampling_rate=None,
raw=None,
filtered=None,
onsets=None,
processed=None,
path=None,
show=False):
"""Create a summary plot from the output of signals.emg.emg.
Expand All @@ -411,12 +413,16 @@ def plot_emg(ts=None,
----------
ts : array
Signal time axis reference (seconds).
sampling_rate : int, float
Sampling frequency (Hz).
raw : array
Raw EMG signal.
filtered : array
Filtered EMG signal.
onsets : array
Indices of EMG pulse onsets.
processed : array, optional
Processed EMG signal according to the chosen onset detector.
path : str, optional
If provided, the plot will be saved to the specified file.
show : bool, optional
Expand All @@ -427,18 +433,34 @@ def plot_emg(ts=None,
fig = plt.figure()
fig.suptitle('EMG Summary')

# raw signal
ax1 = fig.add_subplot(211)
if processed is not None:
ax1 = fig.add_subplot(311)
ax2 = fig.add_subplot(312, sharex=ax1)
ax3 = fig.add_subplot(313)

# processed signal
L = len(processed)
T = (L - 1) / sampling_rate
ts_processed = np.linspace(0, T, L, endpoint=False)
ax3.plot(ts_processed, processed,
linewidth=MAJOR_LW,
label='Processed')
ax3.set_xlabel('Time (s)')
ax3.set_ylabel('Amplitude')
ax3.legend()
ax3.grid()
else:
ax1 = fig.add_subplot(211)
ax2 = fig.add_subplot(212, sharex=ax1)

# raw signal
ax1.plot(ts, raw, linewidth=MAJOR_LW, label='Raw')

ax1.set_ylabel('Amplitude')
ax1.legend()
ax1.grid()

# filtered signal with onsets
ax2 = fig.add_subplot(212, sharex=ax1)

ymin = np.min(filtered)
ymax = np.max(filtered)
alpha = 0.1 * (ymax - ymin)
Expand Down
Loading

0 comments on commit da02d97

Please sign in to comment.