Digital Spirometer

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 50

Faculty of Engineering

Department of Biomedical Engineering

DIGITAL SPIROMETER
A Research Submitted in Partial Fulfilment of the Requirements for the Degree of
Bachelor of Science (Honors) in Engineering.

Prepared by:
Mervat Abualqasim BE-2018-053

Aseel Sirelkhatim BE-2018-024

Wehad Elhadi BE-2018-034

Supervised by:

Eng. Tasneem Elbashir

Co-Supervised by:

Mr. Mohamed Fathiy

January, 2024
Dedication

the best kind of people are the ones that come into your life, and make you see the sun
where you once saw clouds. The people that believe in you, you start to believe in you
too. The people that love you, simply for being you. The once in a lifetime kind of
people

To the people who have never stopped believing in us


To our parents

Mr. Abuelgasim Elnourand Ms. Suaad Elsayed,


Mr. Sirelkhatim Suliman, Ms. Lubna Ibrahim
And Mr. Elhadi MohamedNour, Ms. Manar Kamal

We extend our deepest gratitude for the endless prayers, support and encouragement that
have illuminated our path throughout this journey. Your presence has been the cornerstone
of our ability to take those critical first steps.

I want to express my heartfelt gratitude to all my friends who have stood by me with
unwavering support. Your presence has been a source of strength and joy, turning
challenges into shared moments of laughter and warmth. I am deeply thankful for the
invaluable bond we share, and I cherish the privilege of having such wonderful friends by
my side. Your friendship has been a true blessing, and I am profoundly grateful for each one
of you.

Our friends don't always come as companions but as a chosen family. We know words
can't fully express our gratitude to you, but we wanted to say thank you from the
bottom of our heart Eng. Marwa Ahmed, Eng. Mohamed Fathiy.
Acknowledgement

First of all, we want to thank ALLAH for his never-ending grace, mercy and provision
which lead us in the right track to fulfill this project.

We wish to express our sincere gratitude to our supervisor Eng. Tasneem Elbashir for
being helpful to us by guiding, supporting, encouraging and providing her valued
comments, the co-supervisor Mr. Mohamed Fathiy for his support and effort.
Abstract

The primary test of lung function is called Spirometry. Spirometry parameters are derived from pressure
and/or flow measurements. The spirometer records exhaled air volume, and produces graphic and numeric
information in the form of spirometric parameters and tracings that can depict and describe the mechanical
properties of the lung. Some possible measurements are like Pressure and gas flows behave during one
respiratory cycle in volume controlled. Patient Spirometry measures airway pressures, flow, volumes,
compliance, and airway resistance breath-by-breath at the patient’s airway. The flow of gas is measured, and
the inspiratory and expiratory concentrations of oxygen and carbon dioxide analyzed. All parameters are
measured through a single, lightweight flow sensor and gas sampler, placed at the patient’s airway. The “close
to the patient” measurement is a sensitive and continuous reflector of patient’s ventilator status, obtained
independently of the ventilator used. The breath-by-breath measurement of pulmonary gas exchange is
technically very demanding and requires sophisticated compensation and data processing algorithms to
achieve the accuracy required in the clinical use. Measurement of respiratory gas flow continuously is
associated with several problems, such as the effects of humidity, alternating gas composition, secretions,
and the dynamic response of the flow sensors. Medical technologies have enabled accurate measurement of
respiratory gas exchange in a wide variety of clinical conditions. The clinical applications range from
assessment of energy requirements to comprehensive analysis of ventilation and oxygen transport in patients
with complex cardio respiratory problems. Obstructive disorders, which are much more common than
restrictive abnormalities include asthma and COPD. Asthmatic bronchitis, chronic bronchitis, and
emphysema are included in COPD. These diseases can be identified by a low FEV / FVC ratio or an FEV
that is lower than predicted. Spirometric data have been presented as exhaled volume over time. These
volume-time curves are easy to visualize and allow physicians to identify FEV, FVC, and expiratory time at
a glance. The flow transducer permits physicians to visualize peak flow and timed peak flow. Which is a
check of patients’ efforts FEV, FVC, and FEV, FVC ratio are expressed in terms of lower limit of normal.
Spirometric measurements can be as fundamental to medicine as are pulse, blood pressure. Temperature,
height and weight measurements and therefore could be considered in the physical examination as important
vital signs.
Figure Page
Figure 2.1: Respiratory System [2] 5
Figure 2.2: The process of breathing in / The process of breathing out [3] 6
Figure 2.3: Spirometry [5] 8
Figure 2.4: Lung Volumes and Lung Capacities [6] 9
Figure 2.5: The spirometry system of claim [8] 15
Figure 3.1: Block diagram of the project system 17
Figure 3.2: Methodology Framework of the project 18
Figure 3.3: Thonny [15] 20
Figure 4.1: Spirometry Simulation input 21
Figure 4.2: Case 1 22
Figure 4.3: Case 2 23
Figure 4.4: Case 3 24
Figure 4.5: Case 4 25
Figure 4.6: Summery of Acceptability, Usability, and Repeatability
Criteria for FEV1 and FVC. [16] 26
Figure 4.7: Grading System for FEV1 and FVC. [16] 26
Figure 4.8: Copely website [17] 27
Figure 4.9: MSD Manual website [18] 27

v
Table of contents

Title Page
List of Figures iii

Chapter One
1.1 Overview 2
1.2 Motivation 2
1.3 Research Questions 2
1.4 Problem Statement 2
1.5 Objectives 3
1.5.1 General Objective 3
1.5.2 Special Objective 3
1.6 Scope 3
1.7 Thesis outlines 4
Chapter Two
2.1 Theoretical Background 5

2.1.1 Biological background 5

2.1.2 Respiratory System Functions 6

