# Algorithm for Automatic Peak Detection and Quantification for GC-IMS Spectra

Jorge M. Fernandes, Valentina Vassilenko, Paulo Santos

► To cite this version:

Jorge M. Fernandes, Valentina Vassilenko, Paulo Santos. Algorithm for Automatic Peak Detection and Quantification for GC-IMS Spectra. 11th Doctoral Conference on Computing, Electrical and Industrial Systems (DoCEIS), Jul 2020, Costa de Caparica, Portugal. pp.369-377, 10.1007/978-3-030-45124-0_35. hal-03741534

HAL Id: hal-03741534

https://inria.hal.science/hal-03741534v1

Submitted on 1 Aug 2022

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons CC BY 4.0 - Attribution - International License
<figure><img src="image_2.png" /></figure>

ifip

International Federation for Information Processing

This document is the original author manuscript of a paper submitted to an IFIP
conference proceedings or other IFIP publication by Springer Nature. As such, there
may be some differences in the official published version of the paper. Such
differences, if any, are usually due to reformatting during preparation for publication or
minor corrections made by the author(s) during final proofreading of the publication
manuscript.
# Algorithm for Automatic Peak Detection and Quantification for GC-IMS Spectra

Jorge M. Fernandes¹,², Valentina Vassilenko¹,² and Paulo H. Santos¹,²

¹Laboratory for Instrumentation, Biomedical Engineering and Radiation Physics (LibPhys-UNL), NOVA School of Science and Technology, NOVA University of Lisbon, Campus FCT-UNL, 2896-516, Caparica, Portugal

²NMT, S.A., Edificio Madan Parque, Rua dos Inventores, 2825-182, Caparica, Portugal
j.manuel@campus.fct.unl.pt

**Abstract.** Ion Mobility Spectrometry with a coupled Gas Chromatography (GC-IMS) pre-separation is an analytical technique suitable for detection of volatile organic compounds (VOCs) in complex sample matrices (indoor & outdoor air, breath samples, food, beverages, microbial cultures, etc.) Its outstanding sensitivity allows in-situ analysis of a very large range of organic compounds at low concentrations with detection limits typically in the low ppb or even ppt level. Automatic detection and quantification of VOCs through GC-IMS spectra is challenging and the lack of computational methodologies able to detect, quantify and deconvolute overlapped peaks are still scarce and diminished. In this work we present a preliminary algorithm and still in development for automatically identify and quantify VOC peaks directly from the spectra matrix with an established threshold, a noise filter, Reactive Ion Peak (RIP) measurements. Herein, proposed tools may be very useful for quick automatic detection and quantification of compounds in GC-IMS spectra.

**Keywords** Ion Mobility Spectrometry (IMS); Gas Chromatography (GC); Volatile Organic Compounds (VOCs); Peak Detection; Quantification; Automation; Algorithm.

## 1. Introduction

Ion mobility spectrometry (IMS) was developed in last 50 years as a method for detecting and identifying trace levels (ppb$_v$ and ppt$_v$ ranges) of semi-volatile and volatile organic compounds (VOCs), mainly in security and military venues. IMS working principle is based on mobility determination in electric fields of gas phase ions in a sample from a large array of matrices [1].

Modern ion mobility analytical spectrometers were commercially available only in the late 1970s due to military and governmental control of the technology. Thus, the period afterwards saw a boom in intensive substance characterization by ion mobility spectrometry [2]. This analytical technique was initially known by other terms (e.g. plasma chromatography, gaseous electrophoresis or ion chromatography), however the
working principle of current and modern instrumentation remained [0, 1, 3, 4]. Nonetheless, engineering and technological improvements have opened numerous applications and uses of IMS such as the development of portable spectrometers for field use [1, 2, 4]. General IMS operational principles are summarized in Fig. 1 and include:

* Transference of sample as vapor into an ion source (radioactive sources: ³H, ⁶³Ni; Non-radioactive sources: corona discharges, electrospray or lasers);

* Production of ions from neutral sample molecules at atmospheric pressure

* Injection of an ion swarm into the drift region;

* Determination of drift velocities of ions under the influence of an electric field in the drift region and in a supporting atmosphere, the drift gas;

* Detection of ions and electrical signal storage or display, with or without automated analysis of the result.

<figure><img src="image_3.png" /><figcaption>Fig. 1. Ion mobility spectrometry operation summary in a bidirectional flow system [1].</figcaption></figure>

Ions movement speed, or the drift velocity ($v_d$) dissipated by collisions with neutral molecules of the supporting gas atmosphere, is proportional to the strength of the electric field (E) with the constant of proportionality being the ions mobility (K) [2, 5]. Thermalized ions typically travel with a speed of approximately 2 m s⁻¹ and traverses the drift region with lengths of 5 to 15 cm in a few milliseconds (2 to 15 ms). Ion drift time correlates with ions' mass, charge and collision cross section, which includes structural parameters (physical size and shape) and the electronic factors describing the ion-neutral interaction forces. Therefore, different drift velocities are attained for ions with different structure (shape) and mass, establishing the basis for ions separation in IMS [5].

Engineering advances provide to IMS-based methods a major advantage in analytical application due to the analyser's low size, weight and power consumption, making this instrumentation perfectly suitable for on-site or in-field monitoring, contrary to almost all analytical tools [1, 6, 7]. IMS analysers exhibit fast response and reliable performance (high sensitivity, recording of ion mobility spectra) and can be used in ambient pressure, with nitrogen, helium and air as drift gas.
Several IMS devices have been employed in airports worldwide for chemical-weapons monitoring and explosive detection in hand-held or bench analyser formats [8]. Applications in civilian fields are more diverse and include investigations with complex, humid gas-phase biological samples [6, 9], health and medical diagnostics [10], food quality and safety [11], as well as in the industrial process control [12], petrochemical, environmental analysis [13, 14] and air quality assessment [15, 16, 17]. However, in complex matrix analysis, a single IMS device has limitations, such as clustering forming in the ionisation region, thus making identification of the ions difficult or even impossible. Therefore, to solve this limitation and increase the selectivity, ion mobility spectrometry is usually coupled to the one of pre-separation method: Gas-Chromatographic column (GC), Multi-Capillary Column (MCC) or, not so frequently, Liquid-Chromatography (LC) [18].

## 2. Contributions to Life Improvement

Recent successful CG-IMS technology applications to environmental analysis, medical diagnostics, process control, air quality control, food quality control [19], biomolecules characterization and detection of biomarkers in bacteria [20] show a clear need for tools that allow quick and precise spectra processing.

Experimental research data derived from GC-IMS is represented by 3D graphs, also called heatmaps or spectra, where each analyte is given by retention and drift time for qualitative analysis, and intensity for quantitative analysis. Currently, software availability for automatically detect and process analyte peaks from 3D GC-IMS spectra is scarce, limited or functional for a single instrumentation type. Thus, a generalized automatic peak detection, identification and quantification algorithm will improve, accelerate and enrich IMS instrumentation when employed in the numerous life science fields previously mentioned.

## 3. Materials and Methods

### 3.1 Input Data Format

Ion mobility spectrometers produce data in 2D graphs format in which the x and y axis are respectively, drift time ($t_d$) and intensity (Fig. 2). Drift time is in milliseconds (ms) and it's usually expressed in relation to the Reactive Ion Peak (RIP) drift time (RIPrel). RIP refers to ionized ions of the drift gas and corresponds to the quantity of ions available to ionize analytes. RIP drift time varies with conditions such as drift gas type and humidity, and analytes' RIP relative drift times are employed to standardize drift times allowing their identification and peak comparison of analytes between measurements.

When IMS is coupled with pre-separation techniques, as CG or LC, experimental data obtained changes from 2D graphs to 3D plots, heatmaps, which often are called spectrum (singular) and spectra (plural), as it can be seen in the Fig. 2. Spectra in 3D
format contains data with three variable: (a) retention time ($t_r$) of the gas or liquid chromatographic column, (b) drift time ($t_d$) for the separation of analytes in the drift tube and (c) intensity (I) detected in a faraday plate at the end of the drift tube. Retention time is expressed in seconds, drift time in relation to the RIP and intensity in volts. A more detailed description can be found elsewhere [21].

IMS devices typically have their proprietary software for signal processing, saving measurements files and processing them. The spectra selected for the development of the algorithm to automatically detect and quantify peaks derived from a GC-IMS device, commercially available from G.A.S. Dortmund (*Gesellschaft für analytische Sensorsysteme*) sold as BreahSpec®. The software Laboratory Analyser Viewer (LAV) was provided along the device and can load the output files of the GC-IMS that come in a .mea file format. The software represents the *mea* file data in a heatmap, allows the definition of peak areas for quantification and extraction of drift and retentions times, management of measurements projects (reading several *mea* files in simultaneous)

<figure><img src="image_4.png" /><figcaption>**Fig. 2.** Single IMS or 2D spectrum (right) and 3D spectrum or heatmap examples (left) (spectra processed and obtained from LAV of BreathSpec (GC-IMS) measurements).</figcaption></figure>

among many other features. *Mea* files can be extracted into a CSV format file, containing three degrees of information.

Output data of a single IMS measurement, 2D spectrum, is a vector $S = (z_0, z_1, ..., z_n)$ of signal intensities $z_i$ measured in equidistant time point $dt_i$, $i \in \{1...N\}$. If a pre-separation technique is coupled to an IMS (GC or LC), an additional dimension is provided in the 3D spectrum, the retention time. Therefore GC-IMS data become a series of R one dimensional IMS spectra recorded at equidistant retention time point $rt_k$, $k \in \{1...R\}$. Such data is represented in the mathematical matrix by exporting a measurement file (*mea*) with LAV, which adds additional information in text ($i_{textual}$) into a CSV file as simplified below.
$$i_{textual} = \begin{bmatrix} \text{machine} & \dots & \text{gas}_{\text{drift}} & \dots & \dots & \text{Timestamp} \\ \text{units} & \dots & \dots & \dots & \dots & \text{kHz} & \text{°C} \\ \text{data} & \dots & \text{Air} & \dots & \text{serial} & 2019 & \dots \\ \dots & & & & \text{blank line} & \dots & \dots \\ \#\text{specnum} & & \text{RetTime [s]} & / & \text{Drift time [ms]} & \dots & \dots \end{bmatrix} \quad (1)$$

$$M_{ims} = \begin{bmatrix} Z_{11} & \dots & Z_{1n} \\ \vdots & \ddots & \vdots \\ Z_{1R} & \dots & Z_{nR} \end{bmatrix} \quad (2)$$

Exported CSV files, employed in the developed algorithm, include all available information from *mea* files and are characterized by a 5-line header containing device's mechanical and analytical textual information followed by a mathematical matrix.

## 3.2 Coding Language and Library

The algorithm was developed in Python, an open-source coding language, version 3.7 and, additionally, the libraries and/or functions were imported and include: *scikit-image* algorithms collection for image processing, *scipy.ndimage*, multi-dimensional image processing, *pandas* 0.25.3, Python Data Analysis Library, *mathplotlib* 3.1.1, Python 2D plotting library, *NumPy*, fundamental package for scientific computing and *operator* a standard operators as functions.

## 4. Results and Discussion

Developed algorithm is divided into four phases, (i) reading textual data, (ii) IMS matrix (spectra) processing, (iii) automatic peak detection and (iv) peak filtering and quantification. The algorithm uses *pandas* to read the csv file where all the textual and numerical information is contained.

(i) *Reading textual data:* this phase comprehends reading and printing of data relevant contained in the 5-line header. Useful information extracted in this phase includes, name and date of the file, machine type used, its serial number and GC column information. Textual information is printed after adding a line for the file format and origin. An example is presented below:

<table><tr><td>FILE ORIGIN:</td><td>LAV conversion</td></tr><tr><td>FILE FORMAT:</td><td>CSV DATA</td></tr><tr><td>FILE NAME:</td><td>190410_133432_1.csv</td></tr><tr><td>DATE:</td><td>2019 04 10</td></tr><tr><td>TIME:</td><td>13 34 32</td></tr><tr><td>SAMPLE:</td><td></td></tr><tr><td>Machine type :</td><td>BreathSpec®</td></tr><tr><td>Machine serial :</td><td>3G1-00074</td></tr><tr><td>GC Column :</td><td>MXT-200. 30m X 0.53mm ID</td></tr></table>

Supplementary information can be included in this phase, e.g. retention flow variation chart showing carrier gas flow changes the analysed measured. Additional
textual information can easily be tailored to each user's preference. Herein is shown
only the most important information as an example.

(ii) *IMS matrix (spectra) processing*: conducted after reading the csv file, and includes RIP automated detection, without showing RIP intensity or losing any peaks' information. Such processing is performed by detecting maximum intensity values in the mathematical matrix first line. Since recording is always started before any analyte is injected into the drift tube, the first line contains solely information about intensity from the drift and carrier gas without any sample. However, RIP is contained in a drift time interval and, to detect this interval or window, a simple idea is implemented in the algorithm. RIP is defined and identified as the number of columns in the first line that contain intensity above, 0.280 volts and 0.100 volts prior (left) and posteriorly (right) of the RIP maximum, respectively. Values before and after the RIP are not equal, due to the drift and carrier gas humidity influence. All matrix portions previously fragmented were correctly reconstructed by *matplotlib* functions (as done by LAV).

(iii) *Automatic peak detection* is achieved by applying a module from *skimage* know as measure, *skimage.measure.find_contours*(array, level). By finding iso-valued level of the IMS matrix (or above a threshold), clusters concerning intensity peaks were found, contoured and marked. However, since IMS spectra regularly show low intensity regions with the same intensity value, "noise", *skimage* module outputs a high number of regions which are not to be considered as peaks (Fig. 3). Hence, the algorithm was able to detect and mark matrix regions with a threshold-value above 0.150 volts, set for *skimage level*, and account the total number of contours, however this value did not have a direct correspondence with the effective total number of peaks.

<figure><img src="image_5.png" /><figcaption>**Fig. 3.** Algorithm detected peaks before (left) and after using a filtering method (right) marked by dashed lines and labelled with number in a grey square. Y-axis represents the retention time in seconds and the x-axis the drift time with the RIP position as zero.</figcaption></figure>

(iv) *Peak filtering and quantification*: a simple tactic was employed to filter “noise” regions (or ineffective peaks) from the peaks found by the *skimage measure* module. Matrix maximum and minimum values were obtained for each region with the module
skimage.measure, and if the difference between those values was lower or equal to, a defined threshold of 0.04 such region would not be classified as a peak. This threshold was defined based on observed values for general noise regions and peaks nonetheless this value can be adjusted by the user in accordance to its study targets.

Once the noise filter was applied to the detection algorithm, results enabled the recognition of the effective (real) peaks of the spectra and allowed to estimate peak intensity. Such estimation was executed by summing all the matrix values inside the peak areas delimited previously. Furthermore, the matrix index for the maximum value of each detected peak was obtained with the intention of using it for peak identification based on a database of drift and retention times.

**5. Conclusions and Future Work**

The developed algorithm was able to read a csv file directly exported from the LAV software; a type of software used in ion mobility spectrometers. From csv files, the algorithm interpreted and separated text information and spectral matrix. A graphical representation was correctly performed from the reconstruction of the matrix values and peak detection was achieved by applying a *skimage* module. To reduce spectral noise, a filter was applied resulting in the detection and isolation of relevant peaks. Furthermore, specific maximum and total intensity of peaks were found and calculated respectively.

Aiming to apply the present algorithm in all kind of IMS spectra, additional functions or tools are planned for future iterations. For instance, the deconvolution of potential overlapping peaks, a major issue in IMS spectra, is intended to be solved with the application of adjusted Gaussian functions. With this, the algorithm will be able to automatically detect and quantify all peaks which could later be cross-checked with IMS drift time libraries for compound identification.

**Acknowledgments.** The authors would like to thank the Fundação para a Ciência e Tecnologia (FCT, Portugal) and NMT, S.A. for co-financing the PhD grants PD/BDE/114550/2016 and PD/BDE/130204/2017 of the Doctoral NOVA I4H Program.

**References**

1. H. Borsdorf and G. A. Eiceman, "Ion Mobility Spectrometry: Principles and Applications," *Ap. Spect. Reviews*, vol. 41, no. 4, pp. 323-375, 2006 Aug 22.

