SciELO - Scientific Electronic Library Online

vol.46 issue2Socio-demographic, psychiatric and legal characterisation of Colombian unimputable patients, 2000-2013,Cannabis: A cognitive illusion author indexsubject indexarticles search
Home Pagealphabetic serial listing  

Services on Demand




Related links

  • On index processCited by Google
  • Have no similar articlesSimilars in SciELO
  • On index processSimilars in Google


Revista Colombiana de Psiquiatría

Print version ISSN 0034-7450

rev.colomb.psiquiatr. vol.46 no.2 Bogotá Apr./June 2017 

Original article

Identifying sleep apnoea and hypopnoea episodes from respiratory polygraphy signals*

Identificación automática de episodios de SAHS utilizando seriales de poligrafía respiratoria

Dayana Lizethe Guzmán Sierra a  

Mariano Carreño León a  

Luz Helena Camargo Casallas a   **  

a Grupo de investigación Ingeniería y Nanotecnología para la vida, Facultad de Ingeniería, Universidad Distrital Francisco José de Caldas, Bogotá, Colombia



To design a diagnostic support system for sleep apnoea and hypopnoea syndrome (SAHS) using moving average based on knowledge, able to identify SAHS episodes from a respiratory polygraphy (RP) database.


An analysis was made of data obtained from a public database, that included the RP signals, nasobucal airflow, thoracoabdominal movement, and pulse oximetry of 23 patients between 28 and 68 years with suspected SAHS, and with a body mass index (BMI) from 25.1 to 42.5.


The identification and classification of episodes of apnoea and hypopnoea was obtained.


The algorithm designed identified episodes of SAHS using polygraphy signals, which by implementating in a graphical interface allows visualisation of onset, duration, type, oxygen saturation, and pulse oximetry of each episode, and can be used as a support tool for the diagnosis of sleep disorders.

Keywords: Polysomnography; Breathing; Apnoea; Sleep



Diseñar un sistema de apoyo diagnóstico para el síndrome de apneas-hipopneas del sueño (SAHS) utilizando conocimientos basados en media móvil, capaz de identificar episodios de SAHS a partir de una base de datos de poligrafía respiratoria (PR).


Se analizaron las señales de poligrafía respiratoria (flujo aéreo nasobucal, movimiento toracoabdominal y pulsioximetría) de 23 pacientes con sospecha de SAHS (edad, 28-68 años; índice de masa corporal, 25,1-42,5), obtenidas de una base de datos pública.

Resultados :

Se identificaron y se clasificaron episodios de apnea y hipopnea.


Se detectaron los episodios de SAHS utilizando señales de poligrafía respiratoria cuya implementación en una interfaz gráfica permite la visualización del inicio, la duración, el tipo, la saturación de oxígeno y la pulsioximetría de cada episodio, y se puede emplear como herramienta de apoyo al diagnóstico del trastorno del sueño.

Palabras clave: Polisomnografía; Respiración; Apnea; Sueño


Sleep is considered to be one of the necessary phases for the proper functioning of the body, which not only helps to repair the body at the end of the day, but is also associated with the regulation of neuronal processes and other systems, hence why sleep medicine is becoming increasingly important. Sleep disorders in a population are linked to decreased productivity, road traffic accidents,1 mental health problems and other types of illnesses, such as arterial hypertension, cerebrovascular disease, coronary disease and neurocognitive disease. 2

Research studies carried out by the American Academy of Sleep Medicine (AASM) indicate that approximately 35% of the US population suffers or has suffered from some form of sleep disorder in their lifetime.3 The most common nocturnal disorder is sleep apnoea-hypopnoea syndrome (SAHS).4 Apnoea is the cessation of the oronasal airflow for more than 10 seconds and, in hypopnoea, airflow is reduced by more than 50% of the baseline value, leading to an oxyhaemoglobin desaturation of 2-4%. Each episode of apnoea lasts for 20-30 s, although they can last for 2-3 min.5,6

Some studies indicate that SAHS affects 2% of women and 4% of men7; however, on considering patients between the ages of 30-60 years at random, up to 9% of women and 24% of men have been found to be affected.8

At present, the most commonly used method for diagnosing SAHS is polysomnography (PSG),6,9 which includes an electroencephalogram, electrocardiogram and submental electromyogram and measures of respiratory changes such as position changes, snoring, thoracoabdominal movement, pulse oximetry, oxygen saturation, oronasal airflow and electrocardiogram. However, this method is costly and very time-consuming, and the detailed analysis that must be performed by the specialist is complex.10 Various studies have shown that equipment that exclusively records respiratory variables can be used,11-16 thus reducing costs and waiting times, and facilitating the diagnosis of SAHS at sleep centres.14

The objective of this study is to design a diagnostic support system for SAHS using a moving average-based approach that is able to identify episodes from a respiratory polygraphy (RP) database.


The data were extracted from the Physionet database, which contains overnight polysomnograms (mean, 7 h) of 25 patients with suspected breathing-related sleep disorders.

The subjects from whom the data were obtained were randomly selected over a period of six months from among the patients of the St Vincent's University Hospital Sleep Disorders Clinic, in Dublin, and were aged between 28 and 68 years, with a body mass index (BMI) of 25.1-42.5 and an apnoea-hypopnoea index (AHI) of 1.7-90.9.

Moreover, the patients were deemed not to suffer from heart disease or autonomic dysfunction, and were not on medication capable of interfering with their heart rate.17 According to the Epworth sleepiness scale, 17 76% of the individuals presented mild to severe sleepiness.

RP recordings were obtained in the standard European data format (EDF) used for polysomnography (PSG) recordings, which identified each individual and specified the technical characteristics of the recording. The recordings were characterised, annotated by the specialist and in an open code -conditions that allowed them to be used for this project.

For the signal analysis, two recordings did not meet the inclusion criteria set for this study, and so the recordings of 23 subjects were used (19 men and 4 women). To analyse the signals, three main phases were proposed: signal preprocessing, processing and apnoea episode detection.

Fig. 1 shows a diagram of the general proposal for detecting episodes of SAHS, specifying the procedures considered for each stage.

Fig. 1 Block diagram of the proposed system. 


The American Academy of Sleep Medicine (AASM) classifies RP into four types. Type 1 is conventional PSG, monitored by a sleep laboratory technician (with at least 7 channels); type 2 is PSG performed with a portable device and is not monitored by a technician; type 3 corresponds to what we call RP, where breathing, thoracoabdominal effort and pulse oximetry are recorded (with a total of 4-7 channels); and type 4 corresponds to super-simplified studies with 1- or 2-channel devices (oximetry and/or breathing).18 For this study, airflow (oronasal airflow), respiratory effort (thoracoabdominal movement) and oxygen saturation (pulse oximetry) data were considered, which are recordings obtained by PSG that correspond to type 3 RP.

To view the RP recordings, non-commercial Polyman software was used, which is compatible with the EDF and facilitates PSG signal viewing.19 Segments were found that were eliminated based on the following conditions for each signal: Oronasal airflow, amplitude between -20 and 20l/min, with a dominant frequency of 0.2 Hz, reported for the breathing of one relaxed (sleeping) subject20; thoracoabdominal movement, the values of these signals are between 5 and -5; pulse oximetry, normal values of this signal are between 40 and 80 p/min; oxygen saturation, normal values are between 90% and 100%.

To eliminate high frequency noise and prevent information loss, a moving average filter was used, which is included in MATLAB® v. 7.1 2011 (MATrix LABoratory), an interactive system designed for matrix calculations that is primarily used in scientific and engineering analyses. The moving average filter is used to smooth the data for trend analysis, as described in Eq. (1):

where M is the number of windows to which the filter is applied, h(k) describes the filter applied and x[n - k] are the respiratory polygraphy signals.

RP signal processing

In order to process signals, the moving average was used by setting a 10 s window (80 points) that represents the minimum duration of an SAHS episode.

The moving average is an average of the values in an irregular series that moves from one extreme to the other, replacing these values with the average result in order to detect its trend.21 This average was obtained from the root mean square value (RMS) in each segment, as this provides information on the amplitude of the signal and facilitates the determination of the frequency variables, distance between peaks and form of each signal, which are important for detecting episodes of SAHS.

The RMS or root mean square value for a set of N values {x1, x2,..., xN} of a discrete x variable is determined by Eq. (2):

where N is the number of window elements and each of the elements.

The RMS value is proportional to the signal energy and is defined by Eq. (3):

where T is the temporal integration period and a is the immediate signal amplitude.22

A threshold was subsequently set in accordance with the criteria established by the consensus on SAHS episodes (Table 1) and a binary vector was generated where zero corresponds to the threshold value and 1 to the SAHS episode.

Table 1 Classification of sleep apnoea-hypopnoea syndrome episodes. 

Source : Pita and Pértegas.24

Fig. 2 Respiratory flow signal (deleted segment in red). 

Fig. 3 (A) Visualisation of RMS values in the respiratory flow signal; RMS values in red. (B) Enlargement. 

The start and end time was then determined, generating another vector with the start (1) and end (-1) times, taking into account the distance between peaks3 (Table 1).

SAHS detection

For the classification of the SAHS episodes, a comparison of abdominal and thoracic movements was performed, and the points at which these abdominal and thoracic movements incurred the same reductions were considered.

To assess the performance of the classification, sensitivity, specificity, precision (positive predictive values [PPV] and negative predictive values [NPV]24 were assessed with a view to checking the validity and safety of the algorithm. See Eqs. (4)-(7):

where VP is true positives; VN is true negatives; FP is false positives; and FN is false negatives.

Fig. 4 Possible episode of apnoea. Decrease in peripheral oxygen saturation (SpO2) (green), behaviour of flow signals and thoracoabdominal effort (red) and increase in cardiac pulse (yellow). 

Graphical interface

The graphical user interface was performed using the MATLAB® GUIDE programming environment (v. 7.12011). This environment facilitated the creation and implementation of simulation programmes with a user-friendly interface.


Signal preprocessing

A polysomnographic study takes 8 h and analyses 230,400 samples. Segments corresponding to artefacts at the start and end of the recording were deleted (as presented in Fig. 2). The signal is then filtered for the purpose of smoothing it and to eliminate noise without losing information.

SAHS episode detection

With the RMS value, determined after applying the moving average to oronasal airflow, thoracoabdominal movement and pulse oximetry signals, values proportional to the amplitude variation were detected. Fig. 3 shows a vector of RMS values.

The decrease in the RMS value of the oronasal airflow, thoracoabdominal movement and pulse oximetry signals facilitates the detection of SAHS episodes.

For the classification of apnoea, thoracoabdominal efforts <10% were considered, while hypopnoeas were defined as a vector of thoracoabdominal effort <70% and >10% (Fig. 4).

Barreiro et al.25 detected episodes of SAHS and compared the manual and automatic analysis of neurological and respiratory signals. With the automatic analysis, they reported sensitivity of 55%, PPV of 100% and NPV of 47%. Karandikary et al. also studied SAHS, but they do not address the problem of classifying the type of episode.

In this study, the evaluation was performed using four recordings in training, with the remaining samples used for the validation (19 recordings). The oronasal airflow, thoracoabdominal movement and pulse oximetry data enabled each and every SAHS episode reported in the specialist's notes to be detected, including episodes that fit the medical criteria established in the Spanish national consensus on apnoea and hypopnoea26 and which were not noted. In the classification of these episodes, sensitivity values of 62.33-96.17% were obtained, along with specificity of 38.19-88.69%, precision of 7.06-68.27% and NPV of 49.71-97.47%.

The user-friendly graphical interface implemented in this study enabled the selection of an RP recording, as well as the detection, analysis and classification of SAHS episodes. It may also be employed to train students, viewing signals in order to better understand the behaviour of SAHS episodes, and the interface thus becomes a tool that may be used to teach specialists undergoing training to improve their skills in detecting such episodes.

As reported by Álvarez et al., PSG studies are valued at approximately 179 euros (645,000 Colombian pesos), while the respiratory polygraph costs just 65 euros (234,000 Colombian pesos)27; in some cases, these costs do not include the patient's hospital stay, the salary of the technicians working at the hospital's sleep disorders unit nor the proportionate expenses of the fixed costs, which include facility depreciation costs, general maintenance costs and the costs of other devices within the sleep disorders unit, video cameras, monitors, etc., which are born directly by the patients and/or relatives. As such, the respiratory polygraph used in this study may reduce the costs and resources required in cases where access to costly methods such as the PSG is not possible or when travelling to centres with this equipment is not an option. Moreover, processing the signals with the implemented strategy takes around 30 s per patient, thereby reducing waiting times once the data have been acquired.

The strategy employed in this study would be more suitable for screening in the identification and classification of SAHS episodes in patients with suspicious symptoms, taking into account its low cost and the reduction in time for acquiring and assessing the data that may support the diagnosis; it also enables the duration of each episode and oxygen saturation to be established, which may provide the specialist with more information, and it can be performed in the patient's own home, generating a more comfortable environment with timely detection. In order to implement this strategy, an RP device, computer, software with the implemented algorithm and a trained general practitioner are required.


In this study, episodes of apnoea/hypopnoea were detected and automatically classified as mixed, central or obstructive as diagnostic support, using the moving average with respect to the RMS value and identifying the onset and duration of SAHS. A graphical interface was also designed which may be used for training purposes and to view SAHS signals. Future studies investigating the learning strategies of the machine that could aid classification should be conducted.


To Dr Diana María Tafur Guzmán, general practitioner at the Military University, for her contributions in assessing the software developed.


1. Garbarino S, Traversa F, Spigno F. Sleepiness, safety on the road and management of risk. G Ital Med Lav Ergon. 2012;34 3Suppl.:322-5. [ Links ]

2. Velayos J. Medicina del sueño. Enfoque multidisciplinario. Buenos Aires: Médica Panamericana; 2009.3 [ Links ]

3. Léger D, Poursain B, Neubauer D, Uchiyama M. An international survey of sleeping problems in the general population. Curr Med Res Opin. 2008;24:307-17. [ Links ]

4. Monserrat Canal JM. Síndrome de apnea del sueño. In: Farreras V, Rozman C, editors. Medicina interna. 13a ed. Madrid: Mosby-Doyma Libros; 1995. p. 772-7. [ Links ]

5. Fauci AS, Braunwuald E, Isselbacher KJ. Apnea delsueño. In: Wintrofe MM, Thorn W, Adams RD, Bennett IL, Braunwald E, Isselbacher KJ, editors. Harrison: principios de medicina interna. 14a ed. Madrid: McGraw-Hill Interamericana; 1998. p. 1683-6. [ Links ]

6. Kushida CA, Littner MR, Morgenthaler T, Alessi CA, Bailey D, Coleman J. Practice parameters for the indications for polysomnography and related procedures: an update for 2005. Sleep. 2005;28:499-521. [ Links ]

7. Young T, Palta M, Dempsey J, Skatrud J, Weber S, Badr S. The occurrence of sleep disordered breathing among middle aged adults. N Engl J Med. 1993;328:1230-5. [ Links ]

8. Aguirre C. Caracterización de pacientes adultos con diagnóstico de apnea del sueño. Colombia: Universidad Tecnológica de Pereira; 2012. Available in: [ Links ]

9. Durán-Cantolla J, Puertas-Cuesta FJ, Pin-Arboledas G, Santa María-Cano J, el Grupo Español de Sueño (GES). Documento de consenso nacional sobre el síndrome de apneas-hipopneas del sueño. Arch Bronconeumol. 2005;41:1-110. [ Links ]

10. Lloberes P, Durán J, Martinez MA, Marín JM, Ferrer A, Corral J, et al. Diagnóstico y tratamiento del síndrome de apneas-hipopneas del sueño. Arch Bronconeumol. 2011;47:143-56. [ Links ]

11. Flemons WW, Littner MR, Rowley JA, Gay P, Anderson WM, Hudgel DW, et al. Home diagnosis of sleep apnea: a systematic review of the literature. An evidence review cosponsored by the American Academy of Sleep Medicine, the American College of Chest Physicians, and the American Thoracic Society. Chest. 2003;124:1543-79. [ Links ]

12. Hudgel D, Anderson WM, Boehlecke A, Claman D, Goldberg R, Gottlieb DJ, et al. Portable Monitoring Task Force of the American Academy of Sleep Medicine. Clinical guidelines for the use of unattended portable monitors in the diagnosis of obstructive sleep apnea in adult patients. J Clin Sleep Med. 2007;3:737-47. [ Links ]

13. Decision memo for continuous positive airway pressure (CPAP) therapy for obstructive sleep apnea (OSA) (CAG-00093R2). Centers for Medicare & Medicaid Services; 2008 (from2=viewdecisionmemo.asp&id=204&). [ Links ]

14. Terán Santos J. Acreditaciones en Neumología. Unidades de sueño. Arch Bronconeumol. 2009;45:263-5. [ Links ]

15. Durán-Cantolla J, Aizpuru F, Egea C, Pedraza N, Rubio R, González C, et al. Validez de un sistema super simplificado (ApneaLinkTM) para el diagnóstico de pacientes con sospecha clínica de síndrome de apneas-hipopneas del sueño (SAHS). Resultados preliminares. (Abstract). Arch Bronconeumol. 2009;45 Suppl.:248. [ Links ]

16. Ng SS, Chan TO, To KW, Ngai J, Tung A, Ko FW, et al. Validation of a portable recording device (ApneaLink) for identifying patients with suspected obstructive sleep apnea syndrome (OSAS). Intern Med J. 2009;39:757-62. [ Links ]

17. Goldberger AL, Amaral LAN, Glass L, Hausdorff JM, Ivanov PCh, Mark RG, et al. PhysioBank, PhysioToolkit, and PhysioNet: components of a new research resource for complex physiologic signals. Circulation. 2000;101:e215-20. [ Links ]

18. Ferber R, Millman R, Coppola M, Fleetham J, Murray CF, Iber C, et al. Portable recording in the assessment of obstructive sleep apnea. Sleep 1994;17:378-92. [ Links ]

19. Kemp B, Roessen M. Polyman: a free(ing) viewer for standard EDF(+) recordings and scorings. In: Ruijgt GSF, De Boer T, Van Kasteel V, van Luijtelaar G, Overeem S, editors. Sleep-wake research in the Netherlands, 18. Amsterdam: Dutch Soc Sleep-Wake Res; 2007. p. 71-3. [ Links ]

20. Gómez J. Equipo de medición y visualización del flujo aéreo oronasal. Manizales: Universidad Nacional de Colombia; 1996. [ Links ]

21. Aguirre A. Introducción al tratamiento de series temporales: aplicación a las ciencias de la salud. Madrid: Díaz de Santos; 1994. [ Links ]

22. Bartí R. Acústica medioambiental. Vol. 1. Club Universitario; 2010. [ Links ]

23. Puerta F, Pin G, Santa María J, Duran J, Grupo Español de Sueño (GES). Consenso nacional sobre el Síndrome de Apneas Hipopneas del sueño (SAHS). Definición y concepto, fisiopatología, clínica y exploración del SAHS. Arch Bronconeumol. 2005;41 Suppl. 4:12-29. [ Links ]

24. Pita F, Pértegas S. Pruebas diagnósticas: sensibilidad y especificidad. Unidad de Epidemiología Clínica y Bioestadística. Complexo Hospitalario Universitario de A Coruña (España). Aten Prim. 2003;10:120-4. [ Links ]

25. Barreiro B, Badosa G, Quintana S, Esteban L, Heredia J. Comparación entre el análisis automático y manual de la PSG convencional en el diagnóstico del síndrome de apnea-hipopnea obstructiva del sueño. 2009. [ Links ]

26. Sánchez D. Procesado y transmisión de señales biomédicas para el diagnóstico de trastornos y enfermedades del sueño [tesis doctoral]. Cádiz: Universidad de Cádiz; 2008. [ Links ]

27. Álvarez A, Terán S, Cordero G, Rodríguez L, Viejo J, Marañon A. Reliability of home respiratory polygraphy for the diagnosis of sleep apnea-hypopnea syndrome: analysis of costs. Arch Bronconeumol. 2008;44:22-8. [ Links ]

* Please cite this article as: Guzmán Sierra DL, Carreno León M, Camargo Casallas LH. Identificación automática de episodios de SAHS utilizando señales de poligrafía respiratoria. Rev Colomb Psiquiat. 2017;46:88-94.

Ethical disclosures

Protection of human and animal subjects. The authors declare that no experiments were performed on humans or animals for this study.

Confidentiality of data. The authors declare that no patient data appear in this article.

Right to privacy and informed consent. The authors declare that no patient data appear in this article.

Conflicts of interest The authors declare that they have no conflicts of interest.

Received: October 28, 2015; Accepted: April 05, 2016

** Corresponding author. E-mail address: (L.H. Camargo Casallas).

Creative Commons License This is an open-access article distributed under the terms of the Creative Commons Attribution License