Skip to content

Instantly share code, notes, and snippets.

@endolith
Last active November 5, 2019 02:48
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 endolith/cc56717c841701836ed5579b279516aa to your computer and use it in GitHub Desktop.
Save endolith/cc56717c841701836ed5579b279516aa to your computer and use it in GitHub Desktop.
Heartbeat waveform plotter for SpO2 Assistant

This script plots the waveform CSV files saved by SpO2 Assistant software.

I have the HUGECARE CMS 50D+ Blue Finger Pulse Oximeter and SpO2 Assistant Version 3.0.4

When powered on and connected to the computer software and recording, it creates filenames with names like:

  • _20191016235323.txt - Patient information
  • _20191016235323.SpO2 - binary format
  • _20191016235323.csv - SpO2 and pulse rate over time
  • _20191016235323_wave.csv - Raw waveform data

You want the last *_wave.csv file. This script plots the raw waveform file as a 6-row plot of 15 seconds each, so 2.5 minutes total.

from pandas import read_csv
import matplotlib.pyplot as plt
import numpy as np
filename = '20181113000029_wave.csv'
offset = 0 # In samples, the point at which you want the plotting to start
data = read_csv(filename)
data = data[offset:]
fs = 60 # samples per second
fig, axs = plt.subplots(10, 1, figsize=(11, 7), sharex=True)
chunk_len = 15 # seconds
chunk_size = chunk_len * fs
for n, ax in enumerate(axs):
chunk = data[chunk_size*n:chunk_size*n+chunk_size]
try:
ax.plot(np.linspace(0, chunk_len, chunk_size), chunk['Wave'])
ax.margins(0, 0.1)
ax.tick_params(labelleft=False)
except ValueError:
pass
plt.xlabel('seconds')
#plt.tight_layout()
plt.subplots_adjust(0.01, 0.07, 1-0.01, 1-0.05)
plt.savefig(filename[:-4] + '.png')
@endolith
Copy link
Author

endolith commented Nov 5, 2019

Example output: 6 rows of heartbeat waveform plots, showing skipped beats with red dots (red dots were added afterward)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment