Fundamental component enhancement via adaptive nonlinear activation functions
Abstract.
In many real world oscillatory signals, the fundamental component of a signal might be weak or does not exist. This makes it difficult to estimate the instantaneous frequency of the signal. Traditionally, researchers apply the rectification trick, working with or instead, to enhance the fundamental component. This raises an interesting question: what type of nonlinear function has the property that has a more pronounced fundamental frequency? and seem to work well in practice; we propose a variant of and provide a theoretical guarantee. Several simulated signals and real signals are analyzed to demonstrate the performance of the proposed solution.
Key words and phrases:
fundamental component; rectification; activation function2020 Mathematics Subject Classification:
42A99, 92C55.1. Introduction
1.1. The problem.
We start by describing the problem in the simplest possible setting: suppose we are given a periodic signal
(1) |
and define the support of to be . Our goal is to recover , the greatest common divisor of all the elements in . If we have recorded two or more periods of the signal, then the will be bigger than 1. In that case, we call the fundamental frequency. Mathematically speaking, there is no difficulty: compute the Fourier transform of and check.

There are several reasons why this seemingly trivial problem is difficult in practice.
-
(1)
In practice, all Fourier coefficients of will be distinct from 0; some form of thresholding to decide significance is required.
- (2)
-
(3)
We only have sampled at finitely many points; moreover, in practice one should always expect some form of noise.
1.2. Motivation from medicine.
We describe an explicit problem coming from medical signal processing which was partially the motivation for our paper. Our example can be seen in Figure 2(a) and comes from a phonocardiogram (PCG) signal [2]: this is a sound signal created by the vibrations created by the closure of the heart valves. One fundamental component of the signal, one heartbeat, can be seen within each of the two red boxes: it is comprised of two ingredients, S1 and S2 (indicated by blue errors): S1 is due to the atrioventricular valves closing at the beginning of systole and S2 is the consequence of the aortic and pulmonary valves closing at the end of systole.

Due to the heart rate variability, the periods between two consecutive cycles are not fixed: an important but challenging problem is to estimate the heart rate at a local point in time, this amounts to estimating the time-varying period, or the instantaneous frequency. Naturally, one would be inclined to apply time-frequency (TF) analysis [3]. This signal oscillates roughly twice per second, so the frequency is around 2 Hz, and we would expect to see a dominant curve around 2 Hz that represents the fundamental component of the signal. However, we cannot see anything concrete around 2 Hz from the standard spectrogram shown in Figure 2(b) and, in this sense, the fundamental component of the signal does not exist. In short, we need a different solution if we want to estimate the time-varying heart rate.
1.3. The rectification trick.
There is a surprisingly simple and widely applied solution; that is, take the ‘rectification’ of the signal before running any sort of time-frequency analysis. Mathematically speaking, take the signal where is the signal of interest. We refer to Figure 3 where the signal from Figure 2 has been analyzed after rectification: we analyze instead of .

