|
a |
|
b/README.md |
|
|
1 |
# OMNI (Open Source Monitoring of Neonates and Infants) |
|
|
2 |
|
|
|
3 |
<p align="center"> |
|
|
4 |
<image src = 'images/omni-logo.png' > |
|
|
5 |
</p> |
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
## Software Requirements |
|
|
10 |
Run `sh requirements.sh` in a virtual environment in order to download the required libraries. |
|
|
11 |
|
|
|
12 |
## Hardware Requirements (Edge implementation) |
|
|
13 |
|
|
|
14 |
 |
|
|
15 |
### Components needed: |
|
|
16 |
|
|
|
17 |
1. [OpenBCI Ganglion kit](https://shop.openbci.com/products/ganglion-board?variant=13461804483) |
|
|
18 |
|
|
|
19 |
Open source biosignal acquisition hardware for [research grade biosignal acquisition](https://openbci.com/community/published-research-with-openbci/) |
|
|
20 |
|
|
|
21 |
2. [Raspberry Pi 4](https://www.raspberrypi.org/products/raspberry-pi-4-model-b/) |
|
|
22 |
3. [Rasberry Pi 4 cooling case](https://www.newegg.com/p/1W8-00Y1-00032) |
|
|
23 |
4. Shirt using [conductive textile electrodes](https://www.alibaba.com/product-detail/Conductive-textile-ecg-Electrodes_1127697682.html) [1$ for 1 electrode] |
|
|
24 |
|
|
|
25 |
|
|
|
26 |
Wearable ECG electrodes --> OpenBCI Ganglion ---(Bluetooth)---> Raspberry Pi 4 |
|
|
27 |
|
|
|
28 |
## System Configuration |
|
|
29 |
* Ubuntu 16.04 |
|
|
30 |
* Nvidia 1080Ti - (Required for training the model) |
|
|
31 |
|
|
|
32 |
## Train a model to extract R peaks and Heart Rate from ECG waveform. |
|
|
33 |
* Download ECG MITDB monitoring data from https://storage.googleapis.com/mitdb-1.0.0.physionet.org/mit-bih-arrhythmia-database-1.0.0.zip and unzip it. |
|
|
34 |
* To train: `python train.py --preprocess_data --data_path "PATH TO DATA"` |
|
|
35 |
|
|
|
36 |
## Train a model to extract Breathing Rate from ECG waveform. |
|
|
37 |
* Download ECG from the BIDMC database which is derived from MIMIC-II from https://physionet.org/static/published-projects/bidmc/bidmc-ppg-and-respiration-dataset-1.0.0.zip and unzip it. |
|
|
38 |
* To train: `python train.py --preprocess_data --data_path "PATH TO DATA"` |
|
|
39 |
|
|
|
40 |
## Model Inference |
|
|
41 |
* Download ECG from the preterm infant database from https://physionet.org/static/published-projects/picsdb/preterm-infant-cardio-respiratory-signals-database-1.0.0.zip and unzip it. |
|
|
42 |
* Download the Heart Rate computation model from here: https://drive.google.com/open?id=1yI7G4nofjuzFWkD1CfsOtLZxaukTu0di |
|
|
43 |
* Download the Breathing Rate computation model from here: https://drive.google.com/open?id=1ycV74LfGmgcGmLlrPn2VileeFNsGrRZT |
|
|
44 |
* To run inference and view GUI type: `python run_model.py --path_dir "PATH TO DATA" --saved_hr_model_path "PATH TO HR MODEL" --saved_br_model_path "PATH TO BR MODEL" --patient_no 3 --viewer 1` |
|
|
45 |
|
|
|
46 |
# OMNI OpenBCI Pi Inference |
|
|
47 |
|
|
|
48 |
Edge inference of ECG R-peak detection and Respiration extraction using Raspberry Pi 4 using ECG (OpenBCI Ganglion). |
|
|
49 |
|
|
|
50 |
|
|
|
51 |
## Hardware Design |
|
|
52 |
|
|
|
53 |
Wearable ECG electrodes --> OpenBCI Ganglion ---(Bluetooth)---> Raspberry Pi 4 |
|
|
54 |
|
|
|
55 |
## Software Design |
|
|
56 |
|
|
|
57 |
OpenBCI client ----(LSL)---> Python -> PyTorch inference --> Breathing Rate, Heart Rate |
|
|
58 |
|
|
|
59 |
|
|
|
60 |
## Installation instruction |
|
|
61 |
|
|
|
62 |
### Install PyTorch on Raspberry Pi 4: |
|
|
63 |
|
|
|
64 |
1. Install PyTorch dependicies |
|
|
65 |
`sudo apt install libopenblas-dev libblas-dev m4 cmake cython python3-yaml libatlas-base-dev` |
|
|
66 |
2. Increase swap file memory to 1600, Edit variable `CONF_SWAPSIZE` in `/etc/dphys-swapfile` |
|
|
67 |
3. Reset environmental variables like ONNX_ML [Instructions](https://gist.github.com/akaanirban/621e63237e63bb169126b537d7a1d979) |
|
|
68 |
4. Download PyTorch package compiled for Armv7 ([torch-1.1.0-cp37-cp37m-linux_armv7l.whl](https://github.com/marcusvlc/pytorch-on-rpi/blob/master/torch-1.1.0-cp37-cp37m-linux_armv7l.whl)) |
|
|
69 |
5. Install using the command `sudo pip3 install torch-1.1.0-cp37-cp37m-linux_armv7l.whl` in the same directory |
|
|
70 |
|
|
|
71 |
Refer [here](https://github.com/marcusvlc/pytorch-on-rpi) for troubleshooting |
|
|
72 |
|
|
|
73 |
### Install OpenBCI Ganglion client on Raspberry Pi 4: |
|
|
74 |
|
|
|
75 |
1. Clone OpenBCI_Python repo |
|
|
76 |
`git clone htps://github.com/OpenBCI/OpenBCI_Python.git` |
|
|
77 |
2. Install the following requisites python packages using `pip3 install` |
|
|
78 |
pylsl, python-osc, six, socketIO-client, websocket-client, Yapsy, xmldict, bluepy |
|
|
79 |
3. Open folder OpenBCI_Python and run |
|
|
80 |
`sudo python3 user.py --board ganglion -a streamer_lsl` to open a lab streaming layer stream of sensor data from the ganglion |
|
|
81 |
|
|
|
82 |
## Instructions to run to perform real time breathing rate/ heart rate inference using OpenBCI data |
|
|
83 |
1. Run the lsl streamer script to get data to the inference script |
|
|
84 |
`sudo python3 user.py --board ganglion -a streamer_lsl` |
|
|
85 |
3. Run the visualization and edge inference code on the pi using `python3 lsl_openbci.py` |
|
|
86 |
|
|
|
87 |
|
|
|
88 |
## Sample Predictions |
|
|
89 |
 |
|
|
90 |
|
|
|
91 |
 |
|
|
92 |
Above is an example prediction for noisy real time ECG data obtained using the edge inference model. The beat predictions are represented as blue markers on the ECG. |