-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c9788c9
commit ab77daa
Showing
2 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\n", | ||
"import serial\n", | ||
"from time import time, sleep" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"ser = serial.Serial('/dev/ttyUSB0',9600)\n", | ||
"print(ser.name) \n", | ||
"\n", | ||
"# Read from serial moniter\n", | ||
"line = ser.read_until('e')\n", | ||
"\n", | ||
"# Delete ecg_signal.txt file if it's already present.\n", | ||
"cwd = os.getcwd()\n", | ||
"check = cwd + \"/ecg_signal.txt\"\n", | ||
"\n", | ||
"files = sorted(glob.glob(cwd + '/*.csv'), key=numericalSort)\n", | ||
"if check in files:\n", | ||
" os.remove(check)\n", | ||
"\n", | ||
"# Write the data to a file\n", | ||
"f = open('ecg_signal.txt', 'a')\n", | ||
"f.write(str(line)[10:])\n", | ||
"f.close()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Convert .txt file into .mat file for prediction\n", | ||
"a = np.loadtxt('ecg_signal.txt', dtype = 'object')\n", | ||
"a1 = a[100:9100]\n", | ||
"a1 = np.asarray(a1, dtype = 'float64')\n", | ||
"a1 = a1.reshape(1,-1)\n", | ||
"scipy.io.savemat('ecg_signal.mat', {'val': a1})" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"scrolled": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"!python ecg/ecg/predict.py val.json 0.434-0.864-012-0.309-0.892.hdf5" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.6.5" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"ecg": "/home/manideep/ecg_signal.mat", "labels": ["O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O"]} |