Here, rectification leads to a dramatically different and much more informative spectrogram in which a clearly defined fundamental frequency exists (indicated by the red arrows). This simple solution has been widely applied in practice if we want to estimate the fundamental frequency, for example, in the problem of extracting fetal electrocardiogram (ECG) from the trans-abdominal maternal ECG [9] or extracting f-wave from the ECG signal of a patient with atrial fibrillation [6], which is a far from complete list. To the best of our knowledge, there is no theoretical argument explaining why the rectification trick works to enhance the fundamental component. We believe this to be of substantial theoretical interest.
Open problem. Why is standard time frequency analysis applied to better able to recover the fundamental underlying frequency? Why does the ‘rectification’ trick work?
Abstracting the trick, we may interpret the rectification trick as the application of a nonlinear activation function : instead of analyzing , one analyzes . Naturally, there are many other choices of the activation function [7], like the commonly used Rectified Linear Unit (ReLU) function and other widely applied activation functions from the theory of neural networks that are at our disposal. In practice, ReLU seems to work and work roughly as well as the absolute value. We do not know of any theoretical support for any of these functions and can now formulate the main question that motivates our paper.
Open problem. Which nonlinear activation function leads to the ‘best’ recovery of the fundamental frequency?
One of the main points of our paper is to discuss the problem from the point of view of classical Fourier analysis and to propose, based on that, a somewhat unorthodox choice, provide theoretical support and discuss its behavior in practice.
2. Main Result
2.1. An adaptive activation function.
We define, for small, an adaptive activation function. Introducing, for , the function
we propose to run standard time frequency on the normalized signal
and expect it to enhance the fundamental component of . This activation function is adaptive to the input signal since it depends on the norm of the input signal. Note that is also periodic. So by construction, it inherits the periodicity of . The question is now: can we determine the strength of the fundamental component of ? To provide a theoretical analysis this question, we put some assumptions.
-
(1)
We assume that the function is of the type
In particular, this function will have fundamental frequency .
-
(2)
We assume that the function assumes its global maximum in finitely many points and
-
(3)
that these maxima are non-degenerate: for all .
We can now state our result which shows that, as , the method will indeed recover the fundamental frequency (which we expect to be 1 in the generic setting).
Theorem.
We have, as ,
Remarks.
-
(1)
We note that for ‘generic’ signals (say, random signals picked from a suitable probability distribution), we expect that there is a unique maximum : in that case, the leading order expansion is always guaranteed to be of order
and we are guaranteed that the fundamental frequency is recovered.
-
(2)
If there is more than one maximum, then we only fail at recovering the fundamental frequency if
This is something that we do not expect to happen for generic signal (it corresponds to a precise algebraic identity).
-
(3)
If the frequencies share a nontrivial greatest common divisor
then the maxima of will be periodic on the unit circle and the sum will vanish. The Theorem can then be applied to the function to conclude that the fundamental frequency will be recovered.
2.2. General Activation Functions
The purpose of this section is to give some perspective on the problem from the point of view of classical Fourier analysis. We note that the intrinsically nonlinear nature of the problem does pose an interesting challenge, nonetheless, there are some natural considerations partially inspired by a classical paper of Rudin [8] that seem like they might be relevant. We recall that our goal is, given a function of the type
to come with a nonlinear function such that has a clear frequency contribution at . The main difficulty in practice is, of course, that we do not actually know the precise formula of when only is given, and have no real idea what the actual frequencies might be. We simplify things by assuming that the nonlinearity can be expanded into a Taylor series
Then each individual power applied to can be properly analyzed: note that
This shows that large powers naturally lead to a function whose frequencies is comprised of sums of the individual frequencies. If we replace powers by powers of the absolute value, then at least for even powers the identity leads to a way of writing
as
There is a nontrivial contribution coming from the coefficients , however, if we only consider the support of the frequencies, then a rather clear picture emerges: denoting the set of frequencies that make up by
we expect that
However, we also expect, for sufficiently large, that the numbers that can be appropriately written as sums and differences of elements in have a nice limiting behavior and (for a suitabye lenient definition of )
These heuristic considerations suggest the following rough guidelines:
-
(1)
The Fourier transform of depends on the Taylor expansion of .
-
(2)
If the function is smooth, then the Taylor expansion will have rapidly decaying coefficients and sum sets of the type
A choice like will not lead to a good detection function.
-
(3)
This suggests functions for which the Taylor expansion decays slowly: functions that are discontinuous or have discontinuous first derivative.
-
(4)
Moreover, introducing the absolute value leads to sum-difference sets which might generally lead to better results.
These principles naturally suggest functions like or . However, we note that both of these functions are actually continuous which leads to a decay of coefficients in the Taylor expansion. Indeed, considering all these principles, we should focus our attention on functions of the form
for which the decay slowly. A particularly natural candidate is
and this is how we arrive at our proposed construction. As we will show in Section 3, this construction is not only well motivated by the aforementioned arguments but also naturally incorporates a second approach which is related to asymptotic analysis and encapsulated by Theorem 1.
3. Proof of the Theorem
Proof.
We now give a proof of the result. It follows from the assumptions that each local maximum of behaves locally around the maximum like a parabola (since does not vanish and is negative). This allows us to treat all the points where assumes a maximum in isolation. We start by considering a point such that . In that case, we observe that
This quantity is uniformly bounded as . Since our main result is about the asymptotic growth of an integral over a bounded region as and since we are only interested in terms at scale or larger, we may disregard points where remains bounded as . We can now proceed as follows: since there are only finitely many points that achieve the global maxima of and since all of them are non-degenerate, there exists such that the preimage
can be written as the union of disjoint intervals. By making sufficiently small, we can also ensure that each of the intervals contains a point in which assumes its global maximum. Moreover, we can also infer that, as , these intervals scale asymptotically like , where the implicit constant depends on the value of the second derivative in .
Then, uniformly as , we have
Note that is independent of . This shows that contributions at scale can only come from . Let us now assume that assumes a global maximum in . Then, locally around , we have the expansion
Therefore, we have, locally around ,
(2) |
Note that . Thus, the denominator is, up to second order, growing away from . Our next ingredient will be the identity
(3) |
In particular, letting , we recover
In our case, we have , while
converges to a fixed constant as gets small (and is, in particular, bounded away from 0). This implies
when is sufficiently small. The second equality comes from (3). Indeed, by choosing , we see that the term is of order , and hence
whenever is sufficiently small. Combined with the numerator, we obtain the desired control of . From this control, we deduce
when is sufficiently small. Indeed, since , the error, in (2), is controlled when is sufficiently small. Using continuity of and summing over the intervals, we arrive our conclusion
∎
4. Numerical results
All Matlab codes are available in for the reproducibility purposes.
4.1. Synthetic data.
We generate synthetic data to investigate how different activation functions enhance the fundamental component. Fix the sampling rate to be Hz. First, randomly select an integer between and according to a uniform distribution. Then, randomly select integers between and following the probability density function , where is the normalization constant, so that the chosen integers have 1 as the greatest common divisor. Denote the selected integers as . Then, set the function as
where , , are identically and independently (i.i.d.) sampled from , and , , are i.i.d. sampled from . Note that by construction, is a toy example as that shown in (1) with but as the fundamental frequency. For a given activation function , we evaluate the resulting fundamental component enhancement by evaluating the fundamental component energy ratio, defined as
(4) |
Then, repeat the above procedure for times. The results of different activation functions are shown in Figure 5 as histograms of fundamental component energy ratios. Quantitatively, the median and median absolute deviation of the fundamental component energy ratio over times are 0.28% and 0.46% for the rectification, 0.07% and 0.12% for the RELU, 0.29% and 0.46% for , 0.31% and 0.42% for , and 0.33% and 0.33% for .

4.2. Semi-real Medical Example.
We generate a semi-real dataset and compare the proposed activation function with , and with the usually applied rectification and RELU activation function. We consider two databases. The first one is the noninvasive trans-abdominal ECG database from the PhysioNet Computing in Cardiology Challenge 2013 (CinC2013)111https://physionet.org/content/challenge-2013/1.0.0/. There are in total 75 recording, each recording contains 4 channels, and each record lasts for 1 minute. The second one is the Taiwan Integrated Database for Intelligent Sleep (TIDIS)222https://tidis.org. There are in total 20 whole night polysomnogram recordings, each recording contains 2 channels, and each record lasts for about 6 hours. For each recording in CinC2013, we detect the maternal R peaks by applying the standard R peak detection algorithm to the mean of 4 channels; for each recording in TIDIS, we apply the same standard R peak detection algorithm to the mean of two channels. For the -th channel in the -th recording, we randomly generate an 1-periodic function, denoted as , by averaging randomly selected cardiac cycles. Then we intentionally remove the fundamental component via the Fourier transform, and denote the resulting 1-periodic function as that is sampled at 512 Hz. Next, we apply the -th activation function to , and denote the resulting signal as . To evaluate how much the fundamental is activated, we record the energy ratio of the fundamental component defined in (4), denoted as . For the -th channel in the -th recording, the above procedure is repeated times. The histograms of all collected energy ratios for different activation functions are shown in Figure 6. We see that the proposed activation function gives a delta-like signal with the peak centered at the maximal value. Hence, the power spectrum is flatter compared with both rectification and RELU. This explains why the median of the energy ratio is smaller if we apply the proposed activation function since the proposed activation function tends to flatten the spectrum, particularly when is small. We shall mention that the main difference between these two databases is that the cardiac cycle is recorded from the abdomen in the CinC2013 database, and from the chest in the TIDIS database. Thus the cardiac cycles are of different morphology, and hence different energy ratio of the fundamental component. Note that after the averaging, the fetal ECG impact is reduced, and we obtain a reasonably clean maternal ECG cycles. See Figure 7 for more details.