2.1.3 Breathing Process 6

2.1.4 Respiratory System Diseases 7

2.1.5 Spirometry 8

2.1.6 Lung Volumes 9

2.1.7 Lung Capacities 10

2.1.8 Test the Lung Functions 11

2.1.9 Classification of abnormal spirometry 11

2.1.10 Factors affect the spirometry measurements 13

2.2 Literature Review 15

Chapter Three
3.1 Methodology 18
3.2 Block Diagram 18
3.3 Flow Chart 19
3.4 Software Components 20
3.4.1 Thonny 20

vi
4. Chapter Four
4.1 Introduction
21
4.2 Results
21
4.2.1 Case 1
22
4.2.2 Case 2 23
4.2.3 Case 3 24
4.2.4 Case 4 25
5. Chapter Five
5.1 Conclusion 28
5.2 Recommendation and Future Work 28
6. References 29
Appendix 32

vii
Abbreviations

FEV Forced Expiratory Volume


FVC Forced Vital Capacity
COPD chronic obstructive pulmonary disease
TV Tidal Volume
IRV Inspiratory Reserve Volume
ERV Expiratory Reserve Volume

RV Residual Volume/Reserve Volume


IC Inspiratory capacity
VC Vital Capacity
TLC TLC Total lung Capacity
FRC Functional Residual Capacity
PEF peak expiratory flow rate
CT Computed Tomography
IDE Integrated Development Environment
UI user interface

1
Chapter One
Introduction
1.1 Overview

The human body is made up of numerous organs and tissues that work together to carry
out various tasks in a way that ensures life's continuity. If there were a defect, however,
life would be gradually interrupted and eventually end in death for humans. These
devices are intertwined and each is essential to the other, including the digestive,
respiratory, periodic, and nervous systems. One of the most crucial organs, the respiratory
system is responsible for breathing, distributing oxygen to all body parts, and eliminating
carbon dioxide. Our major goal is to create a fully functional, straightforward spirometer by
using Python language. Our goal is to correct or redesign the spirometry to make it more useful,
simple, accurate.

1.2 Motivation

The huge motivation for us is being able to help people with lung diseases and facilitate
their lives and diagnose their normal and abnormal situations.

1.3 Research Questions

How to design a digital spirometer which can reliably extract pulmonary


flow information?

How we used Thonny to display results?

1.4 Problem statement

According to the latest estimates of the World Health Organization (WHO) more than 3
million people die each year from Chronic Obstructive Pulmonary Diseases (COPD) which
is approximately 6% of all deaths worldwide and 90% of COPD deaths occur in low-
income and middle- income countries.

2
1.5 Objectives

1.5.1 General Objective:

To design digital spirometer easy-to-use and carry out the various lung functioning tests.

1.5.2 Special Objective:


- To design and develop a digital spirometer which can reliably extract pulmonary
flow information.
- To processing preliminary signals and display Spiro metric measurements

1.6 Scope

This project aims to design a promising diagnostic tool in personal and


point of care settings. The developed model can assist the patients by
providing a preliminary diagnosis. It may be shared with the physician
over the network. Patients in resource- limited settings may not have
access to sophisticated health monitoring systems. In this scenario, the
proposed system is an important step towards the goal of Health for All.

3
1.7 Thesis outlines

The thesis consists of five main chapters and appendices explained in detail within this
thesis.

Chapter one: explains in detail the information about the project background, motivation,
research question, problem statement, objectives, scope and the contribution of research.
In this chapter the reader could find out the overview of this project in addition to the
significance of this project.

Chapter two: the related literature to this project is provided in detail. The topics explained
in this chapter includes approaches, design issues, software programming and basic
hardware.

Chapter three: is about design and implementation step which is explained in details
including the prototype.

Chapter four: all the results and analysis about the system either it achieved the objectives
or not.

Chapter five: summarizes this project with recommendations and future work.

4
Chapter Two
Literature review
2.1 Theoretical Background

2.1.1 Biological background

The respiratory system is the network of organs and tissues that help the breath. It includes
the airways, lungs and blood vessels. The muscles that power the lungs are also part of the
respiratory system. These parts work together to move oxygen throughout the body and
clean out waste gases like carbon dioxide. [1]

Figure 2.1: Respiratory System [2]

5
2.1.2 Respiratory System Functions

The respiratory system has many functions. Besides helping inhale (breathe in) and exhale
(breathe out), it:

 Allow to talk and to smell.


 Warms air to match the body temperature and moisturizes it to the humidity level
the body needs.
 Delivers oxygen to the cells in the body.
 Removes waste gases, including carbon dioxide, from the body when exhale.
 Protects airways from harmful substances and irritants. [1]

2.1.3 Breathing Process

The process of breathing, or respiration, is divided into two distinct phases. The first phase
is called inspiration, or inhaling. When the lungs inhale, the diaphragm contracts and pulls
downward. At the same time, the muscles between the ribs contract and pull upward. This
increases the size of the thoracic cavity and decreases the pressure inside. As a result, air
rushes in and fills the lungs.

The second phase is called expiration, or exhaling. When the lungs exhale, the diaphragm
relaxes, and the volume of the thoracic cavity decreases, while the pressure within it
increases. As a result, the lungs contract and air are forced out. [3]

Figure 2.2: The process of breathing in / The process of breathing out [3]

6
2.1.4 Respiratory System Diseases

Many conditions can affect the organs and tissues that make up the respiratory system.
Some develop due to irritants the breath in from the air, including viruses or bacteria that
cause infection. Others occur as a result of disease or getting older.

Conditions that can cause inflammation (swelling, irritation and pain) or otherwise affect
the respiratory system include:

 Allergies: Inhaling proteins, such as dust, mold, and pollen, can cause respiratory
allergies in some people. These proteins can cause inflammation in airways.
 Asthma: A chronic (long-term) disorder, asthma causes inflammation in the
airways that can make breathing difficult.
 Infection: Infections can lead to pneumonia (inflammation of the lungs) or
bronchitis (inflammation of the bronchial tubes). Common respiratory infections
include the flu (influenza) or a cold.
 Disease: Respiratory disorders include lung cancer and chronic obstructive
pulmonary disease (COPD). These illnesses can harm the respiratory system’s
ability to deliver oxygen throughout the body and filter out waste gases.
 Aging: Lung capacity decreases as get older.
 Damage: Damage to the respiratory system can cause breathing problems. [1]

7
2.1.5 Spirometry

Spirometry (spy-ROM-uh-tree) is a common office test used to assess how well the lungs
work by measuring how much air inhale; how much exhale and how quickly exhale.

Spirometry is used to diagnose asthma, chronic obstructive pulmonary disease (COPD)


and other conditions that affect breathing. Spirometry may also be used periodically to
monitor the lung condition and check whether a treatment for a chronic lung condition is
helping the breath better.

If the patient already been diagnosed with a chronic lung disorder, spirometry may be used
periodically to check how well the medications are working and whether breathing
problems are under control. Spirometry may be ordered before a planned surgery to check
if the lung function is adequate for the rigors of an operation. Additionally, spirometry may
be used to screen for occupational-related lung disorders. [4]

Figure 2.3: Spirometry [5]

8
2.1.6 Lung Volumes

The lung volume can be described by the following terms:

 Tidal Volume (TV)


The tidal volume is the total amount of air inhaled or exhaled during regular
respiration or relaxed breathing. Approximately 500 ml of air is utilized during
normal respiration in a healthy man.
 Inspiratory Reserve Volume (IRV)
An inspiratory reserve volume is a supplementary volume, approximately ranging
between 2500 to 3100 ml of air which could be effectively inhaled after the
inspiration of a standard tidal volume.
 Expiratory Reserve Volume (ERV)
An expiratory reserve volume refers to the additional capacity of air which is about
1200 ml are that could be forcibly exhaled out after the expiration of a standard
tidal volume.
 Residual Volume/Reserve Volume (RV)
The residual volume is about the total volume of air around 1100 ml to 1200 ml
residing in the lungs after the reserve volume is emitted or breathed out. [6]

Figure 2.4: Lung Volumes and Lung Capacities [6]

9
2.1.7 Lung Capacities

The lung capacities can be explained by the following terms: [6]

 Total Lung Capacity


The total lung capacity applies to the total volume of air-filled in the lungs after a
forced inspiration. The lung capacity of a healthy man is estimated to be 6000 ml.

TLC = TV + ERV + IRV + RV

 Vital Capacity
The vital capacity is the total volume of air that can be expired after a maximum
inhalation or maximum air that a person can breathe in after forced expiration. It is
an important measure of a person’s respiratory health. A decreased vital capacity is
an indication of restrictive lung disease where the lungs cannot expand completely.
In the case of normal vital capacity, the improper functioning of lungs indicates
obstructive lung disease where the lungs are blocked in the airways.

VC = TV + ERV + IRV

 Inspiratory Capacity
The inspiratory capacity is the total volume of air that can be inspired which is
about 3600 ml.

IC = TV + IRV

 Functional Residual Capacity


The functional residual capacity is the total volume of air residing within the lungs
after an exhalation process and it is about 2400 ml.

FRC = ERV + RV

10
2.1.8 Test the Lung Functions

Lung function tests (also called pulmonary function tests) include a variety of tests that
check how well the lungs work. The most basic test is spirometry. This test measures the
amount of air the lungs can hold. The test also measures how forcefully one can empty air
from the lungs.

Spirometry is used to screen for diseases that affect lung volumes. It also is used to screen
for diseases that affect the airways, such as COPD or asthma.

Lung volume testing is another commonly performed lung function test. It is more precise
than spirometry and measures the volume of air in the lungs, including the air that remains
at the end of a normal breath. In addition, a diffusing capacity test measures how easily
oxygen enters the bloodstream. Exercise testing helps evaluate causes of shortness of
breath. There are also tests to find out if asthma is present when the usual breathing test
results are normal. [7]

2.1.9 Classification of abnormal spirometry

Spirometry can be classified on the basis of these major indices into three abnormal
patterns:

1. An obstructive ventilator defect with reduced FEV1, FEV1/FVC ratio, or PEF. 2. A


restrictive pattern with loss of lung volume without airflow limitation suggested by low
FVC but a normal or high FEV1/FVC ratio.

3. A mixed obstructive and restrictive pattern with airflow limitation and loss of lung
volume shown by low FVC but low FEV1/FVC ratio.

11
The shape of the flow-volume curve may also vary between an obstructive defect, where
the expiratory curve is convex towards flow and volume axes, and a restrictive disease
where the shape may be concave towards the axes. More complex tests of ventilator
function normally undertaken in a physiology laboratory setting,

such as measurement of total lung capacity and residual volume, are required to confirm
both the restrictive and mixed obstructive/restrictive abnormalities. A particular
confounder can exist where a high residual volume due to air causes the decrease in FVC
giving the false appearance of restriction.

spirometry measures include the following:

. Forced expiratory volume in 1 s (FEV 1)

. Forced vital capacity (FVC), the maximum amount of air that can be exhaled when
blowing out as fast as Possible.

.Vital capacity (VC), the maximum amount of air that can be exhaled when blowing out
at a steady rate.

.FEV 1 /FVC ratio.

12
2.1.10 Factors affect the spirometry measurements

Digital Spirometry are intricately influenced by four key inputs: age, height, density, and
pipe diameter, each playing a distinct role in the scientific accuracy of the measurements.

Age significantly influences spirometry measurements due to various physiological


changes in the respiratory system over time. As individuals age, alterations in lung
elasticity and compliance occur, leading to reduced vital capacity as the lungs become
less adept at expanding and contracting. The chest wall stiffens with age, impacting the
ability of the chest to fully expand during inhalation, consequently influencing lung
volumes and capacities measured during spirometry. Declining respiratory muscle
strength is another age-related factor that can contribute to diminished force during
inspiration and expiration, affecting parameters such as forced expiratory volume in one
second (FEV1) and peak expiratory flow rate (PEF). Structural changes, including the
loss of lung parenchyma and increased airway resistance, can further impact airflow
dynamics and spirometry outcomes. Gender-related differences in lung function also play
a role, with men typically exhibiting larger lung volumes than women. Therefore, age-
specific reference values are crucial for accurate interpretation of spirometry results,
recognizing the intricate interplay of aging processes on respiratory function.

Height significantly influences spirometry measurements as it directly correlates with


lung volumes and capacities. The height of an individual reflects the size of the thoracic
cavity, impacting the maximum amount of air the lungs can hold. Taller individuals tend
to have larger lung volumes compared to shorter individuals due to increased thoracic
space. This relationship is particularly evident in parameters such as forced vital capacity
(FVC) and forced expiratory volume in one second (FEV1), where lung size plays a
crucial role. Therefore, when interpreting spirometry results, accounting for height is
essential to establish accurate baseline values and to understand the individual's
respiratory function relative to their unique physiological characteristics.

13
Density plays a significant role in spirometry by influencing the calculation of lung
volumes. The density of inhaled air varies with changes in atmospheric conditions, and
this variation directly affects the volume measurements recorded during spirometric tests.
As the density of air fluctuates, particularly in response to alterations in temperature,
pressure, and humidity, the accuracy of spirometry results can be impacted. To enhance
precision in interpreting spirometry data, adjustments for density fluctuations may be
necessary, ensuring that the recorded lung volumes are corrected for the specific
conditions under which the test is conducted. Recognizing and accounting for the
influence of air density is crucial in obtaining reliable and standardized spirometric
measurements.

Pipe diameter in spirometry plays a crucial role in determining airflow resistance and,
consequently, affects the accuracy of flow-related parameters. The diameter of the
measurement pipe influences the resistance encountered by the airflow during both
inhalation and exhalation maneuvers. A smaller diameter increases airflow resistance,
potentially leading to higher pressure gradients and affecting parameters like forced
expiratory flow rates. Conversely, a larger diameter reduces resistance, allowing for
smoother airflow. The choice of an appropriate pipe diameter is essential for maintaining
standardized testing conditions and ensuring that spirometric measurements accurately
reflect the dynamics of respiratory function. Adjusting for pipe diameter variations is
vital in interpreting results and comparing data across different spirometric setups to
account for their impact on airflow resistance and associated parameters.

14
2.2 Literature Review

A spirometry system included an imaging device that was configured to capture upper body
movement images of a subject during inhalation and exhalation. The system also had at
least one controller that was configured to receive the captured images from the imaging
device and, based on the received images, determined at least one of an image-based
spirometry flow volume curve for the subject or an image-based spirometry parameter for
the subject. [8]

Figure 2.5: The spirometry system of claim [8]

A portable incentive spirometry monitoring device and method of use were developed. The
device was connected to the base of an incentive spirometer, capable of monitoring
inspiration within the incentive spirometer. It featured a user interface for inputting various
parameters, such as desired air volume and attempt thresholds. Results were stored,
allowing medical personnel to review a patient's attempts, monitor therapeutic use, and
encourage patient compliance. Importantly, the portable incentive spirometry monitoring
device could be reused with different incentive spirometers without requiring extensive
sterilization. [9]

15
A method for identifying and diagnosing pulmonary disease using a classification system
and its kit was disclosed (Kind Code: A1). The invention provided biomarkers and
biomarker combinations for diagnosing lung diseases like non-small cell lung cancer or
reactive airway disease. Measurements of these biomarkers were input into a classification
system, such as support vector machines or Ad boost, to determine the likelihood of an
individual having lung disease. Additionally, kits containing agents for detecting these
biomarkers, combinations, and systems to aid in the diagnosis of lung disease were also
provided. [10]

A diagnostic support program that could display movement of a region whose shape
changed for each respiratory element, encompassing all or part of exhalation or inhalation,
was provided. A process was employed to identify a period of a respiratory element,
including all or part of exhalation or inspiration, based on pixels in a specific region of
each frame image. The program then detected a lung field based on the identified
respiratory element's period, divided the detected lung field into multiple block areas,
calculated changes in the image of these block areas in each frame image, and Fourier-
transformed these changes. Subsequently, within a certain band, which included the
spectrum corresponding to the respiratory element's period, a spectrum was extracted, and
an inverse Fourier transform was performed on it. The resulting inverse transform was
displayed on a display, completing the process. [11]

The invention provided a method for monitoring respiratory frequency and sleep-
disordered breathing based on wearable equipment. The steps included acquiring
physiological characteristic data, such as pulse wave signals and electro cardio signals,
from a monitored user. The pulse wave and electro cardio signals were preprocessed to
remove interference, baseline drift, and motion artifacts, and then uploaded to a big data
center. A respiratory frequency and sleep-disordered breathing learning model were
established based on organ model, disease model, and physiological characteristic data.
This model enabled real-time monitoring of the user's respiratory frequency and sleep-
disordered breathing. The invention, requiring only the user to wear wearable equipment,
offered convenience, strong operability, low cost, and more convenience compared to a
portable breath detector. The wearable device demonstrated robust real-time monitoring
performance, acquiring physiological data in real-time, surpassing the capabilities of a
portable breathing detector. Furthermore, users could make personalized adjustments to
their healthy lifestyle based on the feedback data. [12]

16
A method of imaging a patient's lung involved positioning the patient at a first orientation
relative to an x-ray imaging apparatus and obtaining a volumetric measurement of the
patient's breathing. While the patient was positioned at the first orientation and during the
volumetric measurement of the patient's breathing, the method determined the breathing
phase of the patient based on the volumetric measurement. Upon establishing that the
breathing phase matched a predefined phase, the x-ray imaging apparatus was gated to
produce an x-ray projection of the patient's lung. [13]

The invention provided a CT scanning method for lung respiratory motion detection in the
technical field of lung CT scanning. The steps included a breath pre-training step, where
the patient underwent respiratory training before CT scanning, with a respiratory cycle
denoted as t1. Following this, a CT parameter setting step was carried out with 4-10
scanning periods, each period lasting for a scanning period time (t2) greater than t1 but less
than 2t1. Subsequently, CT scanning commenced, with the patient instructed to start slow
respiration during the scanning period (t2). The respiratory motion process condition of the
lung during a breathing cycle (t1) was recorded by CT scanning. The invention facilitated
continuous chest CT scanning under dynamic respiration, enabling continuous and
dynamic detection and evaluation of lung structure and function. This addressed the
limitation of current lung function assessments and provided complete information on lung
respiratory motion, overcoming clinical challenges associated with single static CT
scanning indices. [14]

17
Chapter Three
Methodology
In this section we will describe the process of the safety system and the software tools that
will be used.

3.1 Methodology

Gather and Analyze respiratory data using the Thonny programming environment.
Participants meeting specified criteria underwent spirometry tests with careful calibration
and adherence to standardized testing conditions. Age, height, density, and pipe diameter
were systematically recorded as key variables influencing the respiratory measurements.
Thonny's scripting capabilities facilitated the implementation of algorithms for data
processing, statistical analysis, and result display. Codes written in Thonny were
meticulously designed to handle data intricacies, ensuring accurate calculations and
meaningful graphical representations. Ethical considerations were paramount, with
adherence to participant privacy and informed consent protocols. The developed Thonny
interface allowed for a user-friendly presentation of spirometric results, enhancing
participant engagement. This streamlined methodology harmonizes traditional spirometry
practices with modern programming techniques, providing a comprehensive framework
for reliable data collection and analysis.

3.2 Block diagram

Computer

Data Processing
Input Spirometric Results
and
Parameters Parameters Display
Calculations

Figure 3.1: Block diagram of the project system.

18
3.3 Flow chart

Figure 3.2: Methodology Framework of the project.

19
3.4 Software Components

 Thonny

3.4.1 Thonny

An IDE for Python called Thonny was created with science to make Python
programming more accessible and efficient. Its UI is carefully designed to meet the needs
of both inexperienced and experienced developers, following the guidelines of readability
and simplicity. The integrated Python interpreter simplifies the beginning of coding
projects by removing the hassles of third-party installations. A methodical approach to
package installation, updating, and general dependency management is offered by
Thonny's package management system. Robust scientifically, the IDE incorporates
debugging and code execution facilities, allowing for accurate mistake detection and
correction.

Moreover, Thonny facilitates the establishment and administration of virtual


environments, upholding software development best practices by permitting segregated
project spaces. In a scientific setting, this feature encourages reproducibility and code
integrity.

Figure 3.3: Thonny [15]

20
Chapter Four
Results and discussion

4.1 Introduction

The results of digital spirometry are intricately influenced by four key inputs: age, height,
density, and pipe diameter, each playing a distinct role in the scientific accuracy of the
measurements.

4.2 Results

In the spirometry simulation, this is where crucial data: age, height, pipe diameter, and
density are inserted

Figure 4.1: Spirometry Simulation input

21
After the parameter inputs, including age, height, pipe diameter, and density, have been
inserted, the system proceeds to process and calculate the data. This crucial step involves
utilizing algorithms and computations, ensuring accurate and meaningful results in the
context of spirometry simulations.

Here are a few cases with different inputs, demonstrating the flexibility of the spirometry
simulation.

4.2.1 Case 1

Figure 4.2: Case 1

The results presented are derived from a digital spirometry simulation, featuring inputs
specifying an age of 6, height of 112.3, and a pipe diameter of 0.025. The simulation
outputs include the Forced Expiratory Volume in one second (FEV1), Forced Vital
Capacity (FVC), and the ratio between them. Additionally, the results provide
information on repeatability grade and mass flow rate.

22
4.2.2 Case 2

Figure 4.3: Case 2

The results presented are derived from a digital spirometry simulation, featuring inputs
specifying an age of 16, height of 170, and a pipe diameter of 0.0032. The simulation
outputs include the Forced Expiratory Volume in one second (FEV1), Forced Vital
Capacity (FVC), and the ratio between them. Additionally, the results provide
information on repeatability grade and mass flow rate.

23
4.2.3 Case 3

Figure 4.4: Case 3

The results presented are derived from a digital spirometry simulation, featuring inputs
specifying an age of 54, height of 165, and a pipe diameter of 0.0685. The simulation
outputs include the Forced Expiratory Volume in one second (FEV1), Forced Vital
Capacity (FVC), and the ratio between them. Additionally, the results provide
information on repeatability grade and mass flow rate.

24
4.2.4 Case 4

Figure 4.5: Case 4

The results presented are derived from a digital spirometry simulation, featuring inputs
specifying an age of 23, height of 176, and a pipe diameter of 0.2002. The simulation
outputs include the Forced Expiratory Volume in one second (FEV1), Forced Vital
Capacity (FVC), and the ratio between them. Additionally, the results provide
information on repeatability grade and mass flow rate.

25
The results presented here are derived from the Standardization of Spirometry as outlined
in the Official American Thoracic Society and European Respiratory Society Technical
Statement. Tables have been incorporated to succinctly illustrate these standards,
providing a clear and straightforward reference for understanding the methodologies
employed in this study.

Figure 4.6: Summery of Acceptability, Usability, and Repeatability Criteria


for FEV1 and FVC. [16]

Figure 4.7: Grading System for FEV1 and FVC. [16]

26
The calculations utilized in the digital spirometer are primarily derived from the Flow
Rate Calculator, a Canadian website known as Copley, and the MSD Manual, an
American website, both esteemed for their authoritative content. To enhance transparency
regarding the sources influencing the computational methodologies employed, snapshots
of these websites will be inserted.

Figure 4.8: Copely website [17]

Figure 4.9: MSD Manual website [18]

27
Chapter 5
Conclusion and Recommendation

5.1 Conclusion
Due to its prohibitive cost, adequate pulmonary function testing in developing nations
such as Sudan is very limited. Physicians from these areas realize that the quality of
treatment they could provide to patients would increase dramatically if they had access to
spirometers. Unfortunately, such physicians cannot afford to invest in these devices as the
high costs would likely never be regained from the nominal fees they charge for their
services. Thus, essential diagnoses and monitoring are performed with severely limited
information. The progress we have made this semester in the development of a low-cost
spirometer is the first step toward changing this situation. This project exhibits a
profitable yet socially beneficial solution in manufacturing and selling a low-cost
spirometer to practitioners in developing countries. This project also demonstrates the
value of open innovation in the medical device and healthcare sector, and the commercial
viability of addressing situations where the market has failed to deliver necessary
technology at a widely affordable price.

5.2 Recommendations and Future Work


As further work many suggestions can be listed:
• To print circuit and finalize microcontroller program.
• To perform human subjects testing.
• To modify the proposed system and add some notification systems like alerts on
future asthma attacks.
• To establish a method for design manufacturing.

28
6. References

[1] “Respiratory system: Functions, facts, Organs & Anatomy,” Cleveland Clinic.
[Online]. Available: https://my.clevelandclinic.org/health/articles/21205-respiratory-
system. [Accessed: 26-Nov-2022].

[2] “Respiratory health,” Reeve Foundation. [Online]. Available:


https://www.christopherreeve.org/living-with-paralysis/health/secondary-
conditions/respiratory-health. [Accessed: 26-Nov-2022].

[3] “Breathing - health video: MedlinePlus medical encyclopedia,” MedlinePlus.


[Online]. Available: https://medlineplus.gov/ency/anatomyvideos/000018.htm.
[Accessed: 26-Nov-2022].

[4] “Spirometry,” Mayo Clinic, 17-Aug-2017. [Online]. Available:


https://www.mayoclinic.org/tests-procedures/spirometry/about/pac-20385201. [Accessed:
26-Nov-2022].

[5] “Mir Spiro lab spirometer,” HALOMEDICALS SYSTEMS LIMITED, 22-Nov-


2022. [Online]. Available: https://halomedicals.com/product/portable-spirometer-
spirolab/. [Accessed: 26-Nov-2022].

[6] Admin, “An overview of lung volumes and capacities (vital capacity),” BYJUS, 03-
Aug-2020. [Online]. Available: https://byjus.com/biology/respiratory-and-lung-volumes/.
[Accessed: 26-Nov-2022].

[7] A. L. Association, “Lung function tests,” American Lung Association. [Online].


Available: https://www.lung.org/lung-health-diseases/lung-procedures-and-tests/lung-
function-tests. [Accessed: 26-Nov-2022].

[8] “US20200000370A1 - imaging-based spirometry systems and methods,” Google


Patents. [Online]. Available:

29
https://patents.google.com/patent/US20200000370A1/en?q=Spirometry&oq=Spiro
metry. [Accessed: 26-Nov-2022].

[9] “US10610129B1 - systems and methods for portable monitoring of incentive


spirometry,” Google Patents. [Online]. Available:
https://patents.google.com/patent/US10610129B1/en?q=Spirometry&oq=Spirometr
y. [Accessed: 26-Nov-2022].

[10] “JP2022136138A - methods of identifying and diagnosing pulmonary diseases using


classification systems and kits thereof,” Google Patents. [Online]. Available:
https://patents.google.com/patent/JP2022136138A/en?q=Spirometry&oq=Spirometr
y&sort=new. [Accessed: 26-Nov-2022].

[11] “JP2022172305A - Diagnostic Support Program,” Google Patents. [Online].


Available:
https://patents.google.com/patent/JP2022172305A/en?q=Spirometer&oq=Spiromete
r&sort=new. [Accessed: 09-Jan-2023].

[12] “CN115363544A - method for monitoring respiratory frequency and sleep


disordered breathing based on wearable device,” Google Patents. [Online]. Available:
https://patents.google.com/patent/CN115363544A/en?oq=CN115363544A. [Accessed:
09-Jan-2023].

[13] “AU2022221404A1 - system and method for lung-volume-gated X-ray imaging,”


Google Patents. [Online]. Available:
https://patents.google.com/patent/AU2022221404A1/en?oq=AU2022221404A1.
[Accessed: 09-Jan-2023].

[14] “CN115177279A - CT scanning method for lung respiratory motion detection,”


Google Patents. [Online]. Available:
https://patents.google.com/patent/CN115177279A/en?oq=CN115177279A. [Accessed:
09-Jan-2023].

30
[15] “Thonny download: Get familiar with the python programming language using a
novice-friendly IDE that provides you with several helpful learning tools, all packed into
an intuitive gui,” softpedia, 19-Nov-2023. [Online]. Available:
https://www.softpedia.com/get/Programming/Coding-languages-
Compilers/Thonny.shtml#sgal_0. [Accessed: 14-Jan-2024]

[16] “Thonny download: Get familiar with the python programming language using a
novice-friendly IDE that provides you with several helpful learning tools, all
packed into an intuitive gui,” softpedia, 19-Nov-2023. [Online]. Available:
https://www.softpedia.com/get/Programming/Coding-languages-
Compilers/Thonny.shtml#sgal_0. [Accessed: 14-Jan-2024]

[17] “Flow rate calculator - pressure and diameter,” Copely, 17-Aug-2023. [Online].
Available: https://www.copely.com/tools/flow-rate-calculator/. [Accessed: 15-Jan-
2024]

[18] [“Calculators: PFT adjusted predicted values for men MultiCalc,” MSD Manual
Professional Edition. [Online]. Available:
https://www.msdmanuals.com/professional/multimedia/clinical-calculator/pft-
adjusted-predicted-values-for-men-multicalc. [Accessed: 15-Jan-2024]

31
Appendix
import time

import tkinter as tk

from tkinter import ttk

import random

# Constants

volume_update_interval = 100 # Update interval for volume calculation (milliseconds)

density_air = 1.225 # Density of air at standard conditions in kg/m^3

liters_to_cubic_meters = 0.001 # Conversion factor for liters to cubic meters

seconds_to_minutes = 1 / 60.0 # Conversion factor for seconds to minutes

volumetric_flow_rate = 0.0

# Variables (in liters)

age, height, volume, pipe_diameter = 30, 170, 0, 0.025

# Initialize FVC and FEV1 values

fvc_values = []

fev1_values = []

# Adjustment factors

fev1_adjustment_factor = 1.08

fvc_adjustment_factor = 1.1

# GUI initialization

root = tk.Tk()

32
density_slider = ttk.Scale(root, from_=0, to=100, length=200, orient=tk.HORIZONTAL)

density_slider.set(50)

# Placeholder function - replace with actual implementation

def calculate_pressure(density):

proportionality_constant = 1.0

return proportionality_constant * density

def delay(milliseconds):

time.sleep(milliseconds / 1000.0)

def calculate_predicted_fev1(age, height):

race_factor = 1 # Replace with the appropriate value for Race (1 for the first case)

scaling_factor = 0.001 # Adjust this factor based on the scaling issue

return race_factor * fev1_adjustment_factor * scaling_factor * ((0.043 * height) -


(0.029 * age) - 2.49)

def calculate_predicted_fvc(age, height):

race_factor = 1 # Replace with the appropriate value for Race (1 for the first case)

scaling_factor = 0.001 # Adjust this factor based on the scaling issue

return race_factor * fvc_adjustment_factor * scaling_factor * ((0.0576 * height) -


(0.0269 * age) - 4.34)

def calculate_predicted_ratio(age):

return 87.2 - (0.18 * age)

def kg_to_lbs(kg):

# Function to convert kilograms to pounds

33
return kg * 2.20462

def calculate_mass_flow_rate(volumetric_flow_rate, density):

# Function to calculate mass flow rate

return volumetric_flow_rate * density

def calculate_pipe_area(diameter):

# Function to calculate the cross-sectional area of a cylindrical pipe

return 3.14159 * (diameter / 2) ** 2

def calculate_volumetric_flow_rate(area):

# Function to calculate volumetric flow rate

flow_velocity = 1.0 # Example flow velocity in m/s

return area * flow_velocity

def calculate_grade(measured_value, predicted_value, age):

# Function to calculate grade based on absolute differences and age

# This is a placeholder

absolute_difference = abs(measured_value - predicted_value)

if age >= 6:

if absolute_difference <= 0.150:

return "A"

elif absolute_difference <= 0.200:

return "B"

elif absolute_difference <= 0.250:

34
return "C"

else:

return "D"

else: # age < 6

if absolute_difference <= 0.100:

return "A"

elif absolute_difference <= 0.150:

return "B"

elif absolute_difference <= 0.200:

return "C"

else:

return "D"

def calculate_flow_and_volume():

global volume, volumetric_flow_rate

flow_rate_increment = 0.01

volume_increment = volumetric_flow_rate * flow_rate_increment * (1 +


random.uniform(-0.1, 0.1))

volumetric_flow_rate += flow_rate_increment

volume += volume_increment

fvc_values.append(volume)

fev1_values.append(volume)

35
def repeatability_grade(measured_value, predicted_value, age):

absolute_difference = abs(measured_value - predicted_value)

if age >= 6:

if absolute_difference <= 0.1:

return "Excellent"

elif absolute_difference <= 0.2:

return "Good"

elif absolute_difference <= 0.3:

return "Fair"

else:

return "Poor"

else: # age < 6

if absolute_difference <= 0.05:

return "Excellent"

elif absolute_difference <= 0.1:

return "Good"

elif absolute_difference <= 0.15:

return "Fair"

else:

return "Poor"

def perform_quality_control_ATS_ERS_standards_checks():

36
global volume, fvc_values

# Check if FVC is within the repeatability tolerance

# or is greater than the largest prior observed FVC

if fvc_values:

largest_prior_fvc = max(fvc_values)

if volume >= largest_prior_fvc:

print("FVC Meets EOFE Acceptability Criteria")

else:

print("FVC May Meet EOFE Usability Criteria")

else:

print("Insufficient data for EOFE criteria check")

# Other quality control checks...

# Repeatability criteria checks based on age

if age >= 6 and fvc_values:

fvc_difference = max(fvc_values) - min(fvc_values)

fev1_difference = max(fev1_values) - min(fev1_values)

if fvc_difference >= 0.150 or fev1_difference >= 0.150:

print("Quality Control: Repeatability check failed for age >= 6")

elif age < 6 and fvc_values:

fvc_difference = max(fvc_values) - min(fvc_values)

fev1_difference = max(fev1_values) - min(fev1_values)

37
fvc_threshold = max(0.100, 0.10 * max(fvc_values))

fev1_threshold = max(0.100, 0.10 * max(fev1_values))

if fvc_difference >= fvc_threshold or fev1_difference >= fev1_threshold:

print("Quality Control: Repeatability check failed for age < 6")

else:

print("Quality Control: Insufficient data for repeatability check")

def simulate_spirometry(density_slider_value):

global volume, volumetric_flow_rate, fvc_values, fev1_values

time_elapsed = 0

density = density_slider_value

while True:

pressure = calculate_pressure(density)

calculate_flow_and_volume()

print("Pressure:", pressure)

print("Volumetric Flow Rate:", volumetric_flow_rate)

print("Volume:", volume)

delay(volume_update_interval)

time_elapsed += (float(volume_update_interval) / 1000)

if time_elapsed >= 1: # Terminate the maneuver after 1 second

# Check for an expiratory plateau in the last 1 second

38
volume_change_last_second = volume - fvc_values[-int(1 /
(volume_update_interval / 1000))]

if volume_change_last_second <= 25:

print("Expiratory Plateau Achieved")

else:

print("Expiratory Plateau Not Achieved")

break

def update_variable(value, variable_name):

global age, height, pipe_diameter, density_slider

if variable_name == "age":

age = float(value)

elif variable_name == "height":

height = float(value)

elif variable_name == "pipe_diameter":

pipe_diameter = float(value)

elif variable_name == "density":

density_slider_value = float(value) / 100

simulate_spirometry(density_slider_value)

def start_simulation():

global volume, density_slider, age, height, pipe_diameter

volume = 0

39
fvc_values.clear()

fev1_values.clear()

simulate_spirometry(density_slider.get())

predicted_fev1 = calculate_predicted_fev1(age, height)

predicted_fvc = calculate_predicted_fvc(age, height)

predicted_ratio = calculate_predicted_ratio(age)

print("Measured FEV1:", volume)

print("Predicted FEV1:", predicted_fev1)

print("Predicted FVC:", predicted_fvc)

print("Predicted FEV1/FVC Ratio:", predicted_ratio)

print("patient Age:", age)

print("patient height in CM:", height)

print("spirometer pipe_diameter in Meter:", pipe_diameter)

grade = calculate_grade(volume, predicted_fev1, age)

print("Grade:", grade)

repeatability_grade_value = repeatability_grade(volume, predicted_fev1, age)

print("Repeatability Grade:", repeatability_grade_value)

perform_quality_control_ATS_ERS_standards_checks()

calculate_and_display_flow_rates()

40
def calculate_and_display_flow_rates():

pipe_area = calculate_pipe_area(pipe_diameter)

volumetric_flow_rate = calculate_volumetric_flow_rate(pipe_area)

mass_flow_rate = calculate_mass_flow_rate(volumetric_flow_rate, density_air)

mass_flow_rate_lbs = kg_to_lbs(mass_flow_rate)

print("Volumetric Flow Rate:", volumetric_flow_rate * liters_to_cubic_meters,


"m^3/s")

print("Mass Flow Rate:", mass_flow_rate, "kg/s")

print("Mass Flow Rate (lbs/s):", mass_flow_rate_lbs)

# GUI setup

def gui_setup():

global age, height, pipe_diameter, density_slider

root = tk.Tk()

root.title("Spirometry Simulation")

age_label = ttk.Label(root, text="Age:")

age_label.grid(row=0, column=0, padx=10, pady=10)

age_slider = ttk.Scale(root, from_=0, to=100, length=200, orient=tk.HORIZONTAL,


command=lambda value: update_variable(value, "age"))

age_slider.set(age)

age_slider.grid(row=0, column=1, padx=10, pady=10)

height_label = ttk.Label(root, text="Height:")

height_label.grid(row=1, column=0, padx=10, pady=10)

41
height_slider = ttk.Scale(root, from_=100, to=200, length=200,
orient=tk.HORIZONTAL, command=lambda value: update_variable(value, "height"))

height_slider.set(height)

height_slider.grid(row=1, column=1, padx=10, pady=10)

# Adjust the minimum and maximum values for the pipe diameter slider

min_pipe_diameter = 0.0 # 0 cm converted to meters

max_pipe_diameter = 0.025 # 2.5 cm converted to meters

diameter_label = ttk.Label(root, text="Pipe Diameter (m):")

diameter_label.grid(row=2, column=0, padx=10, pady=10)

diameter_slider = ttk.Scale(root, from_=min_pipe_diameter, to=max_pipe_diameter,


length=200, orient=tk.HORIZONTAL, command=lambda value: update_variable(value,
"pipe_diameter"))

diameter_slider.set(pipe_diameter)

diameter_slider.grid(row=2, column=1, padx=10, pady=10)

density_label = ttk.Label(root, text="Density:")

density_label.grid(row=3, column=0, padx=10, pady=10)

density_slider = ttk.Scale(root, from_=0, to=100, length=200,


orient=tk.HORIZONTAL, command=lambda value: update_variable(value, "density"))

density_slider.set(50)

density_slider.grid(row=3, column=1, padx=10, pady=10)

start_button = ttk.Button(root, text="Start", command=start_simulation)

start_button.grid(row=4, column=0, columnspan=2, pady=20)

42
# GUI setup

# Start GUI event loop

root.mainloop()

# Call the GUI setup function to start the simulation

gui_setup()

43

You might also like