Introduction

Electrogastrography is a research method designed for noninvasive assessment of gastric slow wave propagation [14]. One or multichannel EGG signals are obtained from the disposable electrodes, appropriately arranged on the surface of the abdomen of the patient’s stomach [57]. It is assumed that the frequency range of EGG signal is from 0.015 to 0.15 Hz and the amplitude of it is about 100–400 μV [6, 8]. The typical EGG examination takes about 2 h and consists of three parts: the first one - preprandial, usually no longer than 30 min, it is a stage before a meal (person under investigation should be fasted). The second part takes about 5 to 15 min, including time when the person accepts a standardized meal, and the third part - postprandial, about 60–120 min, when the meal is digested. The standard of a meal depends on the examining center. Most frequently three types of meals are used: non-caloric meal e.g., 400 ml water, liquid meal e.g., 250 ml of yogurt and the caloric meal, e.g., pancake with jam prepared according to a well-defined recipe [9, 10].

The initial analysis of EGG signals involves calculating dominant frequency and dominant power of slow waves [2, 4, 6, 1113]. In the case of EGG examination the frequency is typically calculated in cycles per minute (cpm), as a medical standard [5]. According to the DF values, the EGG rhythm is classified to: bradygastria (0.5–2.0 cpm), normal rhythm (2.0–4.0 cpm) or tachygastria (4.0–9.0 cpm) [4, 5]. Due to very high level of disturbances and interferences in EGG signals while receiving a meal, the DF values are calculated only for preprandial and postprandial parts. On the basis of the rhythm classification, the normogastria index is calculated [6]. This index is expressed as the amount of DF values in the range of normal rhythm to the total amount of the DF values [4, 5].

The parameters DF and MP are usually calculated by means of the spectral analysis. The spectral analysis of EGG is done for short segments (1 to 5 min length) of the signals. The values of DF and MP are calculated for each segment. The length of the segments depends on the limitations of the used method and is a compromise between accuracy and resolution of calculated frequency and its time location in the analyzed signal. Segments of 3 to 5 min length are used to calculate spectrum of the EGG signal, using the short-time Fourier transform (STFT), and for the nonparametric methods (for example AR, ARMA modeling), the minimum length of the segment is about 60 s [4, 6, 11, 12]. In the case of EGG signal analysis, the process of calculation the spectrum of consecutive or overlapped fragments is often referred as a running spectrum analysis (RSA) [8, 14]. Figure 1 shows a 1-min segment of the signal before and after application of Tukey window (left), its power spectrum (middle) with marked both DF and MP values, and an example of RSA analysis of one channel EGG signal (right).

Fig. 1
figure 1

An example of 60s segment of EGG signal (left), its spectrum (middle) with marked DF and MP and an example of RSA analysis of one-channel EGG signal (right)

The EGG signals analysis based on CWT is widely presented in the literature [1519]. In this study, the CWT algorithm based on FFT was applied to determine the dominant frequency of the slow wave in the EGG signal. In the literature, this algorithm is referred to as CWTFT [2022]. An application of CWT allows to reduce limitations of classical methods of spectrum analysis (e.g., FFT, STFT) and facilitates to determine instantaneous frequencies and its location in the time domain [2325].

The continuous wavelet transform is a powerful tool for analyzing nonstationary time series signals in the time-frequency domain and substantially differs from the STFT method that allows clear localization on the time axis of the frequency components, existing in the analyzed signals. Such an analysis is possible using of variable width window which corresponds to the scale of observation (analysis). Wavelet analysis allows using long time windows when we need more precise low frequency information, and shorter when we need high frequency information. It should be noted that the wavelet analysis does not include the area of time-frequency (as in the case of STFT), but the area: the time-scale. The time-scale area can be converted to the appropriate area of pseudo-frequency - time, where the pseudo-frequency is the characteristic central frequency of the wavelet. Another important distinction from the STFT is that the CWT is not limited to sinusoidal analyzing function and do not requires, that the signal meets fairly strict criteria, which are required in the classical Fourier analysis [22].

Method

The CWT reflects the correlation between the analyzed continuous-time signal x(t) and a function referred to as wavelets and is defined by the following formula

$$ Cw\left(a,b\right)={\displaystyle {\int}_{-\infty}^{+\infty }x(t){\psi_{a,b}}^{*}dt}=\frac{1}{\sqrt{a}}{\displaystyle {\int}_{-\infty}^{+\infty }x(t){\psi}^{*}\left(\frac{t-b}{a}\right)dt}, $$
(1)

where: Cw(a, b) is the function of the parameters a and b.

The a parameter is the dilation of wavelet (scale) and b defines a translation of the wavelet and indicates the time localization, ψ*(t) is the complex conjugate of the analyzing mother wavelet ψ(t) [22, 26]. The coefficient \( \frac{1}{\sqrt{a}} \) is an energy normalized factor (the energy of the wavelet must be the same for different a value of the scale). Moreover, to be classified as a basic permissible wavelet, a wavelet function must satisfy the following mathematical criteria [2730]:

The wavelet must have finite energy

$$ E={\displaystyle {\int}_{-\infty}^{+\infty }{\left|\psi (t)\right|}^2dt<\infty } $$
(2)

The following condition must hold true

$$ {C}_{\psi }={\displaystyle {\int}_{-\infty}^{+\infty}\frac{{\left|\overset{\wedge }{\psi}\left(\omega \right)\right|}^2}{\omega }d\omega <\infty }, $$
(3)

where

$$ \overset{\wedge }{\psi}\left(\omega \right)={\displaystyle {\int}_{-\infty}^{+\infty}\psi (t){e}^{-i\omega t}dt} $$
(4)

is the Fourier transform of the ψ(t) function and ω = 2πf is the circular frequency. This condition is defined as a condition of admissibility and can be interpreted as a requirement that |ψ(ω)|2 decay endeavored (head) to zero faster than \( \frac{1}{\omega } \). This condition means that the wavelet has no zero frequency component, that is

$$ \overset{\wedge }{\psi }(0)=0 $$
(5)

Otherwise, the wavelet must have the zero mean value. In the literature the parameter C ψ is called the admissibility constant. The value of C ψ depends on the chosen wavelet [2729].

In the case of complex wavelets, Fourier transform must have both a real component and a value of zero for negative frequencies [22].

As a result of CWT transform we obtain the two-dimensional function E(a, b) = |Cw(a, b)|2 called scalogram, which presents energy distribution of signals for used scales a and the time position b (locations). In practice, all functions that differ from |Cw(a, b)|2 only by the constant multiplicative factor are also called scalograms [22]. The CWT can be considered as a transform that converts the signal from the time domain to the scale-time domain. The scale as mentioned above can be converted to a frequency value (pseudo-frequency), the value of which depends on the center frequency of the applied wavelets and the scale value a

$$ {f}_a=\frac{f_c}{a}, $$
(6)

where: f a is the frequency associated with the wavelet at the specific a scale, while f c is the characteristic frequency of mother wavelet at scale a = 1, and time position b = 0. There is a very important distinction to be made here: “The characteristic frequency f c of the wavelet used in the wavelet transform is representative of the whole frequency makeup of the wavelet. The wavelet does not contain a single frequency, and the signal is not decomposed according to numerous single (sinusoidal) frequencies; this is not Fourier analysis!” [22].

It is known, if the wavelet transform coefficients are given, it is possible to reconstruct the original signal by the inverse wavelet transform described by the following equation [20]

$$ x(t)=\frac{1}{K_{\psi }}{\displaystyle {\int}_{a=0}^{+\infty}\left({\displaystyle {\int}_{b=-\infty}^{+\infty }}Cw\left(a,b\right){\psi}_{a,b}(t)\frac{db}{a^2}\right)}da=\frac{1}{K_{\psi }}{\displaystyle {\int}_0^{+\infty }D}\left(a,t\right)da, $$
(7)

where K ψ is a constant factor that depends on the applied wavelet function and the details function D(a, t) is given by the following equation

$$ D\left(a,t\right)={\displaystyle {\int}_{b=-\infty}^{+\infty}\frac{1}{a^2}Cw}\left(a,b\right){\psi}_{a,b}(t)db $$
(8)

In practical CWT applications usually discrete values of the a scale in the range of continuous values are used. As the result the wavelet coefficients are obtained (called wavelet series). The choice of appropriate wavelet function is crucial to obtain good results during signal analysis. The classic CWT transform is time consuming and it requires considerable computing power to apply it to the analysis of long signals.

In recent years, the new efficient algorithms have been developed for significant acceleration of CWT calculation. One of them uses well-known FFT algorithms to calculate the CWT [20, 22, 23].

If we define

$$ {\psi}_a(t)=\frac{1}{\sqrt{a}}\psi \left(\frac{t}{a}\right) $$
(9)

and

$$ {\psi}_{ab}(t)=\frac{1}{\sqrt[]{a}}\psi \left(\frac{t-b}{a}\right) $$
(10)

the definition of CWT transform (1) can be rewritten in the following form

$$ Cw\left(a,b\right)={\displaystyle {\int}_{-\infty}^{+\infty }x(t){\psi}_{ab}^{*}(t)dt}={\displaystyle {\int}_{-\infty}^{+\infty }x(t){\psi}_a^{*}\left(b-t\right)dt}, $$
(11)

which clearly indicates that the CWT can be treated as a convolution of the signal and wavelets. Consequently CWT can be expressed as an inverse Fourier transform

$$ Cw\left(a,b\right)=\frac{1}{2\pi }{\displaystyle {\int}_{-\infty}^{+\infty}\widehat{x}}\left(\omega \right){\widehat{\psi}}_{a,b}^{*}\left(\omega \right)d\omega, $$
(12)

where:

$$ {\widehat{\psi}}_{a,b}^{*}\left(\omega \right)=\sqrt{a}{\widehat{\psi}}^{*}\left(a\omega \right){e}^{i\omega b} $$
(13)

denote the Fourier transform of the analyzed wavelet at scale a and location b and

$$ \widehat{x}\left(\omega \right)={\displaystyle {\int}_{-\infty}^{+\infty }x(t){e}^{-i\omega t}dt} $$
(14)

is the Fourier transform of the analyzed signal x(t).

In the case of discrete signals (which are typical for the signals processing problems), assuming that the input signal x(n) includes N samples, the discrete versions of the convolution can be represented as

$$ {W}_a(b)={\displaystyle {\sum}_{n=0}^{N-1}x(n){\psi}_a^{*}}\left(b-n\right) $$
(15)

We can easily notice that in order to obtain the CWT we have to calculate the convolution of the signal and wavelets for each value of the location b and repeat the calculations for each value of the scale a. In the case of two periodic sequences (signals) we can use the property described by Eq. (15) and apply fast algorithms for determining the discrete Fourier transform (DFT) to calculate the circular convolution [31]

$$ \begin{array}{cc}\hfill {\displaystyle {\sum}_{n=0}^{N-1}x(n){\psi}_a^{*}}\left(b-n\right)=\frac{1}{N}{\displaystyle {\sum}_{k=0}^{N-1}\widehat{x}(k){\widehat{\psi}}_a^{*}(k)}{e}^{i\frac{2\pi }{N} kb},\;\hfill & \hfill b=0,1,2\dots N-1\hfill \end{array} $$
(16)

where the discrete Fourier transform of x(n) signal is given by formula

$$ \begin{array}{cc}\hfill \widehat{x}(k)={\displaystyle {\sum}_{n=0}^{N-1}x(n){e}^{-i\frac{2\pi }{N}nk}},\hfill & \hfill k=0,1,2\dots N-1\hfill \end{array} $$
(17)

\( {\widehat{\psi}}_a \) is the discrete Fourier transform of the wavelet ψ a

$$ \begin{array}{cc}\hfill {\widehat{\psi}}_a(k)={\displaystyle {\sum}_{n=0}^{N-1}{\psi}_a(n){e}^{-i\frac{2\pi }{N}nk}},\hfill & \hfill k=0,1,2\dots N-1\hfill \end{array} $$
(18)

where k is an index of frequency.

Assuming that the signal is sampled at a frequency f = f s , the sampling period is Δt = 1/f s and in order to obtain the unit energy for each scale a, the wavelet function is normalized by the following formula [23]

$$ {\widehat{\psi}}_a\left(a{\omega}_k\right)=\sqrt{\frac{2\pi a}{\varDelta t}}\widehat{\psi}\left(a{\omega}_k\right), $$
(19)

where:

$$ {\omega}_k=\frac{2\pi k}{N\varDelta t} $$
(20)

The CWT can be expressed as the products of the inverse Fourier transform

$$ {W}_a(b)=\frac{1}{N}\sqrt{\frac{2\pi a}{\varDelta t}}{\displaystyle {\sum}_{k=0}^{N-1}\widehat{x}\left(\frac{2\pi }{N\varDelta t}k\right){\widehat{\psi}}^{*}\left(a\frac{2\pi }{N\varDelta t}k\right){e}^{i\frac{2\pi }{N} kb}} $$
(21)

The above described method was used for the EGG signals analysis. The calculations were made for various wavelets e.g.,: Morlet, Derivative of Gausian and Paul. During initial tests, authors have examined all available in the applied version of the Matlab (R2013b) types of wavelets for CWTFT algorithm: m-th order derivative of a Gaussian wavelet, analytic Morlet wavelet, non-analytic Morlet wavelet, non-analytic Morlet wavelet with zero mean, Mexican hat wavelet. The non-analytic Morlet wavelet was chosen because the obtained scalograms provided similar information consistent with the commonly known properties of EGG signals as the occurrence of the characteristic frequencies (e.g., 3 cpm) and typical changes in parameters after administration of the meal [3].

