Diff of /classification.ipynb [000000] .. [693b90]

Switch to unified view

a b/classification.ipynb
1
{
2
 "cells": [
3
  {
4
   "cell_type": "code",
5
   "execution_count": 1,
6
   "metadata": {},
7
   "outputs": [],
8
   "source": [
9
    "import os\n",
10
    "import serial\n",
11
    "from time import time, sleep"
12
   ]
13
  },
14
  {
15
   "cell_type": "code",
16
   "execution_count": null,
17
   "metadata": {},
18
   "outputs": [],
19
   "source": [
20
    "ser = serial.Serial('/dev/ttyUSB0',9600)\n",
21
    "print(ser.name) \n",
22
    "\n",
23
    "# Read from serial moniter\n",
24
    "line = ser.read_until('e')\n",
25
    "\n",
26
    "# Delete ecg_signal.txt file if it's already present.\n",
27
    "cwd = os.getcwd()\n",
28
    "check = cwd + \"/ecg_signal.txt\"\n",
29
    "\n",
30
    "files = sorted(glob.glob(cwd + '/*.csv'), key=numericalSort)\n",
31
    "if check in files:\n",
32
    "    os.remove(check)\n",
33
    "\n",
34
    "# Write the data to a file\n",
35
    "f = open('ecg_signal.txt', 'a')\n",
36
    "f.write(str(line)[10:])\n",
37
    "f.close()"
38
   ]
39
  },
40
  {
41
   "cell_type": "code",
42
   "execution_count": null,
43
   "metadata": {},
44
   "outputs": [],
45
   "source": [
46
    "# Convert .txt file into .mat file for prediction\n",
47
    "a = np.loadtxt('ecg_signal.txt', dtype = 'object')\n",
48
    "a1 = a[100:9100]\n",
49
    "a1 = np.asarray(a1, dtype = 'float64')\n",
50
    "a1 = a1.reshape(1,-1)\n",
51
    "scipy.io.savemat('ecg_signal.mat', {'val': a1})"
52
   ]
53
  },
54
  {
55
   "cell_type": "code",
56
   "execution_count": null,
57
   "metadata": {
58
    "scrolled": true
59
   },
60
   "outputs": [],
61
   "source": [
62
    "!python ecg/ecg/predict.py val.json 0.434-0.864-012-0.309-0.892.hdf5"
63
   ]
64
  }
65
 ],
66
 "metadata": {
67
  "kernelspec": {
68
   "display_name": "Python 3",
69
   "language": "python",
70
   "name": "python3"
71
  },
72
  "language_info": {
73
   "codemirror_mode": {
74
    "name": "ipython",
75
    "version": 3
76
   },
77
   "file_extension": ".py",
78
   "mimetype": "text/x-python",
79
   "name": "python",
80
   "nbconvert_exporter": "python",
81
   "pygments_lexer": "ipython3",
82
   "version": "3.6.5"
83
  }
84
 },
85
 "nbformat": 4,
86
 "nbformat_minor": 2
87
}