Skip to content

Instantly share code, notes, and snippets.

@pbnsilva
Created April 12, 2020 17:09
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/516f5c4eb0ff9ee995cdf12c2df039c0 to your computer and use it in GitHub Desktop.
Save pbnsilva/516f5c4eb0ff9ee995cdf12c2df039c0 to your computer and use it in GitHub Desktop.
def zero_pad(data, length):
extended = np.zeros(length)
siglength = np.min([length, data.shape[0]])
extended[:siglength] = data[:siglength]
return extended
# plot a sample
data = sio.loadmat('training2017/A00001.mat')['val'][0]
# 61 seconds is the maximum length in our dataset
data = zero_pad(data, max_length*freq)
plt.figure(figsize=(15, 5))
plt.title('Sample zero-padded ECG recording', fontsize=30)
plt.xlabel('Time (s)', fontsize=25)
plt.ylabel('Potential (mV)', fontsize=25)
plt.plot(np.arange(0, data.shape[0])/300, data/1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment