Skip to content

Instantly share code, notes, and snippets.

@pbnsilva
Last active April 16, 2020 18:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pbnsilva/b5742f440ea013ed8a210a48fa0785b3 to your computer and use it in GitHub Desktop.
Save pbnsilva/b5742f440ea013ed8a210a48fa0785b3 to your computer and use it in GitHub Desktop.
import numpy as np
import scipy.io as sio
import matplotlib.pyplot as plt
# plot 10 seconds
secs = 10
# maximum length of ECG recording is 61 seconds
max_length = 61
# our data was recorded at 300Hz
freq = 300
files = [('N', 'A00001'),
('A', 'A00004'),
('O', 'A00038'),
('~', 'A00022')]
fig = plt.figure(figsize=(20,16))
for i, (cls, f) in enumerate(files):
data = sio.loadmat('training2017/'+f+'.mat')['val'][0]
ax = fig.add_subplot(2, 2, i+1)
ax.plot(np.arange(0, secs*freq)/300, data[:secs*freq]/1000)
ax.set_title('Class: ' + cls, fontsize=30)
ax.set(xlim=[0, secs], xticks=np.arange(0, 20, 1),
ylim=[-1, 2], yticks=np.arange(-0.5, 1.2, 0.5))
ax.tick_params(axis="x", labelsize=20)
ax.tick_params(axis="y", labelsize=20)
ax.set_xlabel('Time (s)', fontsize=25)
ax.set_ylabel('Potential (mV)', fontsize=25)
plt.tight_layout()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment