DETECTION AND ANALYSIS OF DISEASE ENTITIES BASED ON LUNG CONDITIONS DETEKCJA I ANALIZA JEDNOSTEK CHOROBOWYCH NA PODSTAWIE SCHORZEŃ PŁUC

The article presents a method for detecting and analysing disease entities associated with lung diseases. The results are related to work on the design of a medical diagnostic system based on impedance tomography. One of the key features of the solution is its ability to diagnose respiratory diseases, particularly chronic obstructive pulmonary disease (COPD), acute respiratory distress syndrome (ARDS) and pneumothorax (PTX). The article describes the results of a classification model that effectively distinguishes between healthy and sick patients, achieving an impressive accuracy of 99.86%. This result underscores the robustness and reliability of the model. The conclusions of the presented research can serve as a basis for further work on improving diagnostic methods and introducing innovative healthcare solutions for patients with respiratory diseases, which may enable faster and more accurate diagnoses of lung diseases and provide more effective treatment and care for patients.


Introduction
Respiratory diseases are a growing and increasingly serious problem in society.The most common of these include chronic obstructive pulmonary disease (COPD), acute respiratory distress syndrome (ARDS) and pneumothorax (PTX).
COPD is a disease characterized by an increasing, hardly reversible restriction of airflow through the lower airways due to bronchospasm and loss of lung elasticity (Jassem, 2009;Antó, 2001;Górecka, 2012).This is due to the inflammation that takes place in response to harmful dust and gases that hurt the bronchial mucosa (Jassem, 2009;Antó, 2001;Górecka, 2012).Mucus secretion increases, mucus-producing glands overgrow, and the number of inflammatory cells in the mucosa increases.These cells secrete substances that cause damage to the lung tissue in the vicinity of very small bronchioles, which leads to an irreversible reduction in the diameter of small bronchi and bronchioles and the destruction of the lung parenchyma in their surroundings (Przewlekła obturacyjna choroba płuc, 2021).A simplified model with a highlighted area containing damaged lungs for very small bronchioles will be presented.It is assumed that such damage occurs at the lung periphery.
ARDS is a life-threatening condition in which the lungs cannot work correctly due to injury to the capillary wall.ARDS rarely occurs spontaneously; it usually results from another medical condition, a serious accident or trauma (Zespół ostrej niewydolności oddechowej, 2021).Patients with ARDS show varying degrees of altered endothelial and pulmonary epithelial permeability, with concomitant pulmonary edema ( Vignon, 2020) .Compared to healthy subjects, patients with ARDS manifest increased extravascular lung water (EVLW) for pulmonary arterial pressure (Neamu, 2013, p. 24-30).The simplified model primarily emphasizes small changes throughout the lungs, simulating the presence of EVLW.To date, no effective pharmacological treatment for ARDS has been invented (Zespół ostrej niewydolności oddechowej, 2021).
Pneumothorax is a medical condition in which air accumulates in the pleural cavity (Odma opłucnowa Pulmonologia, 2016).In a healthy person, there is only a negligible amount of fluid in the pleural cavity, which facilitates lung movement relative to the chest during respiratory movements.Air enters the pleural cavity if there is damage to the lung or chest wall.Its pressure causes the lung to be unable to fill appropriately with air.The accumulated air in the pleural space prevents the lungs from expanding properly during inspiration, causing difficulty in breathing.If the emphysema is so extensive that there is a significant amount of air in the pleural cavity, the lung on that side stops functioning almost entirely (Odma opłucnowa Pulmonologia, 2016).The simplified model consists, among other things, of a reduced lung, air in the pleura, and a second healthy lung.Research on pneumothorax and its evaluation and management has increased over the past 10 years (Barton, 2023).However, many questions and technologies have not yet been evaluated, which are likely to form the basis of future research.
A. PIWKO, A. KOSIOR-ROMANOWSKA, J. CHAŁDAŚ-MAJDAŃSKA • Chest X-ray is often the initial test to diagnose a pneumothorax (McKnight, 2022).Characteristic changes include Barkhausen lines, loss of lung vascular markings, and the presence of air in the pleural space.
To conduct the described examinations, the patient must adhere to specific guidelines and be instructed on how to behave correctly during the procedure.Sometimes, the results of the tests become available after a certain period, for example, when the appropriate doctor needs to analyze and describe them, which may require some time.The solution that allows for an approximate diagnosis in just a few minutes will be presented.

Materials and methods
The future of medical diagnostics relies on devices that enable longterm patient monitoring, which allows for the detection of pathological conditions.The Lung Electrical Tomography System (LETS) is responding to the demand of the medical market.It is a mobile electrical impedance tomography system in three spatial dimensions for area monitoring.The system consists of the vest (Figure 1), the measuring device and the analytics engine LETSWEB.

Hardware
The Vest has 32 electrodes dedicated to electrical impedance tomography, arranged on two planes with 16 on each one.Current injections are opposite and occur only between electrodes on the same level.Voltages are measured between adjacent electrodes.This configuration results in a data frame containing 448 voltages.Another component of the LETS, the analytics engine LETSWEB, is responsible for aggregating, processing and inferring from collected medical data.The measuring device records voltages, which are stored in the object-relational database.The data is processed and analyzed using dedicated algorithms.The medical professional is able to use the system's suggestions and then provide feedback.
Internet of Things (IoT) platform for medical tomography (Figure 2).The diagram describes the essential components of a medical electrical tomography monitoring platform with Internet of Things (IoT) devices and services.The User-Connected Unit (UCU) is a device capable of connecting to the Internet.The TS block runs web applications through the Web Server Gateway Interface (WSGI), while the MCU block serves as the microcontroller interfacing with data acquisition and the IoT gateway system.

Figure 2. IoT platform for medical tomography
Within the MCU block, the tomographic application programming interface (TAPI) stores high-level programming functions for interacting with the data acquisition process in the FTDAQ block.The MCU triggers data acquisition, and using TAPI, the configuration is loaded into FTDAQ.Experiment data is then read from FTDAQ memory to the MCU and directly stored in the TS database.
The AFE (Analog Front End) block includes components for digital control, mixed-signal conversion, and signal conditioning for the transmitter and sensor parts.The SUM block represents the system being measured.It includes an electrode interface and a measuring system, which could be a test circuit, a phantom material tester, organic tissue, or a test subject.
Digital re-configurable signal-mixing devices using Field-Programmable Gate Arrays (FPGAs) provide a key advantage for fast, parallel, and coordinated data acquisition (Mierzejewski, 2016).FPGAs are crucial for real-time monitoring in tomography due to their prototyping capabilities and as an intermediary design for application-specific integrated circuits (ASICs).In an ASIC-based active electrode system (Wu, 2018), the central port is controlled by an FPGA.FPGAs are also utilized for accelerating computational procedures, such as in a semi-parallel potential and current excitation emitter for FFT calculations and signal filtering (Khan, 2015).Additional applications may involve online nonlinear analysis, like mutual information (Véjar, 2019), acceleration of reconstruction using iterative algorithms, and the implementation of artificial intelligence algorithms, such as neural networks.Following the segmentation process to isolate the torso and lungs from the background, the next step involves generating a mesh composed of tetrahedral elements.A comprehensive description of the mesh generation procedure and the subsequent stages of data processing has been provided (Figure 3).
A. PIWKO, A. KOSIOR-ROMANOWSKA, J. CHAŁDAŚ-MAJDAŃSKA The initial stage of our algorithm involves importing a 3D image, which is expressed as a 3D matrix containing the values 0, 1, and 2, where each 0 denotes an element located outside the field of view, 1 represents a human torso, and 2 signifies human lungs.The subsequent stage involves generating a mesh comprised of tetrahedrons.This requires the creation of a voxel grid, then locating the voxels within the field of view (indicated by 1 and 2 in the 3D matrix) and constructing a mesh using tetrahedrons.Subsequently, employing a vest (Figure 1), electrodes were affixed to the model at levels 0.0 and -0.2, arranged as 16 equidistant points.Following this approach, we generated a three-dimensional mesh representing the human torso and lungs.This mesh comprises 1 617 066 tetrahedral elements and features two bands of electrodes.
The main goal of this article is to distinguish a healthy person from a person with respiratory diseases.Lung models (Figure 4) were constructed for a healthy person (a) and for a person with COPD (b), ARDS (c) and PTX (d).All lesions were highlighted in red.The distribution of conductivity in the patient's lungs was simulated using material parameters (Vignon, 2020;Zarogoulidis, 2014;Tomicic, 2019):  ϵ [0.072, 0.14] for healthy lungs,  ref = 0.35 for background, for  ARDS = 0.145 .10 -2 for ARDS, and  PTX = 10 -10 for PTX.
For the case of COPD, the following applies: The data set consists of simulated data frames and was prepared using the finite element method.For each class, the affine transformation was applied to the lung's size and shape for breathing phases.The data set was divided into training and testing sets.The first one had simulations with noise on level 4% and the second without noise.Breathing phases consist of 90 different sizes and shapes of lungs.A parameters grid was explored in the analysed task to identify the optimal solution.The focus was on three crucial hyperparameters: the number of trees, the maximum tree depth, and the learning rate coefficient.Ultimately, following 5-fold cross-validation, the highest efficiency of 99.86% accuracy score was achieved for a configuration that involved 1 000 trees, a maximum tree depth of 3, and a learning rate coefficient of 0.1.The confusion matrix for model classification is in Figure 5.For the cases without noise, the model got it wrong twice.Once, a healthy case was classified as an ARDS case, and once, a case with COPD was classified as a healthy case.

Conclusions
This article presents the application of electrical impedance tomography in medicine.It explores three cases of lung diseases affecting humans (COPD, ARDS, PTX).The classification was carried out using a dataset simulated by the finite element method for specific lung models generated with diagnosed diseases.The article introduces the LETS as a portable, non-invasive system for measuring electrical quantities from a part of the human body and analyzing this data.

Figure 3 .
Figure 3. Block diagram of the EIT data frame simulation process

Figure 4 .
Figure 4. Health and disease models for classification (c) Lungs with ARDS model (d) Lungs with PTX model A. PIWKO, A. KOSIOR-ROMANOWSKA, J. CHAŁDAŚ-MAJDAŃSKA and Discussion Diagnosing a specific lung condition was achieved by Extreme Gradient Boosting (XGBoost) (Chen, 2016).A training model data set was constructed with 19,200 cases, with 4,800 cases in each class.The testing set consisted of 4,800 cases, 1,200 cases in each class.Additionally, 90 real observations (observations without random noise) were included in the testing set for each class.Consequently, the training set ended up having a total of 5,160 observations.