Fabrication of a low-cost ECG pathology detection device

Fabrication of a low-cost ECG pathology detection device
Post Date:2022-09-19,STMicroelectronics

Fabrication of a low-cost ECG pathology detection device

Our goal is to bring proper heart care to humans. Early detection of these lesions is critical for effective treatment

solution

To solve this problem, we are building a small portable device based on low-cost components. The device will contain a motherboard with processing power (like the STM32F407G-DISC1), electronics to read the ECG signal and a small screen to display the analysis results.

Currently, real ECG equipment is heavy and expensive. These devices are designed to be highly reliable and have clear signals. Since our device is designed for preliminary diagnosis and the data will be analyzed by software, the data does not require all the detail and signal cleanliness that the human body needs. Lower the level of detail and filtering, and the device becomes lightweight, cheap, and practical.

Due to its low power consumption, this will allow it to be easily transported to remote lands and powered using batteries or even renewable energy (solar, wind).

how to work

The device has wires that connect to the patient's body. This led to the measurement of in vivo voltage changes related to heart behavior. The signal we receive is amplified and measured by the analog-to-digital converter of the STM32F407G-DISC1.

The data is then processed by a microcontroller with the main processing power of the project. The microcontroller will have a neural network, previously trained with a massive dataset, that will analyze and classify heart signals and try to detect possible lesions.

We plan to visualize the received data plus the output of the neural network in order to inform the patient/physician of the analysis results.

first part

The first part is designed to acquire and amplify the ECG's signal so that a microcontroller can read it. Once the data has been digitized, the microcontroller will send it to the Raspberry Pi 3, where the neural network will extract parameters and generate results.

An electrocardiogram (ECG/EKG) is the voltage signal our heart produces as it beats. Each beat is a series of contractions and relaxations that require electrical signals to flow through the muscle in a specific sequence. This signal travels on the skin and can be measured with the right sensor. They are calculated using the voltage difference between two points on the body.

These signals can be measured between several points on our body, producing different waves. In our example, we focused on showing the more common pattern, called the QRS pattern, preceded by a P wave, followed by a Q wave. This signal is measured using 3 electrodes, two near the shoulder and one on the hip.

The shape of the QRS complex can be used to determine several pathologies and heart rates. The differences between a healthy heart and a diseased heart shown on an EKG can range from subtle changes to completely different signals. In addition, some pathological symptoms may appear randomly or when not measured by a doctor. Many diseases could be diagnosed earlier if ECG signals could be measured and analyzed in real time without human intervention.

Among other things, the characterization and early diagnosis of ECG signals can be accomplished using a number of AI algorithms. In our case, we choose a neural network classifier for simplicity and ease of implementation. The input to these networks is a set of parameters, and based on this network generates an output, which is a classification of the signal based on the parameters and the learning process.

technology

Due to the reliability of the language, the core of the code is mostly written in ADA, which is critical when dealing with projects related to patient health.

Implementation: Neural Network

The first step is to implement the neural network in ADA, which is the core of the project. Looking for relevant information, we found that neural networks using this language did very little. So we found it useful to develop a general library for neural networks in ADA so that it could be used in other projects. This library contains the necessary tools to create a neural network, train it, and execute it, and is useful for both the training and production phases of the network.

For the training of the network, there needs to be an "input.dat" file with the appropriate configuration, which contains the input of the neural network as well as the expected output. In the code, the necessary parameters must be configured in the "config.adb" file, such as the number of layers of the network, the number of required inputs and outputs, the size of each layer or the learning rate. As output, it generates a "weights.dat" file containing the weights generated for each neuron, which is necessary for execution in production.

We provide some basic functions, sum functions, and sigmoid functions for neuron bodies and neuron executors. The system is planned so that more functions can be easily included and configured for the network.

The complete library is located in the "neural-network-lib" folder. The training of the network, as an example of use and manipulation, has been developed in the project within the "neural-learning" folder. A production-mode example of a neural network can be found in the "example-run-net" folder, which also includes an implementation of the Fast Fourier Transform, obtained from https://rosettacode.org/wiki/Fast_Fourier_transform#Ada, we found this Very useful for processing input signals to neural networks.

STM32

The project is located in the "STM32" folder. For the STM32 board, we had to make modifications to the neural network because of code incompatibility, mainly screen output and file processing. For this reason, this version of the STM32 library is only suitable for production, not for training the network, the weights of the neurons must be imported via the ".ads" file.

Also, due to problems with returning unconstrained elements and heavy use of recursion, the FFT code had to be modified.

A console module was developed using the board's USART to be able to use the board's PA2 and PA3 pins to view the results on the screen and send them to the Raspberry Pi module. USART reading also develops through interruptions. It can be found in the file "console.adb".

Another necessary part is using the ADC, taking heartbeat information, analyzing them and sending them to the neural network. For this, the ADC device on the board has been configured on pin PA4 with 12-bit resolution, converting the input to a value between 0V and 3.3V.

The main part of ECG data processing is in the file "ecgprocess.adb". Once it receives a raw input between 0v and 3.3V, it performs a fast Fourier transform on the signal, followed by the module. From this result, it extracts some parameters from the signal that will later be used as input to the neural network. These parameters are:

Related Products

Shopping Cart Tel: +86-755-82518276 Email: sales@jinftry.com Skype: +8615019224070, annies65, +8615118125813 QQ: 568248857, 827259012, 316249462 Mobile: +8615019224070, +8615118118839, +8615118125813 WeChat: Send Message
TOP