Skip to content

Commit

Permalink
upload
Browse files Browse the repository at this point in the history
  • Loading branch information
manideep2510 committed May 16, 2019
1 parent c9788c9 commit ab77daa
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
87 changes: 87 additions & 0 deletions classification.ipynb
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
}
1 change: 1 addition & 0 deletions val.json
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"]}

0 comments on commit ab77daa

Please sign in to comment.