• No results found

Data pre-processing

3.3 Experiment

3.3.3 Data pre-processing

Different pre-processing steps were carried out on the collected spectra before further analysis, in order to enhance the useful features in the spectra, suppress noise, and restrict the wavelength range to include only valid information. The processing routines were implemented in MatlabTM, and involved the following steps:

 Filtering

 De-trending

 Amplitude translation

 Normalization 3.3.3.1 Filtering

The first step involved filtering the raw spectra to improve its signal-to-noise ratio. This was a key step to enable subsequent extraction of useful chemical information from the spectra, especially when working with exceedingly low (up to 10 times lower) spectral amplitude signals for chemicals hidden behind fabric layers.

The kind of filter employed for the purpose was a Savitzky-Golay FIR smoothing filter. This filter, also known as a digital smoothing polynomial filter or least-squares smoothing filter, is typically used to smooth out a noisy signal whose frequency span (without noise) is large. As such, it is deemed particularly suitable for filtering spectroscopic data [9]. In this type of application, this filter performs much better than a standard averaging FIR filter, which tends to filter out a significant portion of the signal's high frequency content along with the noise. Conversely, although a Savitzky- Golay filter is more effective at preserving the pertinent high frequency components of the signal, it is less successful than a standard averaging FIR filter at rejecting noise. In this context, a Savitzky-Golay filter may be regarded as optimal in the sense that it minimizes the least square error in fitting a polynomial to frames of noisy data.

The filter used in this case comprised local 2nd-degree polynomial regression on a moving frame of 15 or 7 spectral values, with the median value of each frame replaced with the value of the corresponding polynomial evaluated at that point. A larger frame size was used for granular solids (15) than aqueous solutions (7), to allow more aggressive noise cancellation in the spectra of solids (at the cost of losing some high frequency spectral peaks) while preserving sharp peaks in the relatively less noisy spectra of the solutions.

3.3.3.2 De-trending

Each spectral reading taken during this study potentially incorporated a unique baseline shift due to the different scattering properties of the samples and/ or small angular variations in the relative positions of chemical cells, fabric samples and the reference

PTFE specimen. Such factors were understood to influence the spatial distribution of wavelengths in the diffuse-reflected signal, in turn affecting transmission through the optical fibre cable connected to the detector, as the refractive index of the optical fibre core (silica), and hence its acceptance angle, was wavelength-dependent. The resulting distortion in the spectral baseline was more pronounced in the spectra of solids, presumably due to greater scattering of the interrogating signal by these samples.

With the distribution of the diffuse reflected signal thus influenced by multiple factors, it was observed that the resulting spectral baseline shift could be closely approximated by 1st or 2nd degree polynomial curves. Thus, the spectra could be regressed in a least squares sense to fit a polynomial݌(ݔ)of the form:

݌(ݔ) =݌ଵݔ௡ +݌ଶݔ௡ିଵ+ ⋯ +݌௡ݔ+݌

௡ାଵ (3.2)

where ݊, the degree of the polynomial, was set to either 2 or 1, and ݔrepresented the wavelength channels (independent variables). Having thus obtained the coefficients (݌…),݌(ݔ)was evaluated for all wavelength channelsݔ:

ݕ=݌(ݔ) (3.3)

The vectorݕwas then used to calculate the de-trended spectra [10]:

ܵௗ = ܵ−ݕ (3.4)

whereܵ andܵwere the de-trended and the original spectra respectively.

An illustration this process, using filtered absorbance spectra of white polyester fabric recorded with two different reference levels, is given in Figure 3.4. As seen in Figure 3.4(a), the same absorption peaks occur in both cases, confirming the origin of these peaks in the polyester sample. However, the baseline shift, dictated by the pertinent reference levels, is different in each case and can be approximated with least squares regression as shown. These regression functions are then used in (3.3) and (3.4) to obtain the de-trended spectra shown in Figure 3.4(b). With the artificial baselines thus removed and the spectra zero-centred, this demonstrates the effectiveness of this technique in enhancing the spectral features and facilitating subsequent comparisons amongst spectra.