In our work all the presented results were obtained for the non-analytic Morlet wavelet with zero mean, specified in the Fourier transform domain by the following formula

$$ \widehat{\psi}\left(a\omega \right)=\frac{1}{\sqrt[4]{\pi }}\left({e}^{-\frac{{\left(a\omega -{\omega}_0\right)}^2}{2}}-{e}^{-\frac{\omega_0^2}{2}}\right), $$
(22)

where ω 0 is the non-dimensional frequency parameter and its value was set to 6 and 15. If ω 0 = 6 the admissibility condition is satisfied [23, 32].

The dependence of the pseudo-frequency scale on the chosen wavelet is given by

$$ {f}_a=\frac{1}{a\varDelta t\lambda}, $$
(23)

where λ is the Fourier wavelength (frequency Fourier factor) for the Morlet wavelet and it is given by the following formula [23]

$$ \lambda =\frac{4\pi a}{\omega_0+\sqrt{2+{\omega_0}^2}} $$
(24)

During calculations the range of the a 0 = ω 0 Δt scale (1.5 and 3.75) to 50 in steps of 0.15 were used, which correspond to the range of the pseudo-frequency values 0.6453–0.0040 Hz for ω 0 = 6 and 0.638–0.0039 Hz for ω 0 = 15 , respectively. The examples of the applied Morlet wavelet are shown in the Fig. 2.

Fig. 2
figure 2

Morlet wavelet (blue a = 1, red a = 3.75) in the time domain (left) and in the frequency domain(red ω0 = 6, blue ω0 = 15) (right)

The Fig. 3. depicts the deference between STFT and CWTFT transforms for an example of a chirp signal (from 0.005 to 0.025Hz, sampled at f s  = 4Hz).

Fig. 3
figure 3

Segment of a chirp signal (left) associated with STFT transform (medium) and CWTFT (Morlet wavelet, ω0 = 6) transform (right)

Application to EGG

As the aim of this work is to show the application of new algorithms for EGG signal analysis, the paper presents the results of research carried out for only four subjects (women), volunteered to participate in the study. Their average age was 25.75 years (range: 24–31) and average BMI 19.83 (range: 18.6–21.1). Every volunteer gave a written consent to participate in the study. The research project was approved by the Bioethics Committee of the Silesian Medical University.

The duration of EGG study was in the range of 120 to 170 min and it consisted of three parts: preprandial (30–40 min), meal (5–10 min) and postprandial (90–120 min). Before the test, all participants were in a fasting state.

The calculations of the CWT coefficients (absolute values of elements W ab further denoted |W ab | ) were performed for four-channels EGG signals, sampled at the frequency 4 Hz and the resolution of 12 bits, using the 4-channel prototype biomedical amplifier with the input range ±1 mV and gain 5000.

In order to assess the accuracy of the obtained results, the values of normogastria index (NI) were calculated for each EGG channel using the following procedure. The signal was divided into 60 s length segments (with overlap 50 %) and the |W ab | matrices were calculated. The |W ab | matrices were reshaped in order to remove the components which corresponded to the pseudo-frequency greater than 9 cpm (0.15Hz), because the analysis of EGG signals above this frequency is not carried out [2, 4, 5]. Then, for each segment of the modified |W ab | matrices the maximum value which corresponds to the pseudo-maximum power pMP(l) was found and its corresponding value of the dominant pseudo-frequency pDF(l), where l is the number of 1-min segment of the EGG signal. Finally NI index as the ratio of the number of pDF values in the range of 2–4 cpm to all values was calculated, for all channels of recorded EGG signal [2, 5, 6, 10]. Then, evaluated normogastria indexes were compared with those calculated by means of the classical method [4, 6].

Results

The described method was applied to the analysis of over 2 h, four-channel EGG recordings, using a light non caloric liquid meal (400 ml cold water). Figure 4 shows the result of the CWT analysis using the non-analytic Morlet wavelet for ω0 = 6. The scale values were converted to the corresponding pseudo-frequency values. This figure clearly shows that the maximum value of the energy in the signal occurs about 3 cpm - the typical frequency of the slow wave in the EGG signal [4, 8]. Especially in the first part of the examination (preprandial) we can see clearly that the frequency is almost constant or oscillates near the 3 cpm. Figure 5 shows the frequency values corresponding to the maximum energy of scalogram. This process (curve) can be treated as a continuous frequency of the slow waves in the EGG signal. Figures 6 and 7 illustrate respectively the pDF and pMP for the sequent of 60 s segments of EGG signal. These values were also obtained based on the analysis of the CWTFT coefficients. Figures 6 and 7 were presented to compare the obtained results against the results of the classical EGG signals analysis (Fig. 12). The Figs. 8, 9, 10, and 11 show results of analysis using the Morlet wavelet with ω0 = 15.

