# Automatic Detection of Electrodermal Activity Events during Sleep
## 2 Materials and Methods
### Wavelet Transforms  
In the literature, WTs have been applied to various biophysical signals, such as electrocardiogram and electromyography signals [34, 35]. Recently, WTs have been used for pre-processing EDA signals, particularly for artefact detection [24, 36]. By properly choosing the mother wavelet, we can distinguish those parts of the signal that resemble the shape of measurement noise or of motion artefacts in order to exclude them.  
Figure 1: A sample raw EDA signal from a single night PSG recording is shown.  
In this work, we use the discrete wavelet transform (DWT) and the stationary wavelet transform (SWT), which is a continuous transform. In the following, we provide a brief description of the WT; a detailed introduction to wavelets can be found in [37]. The WT is similar to the fast FT (FFT) or discrete FT in the sense that they are all linear operations. While the basis functions of FFT are sines and cosines, WTs allow for the use of more complex basis functions [38]. The other main difference between the FFT and the DWT is that wavelets are localised in space. The sine and cosine functions used in the FT are not. Moreover, when using FFT coefficients to reconstruct a signal, sharp changes in the original signal may cause the appearance of ringing artefacts in the reconstruction, which can be confused with actual artefacts. A popular mother wavelet used to limit the effect of sharp changes due to measurement noise is the _haar_ function [27], which is shown in Figure 2.  
In this work, we employ the SWT for the identification of motion artefacts in the data. This choice was motivated by the time-invariant nature of these artefacts, as well as their lack of susceptibility to causing undesirable ringing artefacts. As candidate mother wavelets, we use the functions _db44_ and _coif3_; see Figure 3 and Figure 4, respectively. Both wavelet functions are frequently used in biomedical applications. Moreover, the _coif3_ wavelet resemblance the characteristic shape of motion artefacts [36, 39].  
After choosing the candidate mother functions, the choice of decomposition level (DL) is most critical. We use the DL with minimum entropy as recommended in [40]. Additionally, the entropy of a signal is related to the number of coefficients needed to properly describe the signal [40]. Therefore, choosing the DL with the lowest entropy allows minimising the number of coefficients needed to represent the signal. In this work, we considered Shannon entropy as a measure. It is defined by  
\[E_{sh}=-\sum_{i}y_{i}^{2}ln(y_{i}^{2}), \tag{1}\]  
where \(y\) is the signal [40]. For different DL, the Shannon entropy of the signal shown in Figure 1 is given in Table 1, where the entropy values for \(db44\) and \(coif3\) are similar. Importantly, we obtain similar results for all other EDA signals in the datasets (not shown). Thus, DL 1, which has the lowest entropy, seems to be the most appropriate for artefact detection. Since \(coif3\) resemblances the characteristic shape of motion artefacts, we use it for artefact detection, that is, we exploit the similarity between this mother wavelet and motion artefacts. Note that the _haar_ function was used to smooth the signal.