To have a complete picture of the fundamental enhancement, we repeat the same data preparation procedure above, except removing the fundamental component; that is, we simulate the practical situation that the fundamental component may or may not exist, and its strength may or may not be weak. In addition to record the energy ratio, also denoted as by a bit abuse of notation, after applying the activation function, we also record the energy ratio before, denoted as . In Figure LABEL:Figure6simu, we plot the 2-dim histogram of the distribution of . By definition, when , we obtain an enhancement of the energy ratio of the fundamental component. The portion of cardiac cycles that the fundamental component strength is enhanced is recorded in the title. It is clear that all activation functions enhance the energy ratio of the fundamental component when it is weak.
Note that at the first glance, our proposed activation function seems to provide a worse result due to the smaller portion of enhanced cardiac cycles. However, we should emphasize that due to the “flattening” nature of our activation function, the energy ratio of the fundamental component is smaller.


4.3. Medical Example.
Next, we consider the PCG signal as a real example. In Figure 8, we show the spectrogram of the PCG signal shown in shown in Figure LABEL:Figure3PCG(a) composed with RELU (left) and . We could see that both RELU and provide the fundamental component information; that is, there is an identifiable curve around 2Hz. To have a quantification of this finding, we analyze the maternal PCG signals in the Shiraz University Fetal Heart Sounds Database333https://physionet.org/content/sufhsdb/1.0.1/. There are in total 92 recordings. See Figure 9(a) for a PCG signal different from that in Figure 2(a). It is clear that the spectrogram provides limited information about the heart rate. See Figure 9(b) and recall Figure 2(b) for an illustration. To quantify the fundamental component enhancement performance, we carry out the following steps. First, run the de-shape algorithm [5] to determine the instantaneous frequency (IF) of the PCG. See Figure 9(c-d) for the de-shape spectrogram and the detected IF. Denote the estimated IF as . The detected heart rate is confirmed by reading and hearing the signal. Second, determine the energy ratio around the band Hz; that is,
where is the spectrogram of the signal of length with the sampling rate . Here, since our focus is the heart rate, we downsample the signal to Hz. Over the 92 recordings, the mean and standard deviation of determined from the original signal, the rectified signal, the RELU activated signal and are , , , and . See Figure 9 for an example of the overall procedure.


References
- [1] Marcelo A. Colominas, and Hau-Tieng Wu. Decomposing Non-Stationary Signals With Time-Varying Wave-Shape Functions. IEEE Transactions on Signal Processing 69 (2021): 5094-5104.
- [2] Louis-Gilles Durand, and Philippe Pibarot. Most recent advancements in digital signal processing of the phonocardiogram. Critical Reviews in Biomedical Engineering 45 (2017): 1-6.
- [3] Patrick Flandrin. Time-frequency/time-scale analysis. Academic press, 1998.
- [4] Thomas Y. Hou, and Zuoqiang Shi. Extracting a shape function for a signal with intra-wave frequency modulation. Philosophical Transactions of the Royal Society A: Mathematical, Physical and Engineering Sciences 374.2065 (2016): 20150194.
- [5] Chen-Yun Lin, Li Su, and Hau-Tieng Wu. Wave-shape function analysis. Journal of Fourier Analysis and Applications 24.2 (2018): 451-505.
- [6] John Malik, Neil Reed, Chun-Li Wang, and Hau-Tieng Wu. Single-lead f-wave extraction using diffusion geometry. Physiological measurement 38:7 (2017): 1310.
- [7] Andrinandrasana David Rasamoelina, Fouzia Adjailia, and Peter Sincak. A review of activation function for artificial neural network. 2020 IEEE 18th World Symposium on Applied Machine Intelligence and Informatics (SAMI). IEEE, 2020.
- [8] Walter Rudin, Trigonometric series with gaps. J. Math. Mech. 9 (1960): 203–227.
- [9] Pei-Chun Su, Stephen Miller, Salim Idriss, Pier Barker and Hau-Tieng Wu, Recovery of the fetal electrocardiogram for morphological analysis from two trans-abdominal channels via optimal shrinkage. Physiological measurement 40.11 (2019): 115005.
- [10] Adrien Meynard, and Bruno Torrésani. Spectral analysis for nonstationary audio. IEEE/ACM Transactions on Audio, Speech, and Language Processing 26.12 (2018): 2371-2380.
- [11] Hau-Tieng Wu. Instantaneous frequency and wave shape functions (I). Applied and Computational Harmonic Analysis 35.2 (2013): 181-199.
- [12] Jieren Xu, Haizhao Yang, and Ingrid Daubechies. Recursive diffeomorphism-based regression for shape functions. SIAM Journal on Mathematical Analysis 50.1 (2018): 5-32.
- [13] Haizhao Yang. Multiresolution mode decomposition for adaptive time series analysis. Applied and Computational Harmonic Analysis (2019).