Fig. 4
figure 4

Time-frequency analysis with CWTFT (non-analytic Morlet wavelet, ω0 = 6) for four-channels EGG signal

Fig. 5
figure 5

Instantaneous dominant frequency obtained by means of the CWTFT (non-analytic Morlet wavelet, ω0 = 6) analysis for four-channels EGG signal

Fig. 6
figure 6

Dominant frequency (pDF) obtained by means of the CWTFT (non-analytic Morlet wavelet, ω0 = 6) analysis for four-channels EGG signal (for 60s segments)

Fig. 7
figure 7

Maximum Power (pMF) obtained by means of the CWTFT (non-analytic Morlet wavelet, ω0 = 6) analysis for four-channels EGG signal (for 60s segments)

Fig. 8
figure 8

Time-frequency analysis with the CWTFT (non-analytic Morlet wavelet, ω0 = 15) for four-channels EGG signal

Fig. 9
figure 9

Instantaneous dominant frequency obtained by means of the CWTFT (non-analytic Morlet wavelet, ω0 = 15) analysis for four-channels EGG signal

Fig. 10
figure 10

Dominant frequency (pDF) obtained by means of the CWTFT (non-analytic Morlet wavelet, ω0 = 15), analysis for four-channels EGG signal (for 60s segments)

Fig. 11
figure 11

Maximum power (pMP) obtained by means of the CWTFT (non-analytic Morlet wavelet, ω0 = 15) analysis for four-channels EGG signal (for 60s segments)

The Fig. 12 shows the values of the DF and the MP for the same signal derived from the classical EGG analysis for the same EGG signals.

Fig. 12
figure 12

Dominant frequency (top) and MP (bottom) obtained by means of the classical method of EGG signal analysis (4-channels EGG signals, 60s segments) (the green color indicates the meal period)

Normogastria indexes Norm I and Norm 60 (corresponding to NI index) were calculated by the proposed method while Norm c was obtained by the means of classical method. These values of normogastria indexes for four EGG recordings are presented in Table 1 The normogastria indexes obtained on the basis of CWTFT were calculated by two methods: Norm I was calculated on the basis of all the instantaneous frequency (corresponding to the maximum energy) and Norm 60 was based on the average value for the 60 s segments.

Table 1 The comparison of normogastria indexes

Figures 13, 14, and 15 show the results of the analysis for another EGG signal, which can clearly depict an immediate increase of power in the signal EGG after the meal and its gradual reduction during the postprandial phase. This is the typical phenomenon which can be often observed during the EGG examination [13].

Fig. 13
figure 13

Time-frequency analysis with the CWTFT (non-analytic Morlet wavelet, ω0 = 6) for four-channels EGG signal

Fig. 14
figure 14

Maximum power obtained by means of the CWTFT (non-analytic Morlet wavelet, ω0 = 6) analysis for four-channels EGG signal (for 60s segments)

Fig. 15
figure 15

Pseudo-RSA (obtained by means of the CWTFT) of four-channels EGG signal

Conclusion

In this paper, the method of multi-channels EGG signals analysis by means of the CWTFT was described. Thanks to FFT applying in the CWT algorithm computation, the results for relatively long records of EGG can be obtained in a fairly short time (much faster than using the classical methods based on RSA analysis, e.g., using AR or ARMA models).

In this study, for the first time, the authors show the possibility of a parametric analysis of multi-channel EGG signals, using continuous wavelet transform. The normogastria indexes obtained by means of the proposed method, have similar values to the coefficients calculated by means of the classical analysis. However, it was noticed that the largest differences occurred in the signals for which the value of normogastria index was below 0.6. This phenomenon requires further investigation and necessary medical verification.

We can notice that results obtained by the analysis of the CWT are dependent on the mother wavelet function, which significantly affects the quality of signal analysis and results [16]. According to our tests, the Morlet wavelet gives the best results of the EGG signal analysis moreover preliminary results show the robustness of the method and its large potential in the future analysis of the EGG signals. Additionally, the presented method allows to determine the instantaneous values of the dominant frequency and maximum energy which was not possible with the classical EGG signal analysis.

The possibility of continuous observation of the dominant frequency and the dominant power (and other coefficients calculated on this basis) gives opportunities for a wider application of the proposed method in the medical diagnosis of digestive systems. From medical point of view, the described method must be clinically verified, which requires a sufficiently long time, adequate resources and a commitment of medical environments.