2. R. Cumeras, E. Figueras, C. E. Davis and J. I. Baumbach, "Review on Ion Mobility Spectrometry. Part 1: Current Instrumentation," vol. 140(5): 1376-1390., 2015 Mar 7.

3. A. B. Kanu and H. H. Hill Jr., "Ion mobility spectrometry detection for gas chromatography," *Journal of Chromatography A*, pp. 12-27, 2008.
4. R. H. S. Louis, H. H. Hill Jr. and G. A. Eiceman, "Ion Mobility Spectrometry in Analytical Chemistry," *Critical Reviews in Analytical Chemistry*, pp. 321-355, 1990.

5. V. Gabelica and E. Marklund, "Fundamentals of ion mobility spectrometry," *Current Opinion in Chemical Biology*, vol. 42, pp. 51-59, 2018.

6. H. Borsdorf, T. Mayer, M. Zarejoushe and G. A. Eiceman, "Recent Developments in Ion Mobility Spectrometry," *Ap. Spect. Reviews*, vol. 46, no. 6, pp. 472-521, 2011.

7. G. Hopfgartner, "Current developments in ion mobility spectrometry.," *Anal Bioanal Chem.*, vol. 411, no. 24, 2019 Sep.

8. R. G. Ewing, D. A. Atkinson, G. A. Eiceman and G. J. Ewing, "A critical review of ion mobility spectrometry for the detection of explosives and explosive related compounds," *Talanta*, pp. 515-529, 2001.

9. A. T. Kirk, M. Allers, P. Cochems, J. Langejuergen and S. Zimmermann, "A compact high resolution ion mobility spectrometer for fast trace gas analysis," *Analyst*, pp. 5159-5504, 2013.

10. C. D. Chouinard, M. S. Wei, C. R. Beekman, R. H. Kemperman and R. A. Yost, "Ion Mobility in Clinical Analysis: Current Progress and Future Perspectives," *Vols. 62 (1) 124-133;*, 2016 Jan.

11. Z. Karpas, "Applications of ion mobility spectrometry (IMS) in the field of foodomics," *Food Res. Int.*, vol. 54, no. 1, p. 1146-1151, 2013.

12. J. I. Baumbach, "Process analysis using ion mobility spectrometry.," *Vols. 384(5):1059-70*, 2006 Mar.

13. T. Salthammer, *Organic Indoor Air Pollutants: Occurence, Measurement, Evaluation* (1st edition), Wiley-VCH, 1999.

14. D. Gallart-Mateu, S. Armenta and M. de la Guardia, "Indoor and outdoor determination of pesticides in air by ion mobility spectrometry," *Talanta*, pp. 632-639, 2016.

15. M. Śmiełowska, M. Marć and B. Zabiegala, "Indoor air quality in public utility environments - a review," *Environmental Science and Pollution Research*, pp. 11166-11176, 2017.

16. W. Vautz, V. Ruszany, S. Sielemann and J. Baumbach, "Sensitive ion mobility spectrometry of humid ambient air using 10.6 eV UV-IMS," *Int. J. Ion Mobility Spectrom.*, pp. 3-8, 2004.

17. V. Fetter, V. Vassilenko, J. Fernandes, L. Moukhamedieva and O. Orlov, "Validation of analytical instrumentation for continuous online monitoring of large spectra of VOCs in closed habitat during simulation of space flight," in *Proceedings of 69th International Astronautical Congress*, Bremen, Germany, 2018.

18. W. Vautz, J. Franzke, S. Zampolli, I. Elmi and S. Liedtke, "On the potential of ion mobility spectrometry coupled to GC pre-separation and A tutorial," *Analytica Chimica Acta*, vol. 1024, pp. 52-64, 2018.

19. C. Espalha, J. Fernandes, M. Diniz and V. Vassilenko, "Fast and Direct Detection of Biogenic Amines in Fish by GC-IMS Technology," 2019.

20. M. Gonçalves, J. Fernandes, V. Fetter, M. Diniz and V. Vassilenko, "Novel methodology for quick detection of bacterial metabolites," 2019.