(a)

(b) Figure 3.4 – Absorbance spectra of white polyester fabric sample, recorded with two different

references. (a) 2nddegree polynomial functions that fit the spectra in a least squares sense. (b) Spectra in (a) after de-trending, illustrating same spectral features in the two cases.

The algorithm was mainly used to de-trend the spectra of solid chemicals. In the case of liquids, weaker scattering generally amounted to a constant DC offset in the baseline, which was eliminated as explained in Section 3.3.3.4.

3.3.3.3 Wavelength range selection

The spectrometer used in this study (see Table 3.1) had a default wavelength range of 854 – 2,620 nm. However, the range used for spectral analysis needed to be curtailed in accordance with the sensitivity of the spectrometer’s sensor array. As seen in the spectral response curve of the spectrometer (marked NIR256-2.1) in Figure 3.5 [11], the sensitivity dropped sharply between 2,100 – 2,200 nm. Accordingly, the upper range limit for all subsequent analysis was set at 2,000 nm.

In addition to the above, the nature of the spectra collected with liquid samples further restricted the useable wavelength range. This resulted from exceptionally strong absorption due to the first overtone of water (1,450 nm) [6], which typically saturated

A b s o rb a n c e (O D ) A b s o rb a n c e (O D ) λ (nm)

the spectra in the 1,400 – 1,800 nm wavelength range. An illustration of this phenomenon is given in Figure 3.6(a), where the spectra of water and ethanol are seen to saturate in the said range, irrespective of the contents or concentration of sample solutions.

Figure 3.5 – Spectral response curve of spectrometer (marked NIR256-2.1) [11]

In order to verify the origin of this saturation, a number of spectral readings of water were taken in glass cells of different sizes, thus varying the optical path length ݈in equation (3.1). The results are shown in Figure 3.6(b). As seen, the first overtone at 1,450 nm is well-defined for optical paths shorter than 1 mm, with spectral saturation progressively setting in at longer path lengths. As all subsequent experiments were conducted using chemical cells with a width of 10 mm (ref. Section 3.3.1.2), which corresponded to a minimum optical path length of 20 mm in diffuse reflectance for liquid samples, the upper wavelength limit for all liquid spectra was set at 1,350 nm.

3.3.3.4 Amplitude translation

This technique was used to correct the baseline shift in the spectra of chemicals in solution form. In this case, the relatively low repeatability error, arising from factors such as minor variations in the temperature of the sensor and positioning of the clear sample solutions, introduced relatively less baseline distortion as compared with granular solids. This typically showed up as a nearly constant amplitude offset (positive or negative) across all wavelength channels. As the spectra of liquids were known to

removed by translating the spectra along the amplitude axis so as to have a constant absorbance value at a specific wavelength channel (1 600 nm) in the saturated region. Finally, with this DC shift implemented, the saturated regions were discarded as above. The process generally produced spectra that were arranged in accordance with the relevant sample concentrations in solution. This can be seen in Figure 3.7, which shows spectra of ethanol samples in various concentrations pre-processed as above.

(a) (b)

Figure 3.6 – Spectral saturation due to the first overtone of water (1 450 nm). (a) Spectra of water and two ethanol solutions, showing saturation in the 1 400 – 1 800 nm wavelength range

(measured in diffuse reflection with optical path ~20 mm; reference: empty cell with PTFE). (b) Spectra of water for different optical paths (measured in transmission in glass cells

of different widths); the first overtone is defined for path lengths up to 1 mm.

3.3.3.5 Normalization

An optional final step involved normalizing the spectra to span the values between 0 – 1. This allowed enhancement of spectral features for effective comparisons, albeit with the loss of original spectral amplitudes.

3.4 Results