# Unobtrusive Respiratory Flow Monitoring Using a Thermopile Array: A Feasibility Study
## 2 Materials and Methods
### Method
#### 2.2.2 Pixel Selection and Pixel Update  
The pixel containing the respiratory information should be identified. An approach was proposed in [20] where an empirical metric, SQI, was evaluated based on four features of the spectrum. The SQI is dependent, however, on empirically-chosen thresholds.  
The method to identify the pixel with the strongest respiratory signal proposed in this work also operates in the Fourier domain. For each pixel, the time-domain samples were Hanning-windowed, then transformed through a 1D FFT, and the value of the highest peak in the normalized magnitude spectrum was used as a strength indicator. Consequently, an 8\(\times\)8 array of strength indicators was obtained, and the maximum element in this array was used to identify the pixel containing the respiratory signal.  
Formally: let \(x_{i}(nT_{s})\) be the filtered, Hanning-windowed time-domain signal for the \(j^{\text{th}}\) window where the spatial mean has been removed; \(i\) is an index running through all 8\(\times\)8 pixels in the array, i.e., from 1-64, and the index \(n=0+(j-1),1+(j-1),...,N+(j-1)\) depends on the current window \(j\); the number of samples per window was \(N=300\), and the sampling time was \(T_{s}=0.1\,\text{s}\). \(Y_{i}(f_{k})\) is the spectrum of the \(i^{\text{th}}\) pre-processed time-domain signal \(x_{i}(nT_{s})\) and \(\mid Y_{i}(f_{k})\mid\) its magnitude, with \(f_{k}=\frac{k}{NI_{s}}\,\text{Hz}\) and \(k=0,1,...,\frac{N}{2}-1\). We define the height of the normalized spectrum's peak as:  
\[m_{i}=\frac{\max_{f_{min}\leq f_{k}\leq f_{max}}(\mid Y_{i}(f_{k})\mid)}{\sqrt {\frac{f_{max}}{f_{k}=f_{min}}\mid Y_{i}(f_{k})\mid^{2}}}\,, \tag{1}\]  
where \(f_{min}=0.167\,\text{Hz}\) and \(f_{max}=0.667\,\text{Hz}\), i.e., boundaries of the respiration band.  
We assumed the respiration signal to be pseudo-periodic; thus, the spectrum would contain a peak. Noise, on the other hand, would show a relatively flat spectrum, as illustrated in Figure 2. In our algorithm, we interpreted a higher peak in the normalized spectrum as an increased likelihood that the pixel would contain the respiratory signal, and we only used a single pixel in the array, identified with index \(i_{R}\) defined as:  
\[i_{R}=\operatorname*{arg\,max}_{i}(\mathbf{M}), \tag{2}\]  
where \(\mathbf{M}\) is defined as:  
\[\mathbf{M}=[m_{1}\ m_{2}\...\ m_{64}]. \tag{3}\]The pixel needed to be selected for each window \(j\). For the first \(w\) windows, the position was chosen by selecting the pixel with the highest peak in the normalized spectrum. The successive positions were, instead, dependent on the preceding \(w\) positions, limiting the search space of the following pixels. This procedure was intended to prevent rapid pixel-switching, which could deteriorate the computed spectra, whereas the scenario (substantially static subject) did not require rapid adaptation. A mask was created based on the \(w\) preceding positions that allowed the following ones to move only to an adjacent position. The value \(w\) was fixed empirically to 10.