Exemple #1
0
client=TwilioRestClient(accsid,token)
arddata=serial.Serial('/dev/ttyACM0',19200)
while (1==1):
    if(arddata.inWaiting()>0):
        data=arddata.readline()
        if(data[0]=='e'):
            data = data[1:len(data)]
            f=open("ecg.csv", "rw+")
            f.write(str(data)+"\n")
            #print ("ECG value "+data)
        else if(data[0]=='t'):
            #print("Temperature value: "+data)
            temp=int(data)
            f.close()
            dataset = hb.get_data("ecg.csv")
            hb.process(dataset, 0.75, 100)
            bpm = hb.measures['bpm']
            if(temp>37 or bpm>120):
                if(temp>37):
                    message = client.messages.create(to="+919743451835", from_="9097265085",
                                                       body="The temperature is "+temp)
                else if(bpm>120):
                    message = client.messages.create(to="+919743451835", from_="9097265085",
                                                       body="The heart rate is "+bpm +"BPM")
                    
            break   #goto as another option

__author__ = 'mongolab'

SEED_DATA = [
    {
        k = k + 1

    print("The start of the experiment was at line %i." % (k))

    body = np.array(rawdata[k:])
    data = pd.DataFrame(body, columns=header)

fs = hb.get_samplerate_mstimer(
    [int(x) for x in data['unix_timestamp'].tolist()])

# print(np.floor(1000 / np.mean(diffs)) / 4)

voltages = np.array([intr(x) for x in data['heart_rate_voltage'].tolist()])
filtered = hb.butter_lowpass_filter(voltages,
                                    cutoff=np.floor(fs / 4),
                                    sample_rate=fs,
                                    order=3)
enhanced = hb.enhance_peaks(filtered, iterations=2)

measures = hb.process(
    enhanced,  # array-like
    fs,  # frequency
    report_time=True,  # print the time for processing
    calc_freq=True,  # calcuate frequency domain
    interp_clipping=False,  # implied peak is interpolated
    interp_threshold=940  # amp beyond which will be checked for clipping
)

# Visualize peaks for inspection
hb.plotter()
Exemple #3
0
# -*- coding: utf-8 -*-
"""
Created on Thu Mar 29 12:37:04 2018

@author: Shubham
"""

import heartbeat as hb
import sys

if __name__ == '__main__':
    hrdata = hb.get_data(sys.argv[1] + "/ecg.csv")
    measures = hb.process(hrdata, 100.0, windowsize=0.1, report_time=True)
    measures.pop('interp_rr_function')
    measures.pop('interp_rr_linspace')
    print(measures)
    plt = hb.plotter(title='')
    plt.grid(color='r', linestyle='-', linewidth=0.2)
    my_dpi = 96
    plt.savefig(sys.argv[1] + '/ecg.png', dpi=my_dpi * 10, bbox_inches='tight')
# plt.show()
Exemple #4
0
import heartbeat as hb
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

rfile = open("5-gamers/gamer1-ppg-2000-01-01.csv", 'r')
ppg = []
for i, line in enumerate(rfile):
    if i != 0:
        line = line.split(',')
        ppg.append(line[1].strip("\n"))

ppg = np.array([int(elem) for elem in ppg])

ppg = ppg[ppg >= 100]

plt.plot(ppg[1:1000])
plt.show()

measures = hb.process(ppg[300:1100], 100)

print(measures)

hb.plotter()
Exemple #5
0
import heartbeat as hb

data = hb.get_data('heartbeat/data.csv')
measures = hb.process(data, 100.0)

print measures['bpm']
Exemple #6
0
import heartbeat as hb

hrdata = hb.get_data('data2.csv', column_name='hr')
timerdata = hb.get_data('data2.csv', column_name='timer')

hb.process(hrdata, hb.get_samplerate_mstimer(timerdata))

#plot with different title
hb.plotter(title='Heart Beat Detection on Noisy Signal')