Abstract
The spectral analysis of signals is currently either dominated by the speed–accuracy tradeoff or ignores a signal’s often nonstationary character. Here we introduce an opensource algorithm to calculate the fast continuous wavelet transform (fCWT). The parallel environment of fCWT separates scaleindependent and scaledependent operations, while utilizing optimized fast Fourier transforms that exploit downsampled wavelets. fCWT is benchmarked for speed against eight competitive algorithms, tested on noise resistance and validated on synthetic electroencephalography and in vivo extracellular local field potential data. fCWT is shown to have the accuracy of CWT, to have 100 times higher spectral resolution than algorithms equal in speed, to be 122 times and 34 times faster than the reference and fastest stateoftheart implementations and we demonstrate its realtime performance, as confirmed by the realtime analysis ratio. fCWT provides an improved balance between speed and accuracy, which enables realtime, wideband, highquality, time–frequency analysis of nonstationary noisy signals.
Main
Signals are essential in both nature and (manmade) technology, because they enable communication^{1,2} (Fig. 1). Mathematically, a signal is a function of one (for example, speech) or more (for example, a twodimensional (2D) image) dimensions that carries information about the properties (for example, state) of a physical system^{3}. A source transmits a signal via a channel to a receiver, which delivers it to its destination. For example, a brain sends an oral message via vocal cords through the air, which is received by the listener’s ear, which brings it to the listener’s brain. When the same message is transmitted via a smartphone, the air is complemented by a chain of technology, leaving the rest of the chain untouched. Signals are omnipresent in society^{3,4} (Fig. 1).
Independent of its source, a signal needs to be processed to enable the generation, transformation, extraction and interpretation of the information it is carrying^{3}. A widely used method to interpret (that is, extract and analyze) repeating patterns in signals is the Fourier transform (FT)^{3,4}. A FT transforms a function of time into a complexvalued function of frequency, representing the magnitudes of the frequencies. The FT assumes the signal is stationary. In other words, it is a stochastic process in which the marginal and joint density functions do not depend on the choice of time origin^{2}. However, in realworld practice, this assumption is often violated. Consequently, the FT is unable to process realworld nonstationary signals reliably^{5}. To circumvent the problem of nonstationarity, advanced algorithms exist that analyze a signal based on their decomposition in elementary signals that are well localized (or boxed) in time and frequency^{4}. These include the shortterm Fourier transform (STFT), also known as the Gabor transform, and the wavelet transform (WT)^{6}.
The STFT is very similar to the FT, but it uses a window function and short wavelets localized in both time and frequency, instead of pure waves, to extract temporal and spectral information. The drawback of the STFT is its use of a fixedwidth window function, as a result of which frequency analysis is restricted to frequencies with a wavelength close to the window width^{7}. Additionally, chopping up the signal in short, fixedwidth windows scrambles the signal’s properties. Accordingly, the frequency analysis is affected^{8}.
The WT overcomes the drawback of the STFT by not relying on a window function. Instead, it uses a family of base functions that dilate and contract with frequency to represent the signal, thereby ensuring high resolution across the entire frequency spectrum. Consequently, the WT suffers from a high computational load. This prohibits its use with lowend hardware and for realtime applications^{9}, as realtime computation requires an algorithmic computation time that is smaller than the signal’s duration.
To reduce the computational burden of the WT, the discrete wavelet transform (DWT) has been proposed, which applies a coarse, logarithmic discretization. This makes DWT suitable for data compression, but simultaneously disqualifies it from use in detailed analysis, as it is not able to analyze intricate time–frequency details^{8} (as shown in Fig. 2). For this, a true WT—the computationally expensive continuous wavelet transform (CWT)—also called an integral wavelet transform (IWT), is needed. CWT offers a highresolution representation of the time–frequency domain by using nearcontinuous discretization. Its continuous time and frequency scales better support intricate time–frequency analysis. Consequently, CWT is often described as the mathematical microscope of data analysis^{10} (Fig. 2).
In this Resource paper we introduce the opensource fast continuous wavelet transform (fCWT), which brings realtime, highresolution CWT to realworld practice (for example, biosignals^{11,12,13}, cybersecurity^{14,15} and renewable energy management^{16,17}; Fig. 1). Next, we assess the performance of fCWT in a benchmark study and then validate the use of fCWT on synthetic, electroencephalography (EEG) and in vivo electrophysiological data. We end with a concise discussion.
Results
The performance of fCWT was benchmarked against six widely used CWT implementations, then it was subjected to a threefold validation on accuracy, resolution and throughput using, respectively, synthetic data, human EEG data and highdensity in vivo extracellular rodent electrophysiology.
Benchmark
To benchmark the performance of fCWT we compared fCWT to the six widely used CWT implementations shown in Fig. 3. Because of its widespread use across research, the complex Morlet wavelet (σ = 6) was used to calculate the CWT of three signals, all containing N = 100,000 samples. The Morlet wavelet is defined as a plane wave modulated by a Gaussian envelope. The parameter σ controls the time–frequency resolution tradeoff^{18}. The first signal was generated to be nonstationary using a sine wave whose frequency changed linearly from f_{start} = 1 Hz to f_{end} = 7 Hz. The second and third signals contained uniformly random noise and a stationary piecewise defined function, respectively. Three different signals were used to prove fCWT’s flexibility and signal independence. Nevertheless, the signal content and wavelet choice are irrelevant to the performance of fCWT (see Methods for details).
All CWT implementations, including fCWT, use a nearcontinuous frequency scale containing 3,000 frequencies (range, f_{0} = 1 Hz to f_{1} = 32 Hz), evenly spaced in exponential space. fCWT thus features a highfrequency resolution in the lowfrequency spectrum and a lower frequency resolution in the highfrequency spectrum.
PyWavelet^{19} and SciPy^{20} execution times were measured in a Python 3.8.6 environment, using the Timeit library inside the code to exclude compile time. The overhead resulting from the translation between C and Python was removed by estimating the intersection factor of the linear relationship between signal size and execution time. MATLAB v2019b and Mathematica 12.0.0.0 execution times were measured using the programspecific timing functions that measure the exact kernel execution times.
Wavelib^{21} was used as the benchmark’s baseline algorithm as it is the reference CWT C/C++ library^{9}, and most microcontrollers are programmed using C/C++. Wavelib^{21} thus serves as a baseline for the reported speedups (Fig. 3). The reported execution times were obtained from an eightcore 2.30GHz central processing unit (CPU) via 100 successive runs, which removed the influence of caching behavior. A 10s pause between runs was implemented to prevent the CPU from overheating. Outliers that deviated by more than 3 s.d. from the mean were removed. Wavelib and SciPy had three outliers, leaving N = 97 samples for all algorithms to ensure equal group sizes. A repeatedmeasures analysis of variance (ANOVA) revealed that the algorithms differed significantly, F(4, 93) = 2,474,778.911, P ≪ 0.001, η^{2} = 1.000, where F denotes the ANOVA statistic based on the ratio of mean squares, which indicates the ratio between the explained and unexplained variance or, in other words, the between and withingroup variability. P is the probability that an observed difference occurred by chance, and η^{2} ‘indicates the proportion of variance accounted for (that is, a generalization of r/r^{2} and R/R^{2} in correlation/regression analysis)^{13}. Also, all pairwise comparisons were highly significant (P ≪ 0.001, Bonferronicorrected), with fCWT being, respectively, 122 times and 34 times faster than the reference Wavelib^{21} and the fastest available algorithm, PyWavelet^{19}. Figure 3 presents descriptive statistics for all distributions.
The fast running time of fCWT was also compared to two other fast time–frequency estimation algorithms: the STFT and DWT. In this benchmark, STFT uses a Blackman window of 500 ms with 400ms overlap, and DWT uses 20 dyadic (that is, a^{j} = 2^{j}) scales of Debauchie decomposition. The parameters were chosen to reflect actual usage in realworld applications (Fig. 1). Both algorithms are implemented and benchmarked in MATLAB using the inprogram timing functions. CWT implementations use 600 frequencies, evenly spaced in exponential space. Fewer frequencies are used to reduce memory usage.
To assess whether or not the algorithms perform in real time (that is, an algorithmic computation time less than the signal’s duration), we define the realtime analysis ratio (RAR):
with Δt_{computation} and Δt_{signal} being the duration of the computation and signal, respectively. In the case of RAR > 1, an algorithm does not operate in real time. In the case of RAR just shy of 1, the algorithm is unlikely to run in real time as the time–frequency calculation is merely one step in a processing pipeline. When RAR ≪ 1, realtime operation is likely to be achieved or within reach. For all six CWT implementations and two traditional time–frequency techniques (that is, STFT and DWT), Fig. 3b shows RAR versus sampling frequency. The RARs were obtained by averaging 100 successive runs on 10s signals with varying sampling frequencies (range, f_{s0} = 1 kHz to f_{s1} = 200 kHz). fCWT and CWT used 5s signals to fit memory constraints. Small fluctuations in RAR are caused by the stochastic nature of benchmarks performed under realworld conditions. It should be noted that the sampling frequency is directly related to the number of samples. Therefore, we test fCWT’s performance for different signal lengths.
STFT and DWT exhibit superior realtime behavior on signals with sampling frequencies up to 200 kHz and beyond. However, they achieve these very high speeds because of their considerable drop in precision, as shown in Fig. 2. Therefore, STFT and DWT are not suitable for wideband highresolution time–frequency estimation. In these cases, CWT is favored. However, even the fastest CWT implementation available tends to be extremely slow compared to STFT and DWT. fCWT merges the best of both worlds, yielding realtime behavior on signals with sampling frequencies up to 200 kHz. This has brought CWT’s execution time close to that of STFT and DWT, while having 25 times to 100 times the spectral resolution of DWT throughout the spectral domain. As such, fCWT is a truly competitive realtime, highresolution alternative for STFT and DWT.
fCWT allows signals with 34 to 122 times the sampling frequency of existing CWT implementations. Figure 3 shows fCWT’s capability of analyzing signals up to 200 kHz in real time, whereas the fastest implementation of CWT fails at f_{s} = 30 kHz. Consequently, fCWT enables realtime analysis of highfrequency signal dynamics, as exist in audio (for example, loudspeaker characterization^{22}, full band speech coding^{23} and paralinguistic analysis^{24}), biosignals (for example, brain–computer interfaces^{12} and peripheral signals such as ECG, electromyography, electrodermal activity and respiration^{11,13}), image and video (for example, distance transforms^{25,26}), sonar and radar^{27,28}, network analysis (for example, renewable energy management^{16,17} and cybersecurity^{14,15}) and machine fault diagnosis^{29,30} (Fig. 1).
Synthetic data
fCWT’s spectral resolution is equal to that of CWT. In contrast to many other CWT optimization studies, we do not compromise precision. To demonstrate this, we compared fCWT to CWT on both clean and noisy synthetic datasets (see Data availability statement for details). Each dataset consists of three wavepackets that validate an algorithm on spectral and temporal resolution and bandwidth size. A noisy dataset was generated to mimic realistic conditions and assess noise resilience.
Quantitative assessment of each algorithm’s performance is carried out by calculating the perwavepacket mean absolute percentage error (MAPE) scores of 100 runs on both datasets between actual frequencies and the time–frequency ridges extracted from the spectra (see Methods for details). The MAPE scores of the clean data are based on one run, as they are completely deterministic. We used a relative error measure to weight errors at all frequencies evenly.
Next to fCWT and CWT, STFT and DWT were also included, allowing us to show the speed–accuracy tradeoff that currently dominates the time–frequency landscape. STFT is based on calculating multiple traditional FTs with overlapping fixedsized windows. The STFT is very fast and efficient as it relies on the fast Fourier transform (FFT). However, the use of fixedsized windows requires the wavelengths to be close to the window size. Hence, frequency resolution changes drastically over the spectrum, and only a small frequency band can be analyzed at the same time. DWT does not have this drawback. It does not rely on a window function. Similar to CWT, it uses wavelets that dilate and contract with frequency to represent the signal. However, in contrast to CWT, it uses far fewer wavelets to represent the signal. This makes DWT a very fast time–frequency estimator. Finally, to complete the time–frequency landscape and allow a thorough comparison on accuracy, we added the highresolution Wigner–Ville distribution (WVD)^{4}, the advanced Hilbert–Huang transform (HHT)^{31} and the more recent empirical wavelet transform (EWT)^{32}. WVD has the highest time–frequency resolution mathematically possible and HHT and EWT improve the resolution by using a slow but accurate adaptive iterative process to decompose a signal into fundamental functions that are not necessarily sine functions (for example, FFT). Manual tuning obtained the following parameters for optimal time–frequency sharpness. fCWT and CWT use the complex Morlet wavelet (σ = 6) and a frequency scale of 480 frequencies (range, f_{0} = 0.25 Hz to f_{1} = 250 Hz), evenly spaced in exponential space (cf. the 111Benchmark section). STFT uses a 500ms Blackman window with 400ms overlap, DWT uses 11 dyadic (that is, a^{j} = 2^{j}) scales of 15order Daubechie wavelet decomposition, and WVD does not take parameters. HHT and EWT use a frequency resolution of 0.25 Hz. HHT uses seven intrinsic modes that were extracted using a maximum signaltoresidual ratio of 20 as a stopping criterion. EWT decomposes the signal using a peak threshold of 5%. Outliers that deviated more than 3 s.d. from the mean were removed. The HHT had four outliers, which resulted in N = 96 for all algorithms to ensure equal group sizes.
Overall, the perwavepacket MAPE scores differed significantly on both the clean and noisy datasets between the algorithms (F(6, 90) = 112, 243.890, P ≪ 0.001, η^{2} = 1.000; Fig. 4). Within each algorithm, the perwavepacket MAPE scores also differed significantly between each other (F(2, 94) = 399.044, P ≪ 0.001, η^{2} = 0.895) However, fCWT and CWT generated similar, low MAPE scores on both the clean and noisy datasets for all three wavepackets. This was confirmed by a correlation analysis per wavepacket, respectively r(94) = 0.996, P < 0.001, r(94) = 1.000, P < 0.001 and r(94) = 0.997, P < 0.001. The low MAPE scores can be explained by CWT’s and fCWT’s wavelet convolution, which averages fluctuations of a signal at different scales^{33}, and its redundancy (that is, wavelets are not orthogonal at different scales), which reduces noise by canceling out the random signal components^{34}. Hence, both can separate frequency bands and their details across the full frequency range. When compared to the slow CWT, fCWT’s accuracy and noisehandling capabilities are not compromised by its highly efficient implementation. Small differences in the time–frequency spectrum can be seen at the edges. However, these differences are caused by MATLAB’s mitigation of edge artifacts (202020Implementation of fCWT section in the Methods).
STFT cannot extract details of the lower frequency bands present in the first and third wavepackets. The wavelengths of these waves are too long for the 500ms window we used, whereas a larger window cannot distinguish the complex nonstationary behavior of the first packet. Nevertheless, STFT shows strong noisehandling capabilities that result from the averaging effect of FFT’s inherited convolution. DWT is powerful in denoising, but not suitable for time–frequency analysis. WVD suffers from its wellknown artifacts, which are only made worse by the additive noise^{4}. HHT and EWT are very good at separating the frequency bands of the clean dataset. Unfortunately, HHT’s frequency estimations, and to a lesser extent those from EWT, fluctuate heavily, leading to high MAPE values. These distortions are caused by the interference between the multiple wavefunctions in each wavepacket. This effect increases dramatically for both algorithms in the noisy dataset^{4}.
EEG
Owing to its ease of measurement and high temporal resolution, the vast majority of neuroscience studies are based on EEG measurements^{35}. As EEG measures brain activity via electrodes on the skull, no medical procedures are needed. However, such external measurements do suffer from increased noise. Fluctuations in EEG caused by brain activity are orders of magnitude smaller than the disturbances caused by eye, face and body movements^{36}. Therefore, studies average the recordings of many trials to cancel random fluctuations. Unfortunately, the use of repeated trials removes the temporal advantage of EEG and prevents its applicability in realtime implementations, which rely on singletrial estimation.
The oftenused FFT cannot handle the highly nonstationary character of EEG signals. Additionally, EEG sampling frequencies are often 1 kHz, and the simultaneous recording of 64 electrodes is standard. Hence, highspeed, nonstationary, time–frequency analysis is essential to have any chance of success in singletrial estimation. This is a criterion that current time–frequency techniques are unable to meet. Techniques like STFT and DWT^{8} are fast but lack the desired resolution in representation, whereas methods like CWT^{6} are precise but lack speed. fCWT fuses the best of both worlds by accelerating the highresolution CWT by 34 to 122 times. So, we can improve the resolution by ≥34 times or handle ≥34 times as many data than the fastest CWT implementation available in the same time frame. To demonstrate the impact of realtime superresolution on neuroscience, fCWT was thus benchmarked against fullresolution CWT and fast STFT, and DWT on a singletrial EEG dataset of subjects performing mental arithmetic tasks^{37}.
Because active concentration is known to be most visible in the frontal region of the brain^{36}, the signals of three frontal electrodes (prefrontal 1, prefrontal 2 and midfrontal in the 10–20 system^{36}) were averaged to reduce local fluctuations. We analyzed the resulting signal in the δ (delta), θ (theta), α (alpha), β (beta) and γ (gamma) frequency bands, using a frequency range that spans five octaves (f_{0} = 2 Hz to f_{1} = 64 Hz). Simultaneous analysis of all these frequency bands is vital for cognitive task experiments, with prefrontal δ frequencies (2–4 Hz) being associated with attention and motivation^{38}, and the power of θ oscillations (4−7 Hz) reflecting memory encoding and retrieval^{39}. Lower αdesynchronization (8–13 Hz) relates to taskunspecific attentional demands and βband (13–30 Hz) power increases with demanding cognitive tasks^{36}. The γ oscillations (~30−100 Hz) indicate complex cognitive thinking (for example, object recognition and sensory processing^{40}). Consequently, fullrange, highresolution frequency analysis is vital.
The analysis of CWT, fCWT, STFT and DWT was complemented with 3.0%CWT (that is, CWT with fCWT’s RAR; Fig. 5). 3.0%CWT enables a fair comparison between the realtime resolution of CWT and full fCWT using 650 frequencies and 3.0%CWT using 20 frequencies. The three CWTs use the complexvalued Morlet wavelet (σ = 20), tuned for optimal time–frequency resolution. Based on manual tuning we set a 500ms Blackman window with 400ms overlap for STFT and 11 dyadic (that is, a^{j} = 2^{j}) scales of 15order Debauchie wavelet decomposition for DWT, enabling maximal time–frequency sharpness. RAR versus the number of 1kHz channels was calculated for fullresolution CWT and fCWT, STFT and DWT.
The resolution difference between the equally fast full fCWT and 3.0%CWT is most prominent during the mental arithmetic task. Realtime fCWT distinguishes different EEG frequency bands much better than realtime CWT. The sheer amount of subdivisions in the frequency spectrum allows fCWT to show the small chaotic βfrequency variations often seen during active concentration^{36} and the slow oscillating δband power associated with motivation^{38}, in real time. Having the same runtime, the fastest CWT implementation fails. Although STFT can separate frequencies in the βfrequency (13–30 Hz) and γfrequency (~30−100 Hz) bands, it suffers from low spectral resolution in the δfrequency (<4 Hz) and θfrequency (4–7 Hz) bands. Hence, STFT makes wideband EEG analysis impractical. Again, DWT was shown to be unsuitable for detailed time–frequency analysis.
fCWT’s power excels when an entire array of EEG electrodes is analyzed in real time. Although the use of EEG is gaining popularity, its low spatial resolution remains a huge drawback. Figure 5 shows that the fastest CWT implementation available can only handle ~20–24 electrodes (or streams of data) simultaneously at full resolution in real time. By contrast, fCWT is easily capable of calculating realtime, highresolution time–frequency representations of stateoftheart EEG setups with up to 512 electrodes.
In vivo electrophysiology
Using depth electrodes, local field potentials (LFPs) measure local voltage changes inside the brain caused by the activity of neuron clusters. LFPs are recorded in vivo and, consequently, they do not suffer from the skull’s highfrequency mask behavior. Consequently, the γfrequency (~30–100 Hz) and high γfrequency (>100 Hz) bands can be reliably recorded, these being bands that highly correlate with single neuron firing and reflect aspects of movement (in the motor cortex^{41}) and vision (in the visual cortex^{42}). Recording these frequencies requires sampling rates that are several times those used for EEGs (that is, 2–3 kHz). Furthermore, in vivo electrophysiology techniques^{43} use huge amounts of electrodes^{44}. LFPs are often recorded simultaneously at 100–300 channels, or even more^{45}. In the future, data bandwidth is expected to increase even more than its recent tremendous increases. Neuropixels^{43}, Utah arrays^{44} and Michigan probes^{46} are currently able to measure hundreds of LFPs and thousands of neurons simultaneously. Realtime LFP time–frequency analysis could lead to nextgeneration prostatics^{41}. Unfortunately, current implementations are unable to handle these bandwidths without compromising resolution. fCWT shows that superresolution can be maintained when analyzing hundreds of highbandwidth LFP data streams simultaneously.
Rodent in vivo electrophysiology data from the Allen Brain Observatory data collection^{47} were analyzed. During randomly alternating fullfield, high and lowcontrast flashes, six Neuropixel probes^{43} with 374 electrodes (Neuropixel 3a; 20 μm vertical electrode separation) each recorded a mouse visual cortex’s responses. LFPs were obtained by downsampling the data to 1.25 kHz and filtering using a 1,000Hz lowpass filter. Full fCWT and CWT, 3.0%CWT (EEG section), STFT and DWT time–frequency estimations were performed on 9 s of raw singletrial LFP data containing four stimuli.
We compared CWT and fCWT to STFT and DWT, as the latter two are used in situations where speed is key. Other time–frequency algorithms offer much higher resolution but are orders of magnitude slower, making them impractical for LFP analysis.
The analysis covers a frequency range from f_{0} = 8 Hz to f_{1} = 128 Hz, allowing simultaneous analysis of both low frequency (that is, α and β bands) and high frequency (that is, γ and high γ bands), which is very important as they reflect different aspects of task performance. Lowfrequency LFPs unveil longdistance communication, whereas highfrequency activity reflects local neural processing^{48}. As the interplay between these frequency ranges discloses the coordination at the inter and intracortical level^{49}, realtime, wideband time–frequency estimation is key in the LFP analysis of complex brain mechanics.
The three CWTs use the complexvalued Morlet wavelet (σ = 16), tuned for optimal time–frequency resolution. Based on manual tuning we set a 500ms Blackman window with 400ms overlap for STFT and 11 dyadic (that is, a^{j} = 2^{j}) scales of 15order Debauchie wavelet decomposition for DWT, enabling maximal time–frequency sharpness. The RAR versus number of channels was also calculated for fCWT and CWT at full resolution and STFT and DWT for a 2.5kHz input signal.
The subfigures of Fig. 6c show the ability of realtime, full fCWT to separate multiple βfrequency components (16, 20 and 25 Hz), locate four γ bursts and reveal the overall γfrequency dynamics, all at the same time. By contrast, realtime 3.0%CWT misses two out of four γ bursts, cannot separate lowfrequency β components, and loses higher γfrequency dynamics. With STFT, the resolution is on par in the midfrequency range, but the high and lowfrequency ranges suffer from low resolution. Despite their very high speeds, both STFT and DWT are unsuitable for broadband, highresolution, time–frequency estimations.
Electrode density is set to increase dramatically; for example, 5,000electrode Neuropixels have already been announced^{50}. Figure 6d shows RAR (equation (1)) versus the number of channels per algorithm. Full CWT can hardly process 15 LFP channels (or data streams) in real time. By contrast, fCWT offers a realtime, fullresolution performance for up to 350–400 channels. Considering the Allen Brain Observatory dataset, fCWT supports realtime analysis and feature extraction of three to four entire Neuropixel probes, whereas the fastest CWT implementation available supports only onetenth of a single probe.
Discussion
One of WT’s most powerful features is the possibility to use custom wavelets. However, not all wavelet types are suitable for existing fast approximate CWT implementations, which rely on finite impulse response filters^{4}. fCWT does not suffer from this setback, as it calculates wavelets starting directly from its definition. With custom wavelets, fCWT performance can be improved even further^{51}. As such, fCWT enables the realtime analysis of highfrequency nonstationary signals, such as in audio^{22,23,24,52}, biosignals (for example, brain–computer interfaces^{12} and ECG^{11,13}), image and video^{25,26}, sonar and radar^{27,28}, renewable energy management^{16,17}, cybersecurity^{14,15} and machine fault diagnosis^{29,30,53} (Fig. 1).
The implementation of fCWT could be extended to other time–frequency methods as well. The synchrosqueezed transform (SST)^{54} uses reassignment to sharpen the CWT spectrum, and the chirplet transform (CT)^{55}, superlets (SL)^{6} and the noiselet transform (NT)^{56} use atoms to describe a signal, sharing a waveletlike implementation. Future research could explore speedups of these algorithms and bring them to realtime applications. Hence, fCWT’s impact is broader than CWTbased applications alone. Consequently, we did not include the SST, CT, SL and NT in the benchmark study, as these rely on the CWT in their core. These secondorder techniques as well as modifications of the included firstorder techniques (for example, smoothed WVD^{6}) are by definition slower than the already expensive CWT.
fCWT shares its mathematical definition with CWT and, hence, without compromise, inherits both all its benefits^{10} and all its limitations (for example, its degrading spectral resolution^{57} and increasing redundancy in higher frequency ranges^{5}). Fortunately, these are wellknown limitations that have solutions^{4,54}. Moreover, the time–frequency landscape keeps growing, including new CWT implementations^{58}. We therefore invite everyone to compare their implementations against fCWT’s open source^{59}, and, to extend its validity, we invite all to apply fCWT on more extensive and different specimens that fall outside this paper’s scope.
fCWT allows an acceleration in the developments of science and engineering, industry and health (Fig. 1). Although maintaining CWT’s full resolution and supporting customization, fCWT enables realtime time–frequency analysis of nonstationary signals. As such, fCWT can bring offline research that is hindered by the low resolution of DWT, the limited range of STFT and/or the computational burden of CWT into realtime practice.
Methods
Datasets
In this Resource paper, three types of data were used: synthetic, EEG and in vivo electrophysiological data. Details on each dataset are described in the following subsections.
Synthetic data
Two synthetic datasets were generated for this paper, both composed of the same three timevarying wavepackets with a sampling frequency of 500 Hz:

1.
Three 5s sine waves, the frequencies of which gradually change between 100 and 110 Hz, 20 and 22 Hz and 5 and 6 Hz, respectively, with a periodicity of 1 Hz.

2.
Two 5s sine waves with linearly changing frequencies between [5, 50] and [100, 50] Hz.

3.
Three 10s lowfrequency waves of 2, 1 and 0.5 Hz. All wavepackets are separated by 0.5 s and are multiplied by a Gaussian window function to mitigate discontinuities at the boundaries.
One set contained clean data and the other was contaminated with white Gaussian noise with a 1:1 signaltonoise ratio (SNR) across the whole signal, with the SNR being determined by the average power. Both datasets have a total duration of 21.0 s and are available in the fCWT CodeOcean repository^{59}.
EEG
The EEG mental arithmetic dataset by Zyma et al.^{37} was obtained from PhysioNet^{60} and loaded into MATLAB R2021a. EEG data were recorded monopolarly at 500 Hz, using Ag/Ag electrodes and the Neurocom EEG 23channel system (Ukraine, XAIMEDICA). The International 10/20 scheme was used for electrode placement. Electrodes were referenced to the interconnected ear reference electrodes. Data were preprocessed using a 30Hz highpass filter and a 50Hz power line notch filter. Common EEG artifacts were removed using independent component analysis. All participants had normal or correctedtonormal vision and had no mental or cognitive impairment.
In this paper we use the data of subject 13, a 24year old male who excelled in mental arithmetic by performing 34 subtractions between fourdigit and twodigit numbers in 4 min. Subject 13 was chosen to ensure task compliance. We used the last 30 s of EEG during rest and the first 30 s of EEG during the arithmetic task.
In vivo electrophysiology
In vivo electrophysiology data were collected from The Visual Coding—Neuropixels project^{47}. LFP data from female specimen 738651054 from stimuli IDs 3861−3864 were used. Six Neuropixel version 3a probes were inserted into the mouse visual cortex. In this study, LFP data from fifth probe (Probe ‘e’) channel 63 were used. The 250ms highcontrast stimuli, 2,000 ms apart, alternate in random order. Mice were shown a neutral gray screen between stimuli. Additional technical, experimental and medical details about the dataset can be found in ref. ^{47}.
Mathematical preliminaries
The Fourier transform
With its core idea that a function, often a signal, can always be decomposed into pure sine and cosine functions, the FT is foundational in spectral pattern analysis^{3,4,8,61}. However, not all functions f(t) can be decomposed—only those that live in the Lebesgue space L^{2}(0, 2π). This space includes all functions that are (1) finite in energy, (2) 2πperiodic and (3) squareintegrable, formally
which allows f(t) to be represented as a weighted sum of complex wavefunctions:
with the Fourier coefficients c_{n} given by the amount of overlap between the conjugated complex wavefunction and the function f(t):
or in discrete form when used on actual digital samples in a sequence f having length N:
In other words, any 2πperiodic, squareintegrable function f(t) can be represented by this superposition of complexvalued sinusoidal waves that are translated in the frequency domain. However, this is precisely Fourier’s pitfall; not all functions, or signals for that matter, are 2πperiodic. FTs cannot decompose the wide variety of nonstationary functions that are not 2πperiodic. Unfortunately, this constraint is often misunderstood, and FT are still used to analyze signals with varying frequencies.
The mathematical reason behind FT’s constraint becomes apparent when we consider the Lebesgue space \(L^2({\mathbb{R}})\) containing all squareintegrable functions that have finite energy along the entire real axis:
The reason why equation (4) cannot represent these functions is that pure sine waves extend to infinity and therefore do not have finite energy. Pure waves do not lie in \(L^2({\mathbb{R}})\) and, as such, they cannot represent its functions.
Wavelets
We can define a set of functions other than equation (4) that do have finite energy. The result is the set of short periodic functions ψ(t) called wavelets that are well localized in both the time and frequency domains^{5,6,8,33,57,62}. Consequently, wavelets need to be able to translate in both domains as well:
where ψ_{jk} is a daughter wavelet function, defined as the mother wavelet ψ(t) scaled in the frequency domain by j and translated in the time domain by k. So, the WT outputs a 2D time–frequency matrix, where the FT gives a 1D frequency spectrum.
Similar to equation (4), the superposition of these wavelets can represent any function
where, like with the FT, the wavelet coefficients c_{jk} are given by the amount of overlap between the wavelet and the function f(t). This definition also shows us that wavelets, similar to Fourier’s pure wavefunctions, live in Hilbert space as multiplication between two functions is defined as an inner product:
in which \({\overline{\psi }}_{jk}\) corresponds to the conjugate of ψ_{jk}. However, as j and k can be any real number, we have to define both variables’ optimal discretization such that the resulting time–frequency matrix does not under or overdetermine the function f(t). So, the variables should be discretized such that the wavelets form an orthogonal basis in Hilbert space^{63,64}—in other words, such that the wavelet functions have zero overlap.
Wavelets are orthogonal in Hilbert space if
from which it follows that equation (8) is indeed logarithmic orthogonal. The WT that uses this type of discretization is called the DWT^{8,65,66}. In this context, ‘discrete’ refers to the use of its wavelets, not to the type of data it processes. As all DWT’s wavelets are orthogonal, it describes a function by the minimal number of wavelet coefficients possible. However, as stated at the beginning of this paper, a redundant, overcomplete representation is often much more favorable for signal analysis. Therefore, it is also possible to define a WT with arbitrary wavelet discretization. Such a wavelet transformation is called the CWT^{67}. Again, ‘continuous’ does not refer to the type of data it can handle. CWT features continuously scalable and translatable wavelets that allow a much more precise analysis of a signal’s spectrum:
which comes with considerable computational complexity. When implemented digitally, its discrete form is used:
which is mathematically equivalent to passing the input signal through a series of wavelet filters of different lengths. Care is required at the boundaries of the signal. As the discrete form assumes signals of finite length, wavelet coefficients near the boundaries become increasingly meaningless. Instantaneous frequency at the first or last sample is impossible to calculate as one should know how the signal continues. There are several strategies to solve this uncertainty. For more details about this topic, see the Boundary effects section.
Equation (10)’s computational complexity can be estimated using the trapezoidal rule for integral solving and assuming a signal of length N = 2^{J}. Furthermore, we assume J wavelets at a_{j} = 2^{j} discrete scales, and a wavelet length of L samples at unit scale. Starting at unit scale a_{0} = 1, we then have O(a_{0}NL) complexity, with the cost of all scales resulting in
In other words, a naïve approach to DWT calculation would result in a polynomial complexity of O(N^{2}). CWT would be even worse, as the discretization of the time and frequency domains is much finer. Fortunately, scientists quickly realized a considerable reduction in computational complexity could be achieved using Parseval’s theorem.
Fourierbased wavelet transform
Applying Parseval’s theorem to equation (12), a reduction in CWT’s complexity can be achieved:
Subsequently, we define \({\overline{\widehat{{\psi }_{a,\,b}}{(\xi )}}}\) in terms of the FT of the mother wavelet function ψ(t), using its basic timeshifting and timescaling properties:
Substitution gives
or in its discrete form
which describes W_{ψ}f[a, b] as an inverse FT of \({{\hat{f}}{[k]}{\overline{\hat{\psi }{[ak]}}}}\). So, WT’s computational complexity no longer depends on the timeoffset parameter b. As \({\hat{f}{[k]}}\) can be calculated beforehand, it is reduced to three distinct steps per scale:

1.
Generate \({\overline{\hat{\psi }{[ak]}}}\)

2.
Calculate \({{\hat{f}}{[k]}{\overline{\hat{\psi }{[ak]}}}}\) and

3.
Evaluate the inverse FT and obtain W_{ψ}f[a, b],
with the first two steps evaluated in O(N) and the last one requiring at least O(Nlog_{2}N) when using a fast FT implementation^{68,69}. This results in O(Nlog_{2}N) complexity, a considerable reduction compared to O(N^{2}), which is needed for the naïve approach. Additionally, the constant factor of this complexity can be reduced even more, as we will see in the next section.
Implementation of fCWT
Fourierbased wavelet transformation’s computational complexity is mainly determined by the inverse FT. Consequently, equation (12) has been rewritten regularly to use spline interpolation of the wavelet and circumvent the FT entirely^{70,71}. Spline interpolation, also known as polynomial interpolation, defines a wavelet by only a few evenly spaced sampling points across the domain. Because the number of points is independent of the wavelet’s scale, the theoretical complexity of equation (12) is reduced to linear time. However, while complexity is lowered, the constant factor that equals the number of sampling points has been increased tremendously. In turn, this yields a tradeoff between speed and accuracy: more interpolation points leads to increases in both precision and computation time. Additionally, the spline interpolation only works for specific wavelet types. To avoid the tradeoff, we optimize the Fourierbased wavelet transformation by reducing the constant factor of its computational complexity. In this way, we maintain WT’s ability to use custom wavelet types^{51} and can exploit optimized FFT libraries^{72,73,74}.
fCWT separates scaleindependent and scaledependent operations, which have to be performed separately for each wavelet’s scale. A detailed schematic of fCWT’s algorithmic implementation is provided in Extended Data Fig. 1. With CWTs, the frequency scale is often divided into hundreds of scales. We thus focused the optimization on the fCWT’s scaledependent part by exploiting its repeated nature and high parallelizability. The scaleindependent operations are performed first as their result forms the input for the scaledependent steps. We precalculate two functions: (1) the input signal’s FFT and (2) the FFT of the mother wavelet function at scale a_{0} = 2. Both functions are independent of the scale factor a, so they can be precalculated and used as lookup tables in the processing pipeline.
FFT
Using the float and AVX2enabled Fastest Fourier Transform in the West (FFTW) library^{73}, the input signal’s FFT is calculated. FFTW has superior performance in various benchmarks^{75} and has the ability to dynamically optimize its algorithmic implementation. FFTW determines the most efficient way to calculate the signal’s FFT with length N on hardware setup X. This requires considerable time, which makes it only useful in situations where many FFTs are calculated with the same N and X. This is the case with fCWT, as its scaledependent part evaluates a fixedlength inverse FFT for every scale factor a. Other highperformance FFT libraries include the Fastest Fourier Transform in the South^{72} and Intel’s Math Kernal Library^{74}. However, as Fastest Fourier Transform in the South lacks important optimization techniques and Intel’s Math Kernel Library is limited to Intel processors only, FFTW is currently the most flexible and versatile highperformance FFT library available.
Before a signal’s FFT is calculated, it is first zeropadded to the nearest power of two, which allows more timeefficient calculations than with other signal lengths. Zero padding lets all signals that map to the same nearest power of two use the same FFTW optimization. Hence, the flexibilty of fCWT as a tool is preserved while still enjoying the benefit of FFTW’s optimization plans. However, it will result in steplike performance behavior as seen in Fig. 3. After FFT calculation, we let FFTW write the complexvalued FT to memory in an interleaving format (Extended Data Fig. 2). Using this, we exploit the CPU’s predictive caching behavior and hence reduce memory access in the next steps. Because a CPU works with chunks of memory instead of single values, it always caches adjacent memory next to a requested value as well^{26,76}. While we access the real part of a value, interleaving takes advantage of this behavior as the complex part is cached. Consequently, accessing the complex part after the real part does not require an additional memory request, which reduces memory accesses by 50%.
Scaleindependent mother wavelet generation
The FFT of the mother wavelet function \({\hat{{{\varPsi }}}}{[k]}\) is generated once during the scaleindependent step. Because wavelets in the frequency domain uniformly contract as their scale increases, daughter wavelet functions can be generated by downsampling a pregenerated mother wavelet function. Because scales must be at least a_{min} = 2, we generate the mother wavelet function at a_{0} = 2 to save memory. It is important to note that the mother wavelet function is generated directly from its analytical Fouriertransformed definition. Consequently, we create \({\hat{{{\varPsi }}}}{[k]}\) such that its length always matches that of \({\hat{f}}{[k]}\). This ensures fCWT’s independence of wavelet length and achieves the highest wavelet resolution possible.
After calculation of the FFT signal and the generation of the FFT mother wavelet, the scaleindependent step is complete. fCWT proceeds to the scaledependent phase (Extended Data Fig. 1). This phase is repeated m = ∣a∣ times. Using m steps with step size Δa, the scale factors a are defined by discretizing the frequency spectrum evenly on a logarithmic scale:
This generates the wavelet coefficient matrix W_{ψ}f[a, b] one row at a time.
Scaledependent downsampling
Each iteration of the scaledependent step first generates the Fouriertransformed daughter wavelet function \({\hat{\psi }}_{a}{[k]}\) by downsampling the mother wavelet function generated in the scaleindependent step. This optimization is realized by using the mother wavelet as a lookup table (Extended Data Fig. 3). Hence, as explained earlier, the expensive Gaussian calculations involved in wavelet calculation are removed from the scaledependent step. The daughter wavelet is generated by only performing a systematic lookup that accesses every ath value of the mother wavelet function. A schematic overview of this process is shown in Extended Data Fig. 3.
Scaleindependent multiplication
Using the single instruction, multiple data (SIMD) model, another acceleration is achieved. By using the CPU’s full power, eight multiplications are executed at once^{77,78}, which is used to exploit the elementalwise multiplication between \({\hat{\psi }}_{a}{[k]}\) and \({\hat{f}{[k]}}\). In our case, SIMD performs four complexvalued multiplications in parallel, because the multiplication between the realvalued daughter wavelet and complexvalued Fouriertransformed input signal takes two multiplications per element. By exploiting the parallelizable nature of this step, an additional speedup of 4× is achieved. Extended Data Fig. 4 shows this process graphically.
An additional acceleration is achieved by merging the generation of the daughter wavelet (Scaledependent downsampling section) and the multiplication with \({\hat{f}{[k]}}\) (Scaleindependent multiplication section) in one loop. Consequently, no intermediate results are stored in memory, which largly eliminates memory access.
Scaleindependent inverse FFT
Finally, using FFTW’s inverse FFT function, the result is transferred back to the time domain. Similar to the FFT calculation in the scaleindependent step, the inverse FFT uses a precalculated optimization based on the input signal’s zeropadded length. The complexvalued time–frequency matrix is stored in rowmajor order as an array of 2NM floats, where N is the signal length and M the number of scales. Each value is stored as two floats as the matrix is complexvalued.
Boundary effects
Because CWT uses convolution to calculate the wavelet coefficients, a wavelet is eventually close enough to the beginning or end of the signal to be multiplied with undefined data outside the boundaries of the signal. In these situations, frequency becomes a meaningless construct as one does not know how a signal would proceed beyond these limits. As this effect becomes more evident with larger wavelets (that is, lower frequencies) one can speak of a cone of influence^{33} caused by the edges that affect the entire spectrum. Several strategies exist to handle these socalled boundary effects^{4,79,80}.
One could extend a signal by adding zeros at the beginning and the end to define data outside the boundaries. Because convolution relies on the elementwise multiplication between the signal and the wavelet, this strategy is similar to stopping the convolution at the boundary. Other strategies rely on making assumptions about the signal outside its bounds. For example, the signal could be extended by mirroring or repeating the signal at its boundaries^{4}. With fCWT, we decided to let the users decide themselves. As fCWT is designed to be independent of signal content, we assume an unbiased zero extension. Consequently, users can choose their own boundary strategy by extending the signal manually before the fCWT is applied.
The direct result of fCWT’s strategy can be seen in the Synthetic data section. At both edges, fCWT shows a strong cone of influence effect of the boundary. MATLAB, by default, performs signal extension, which mitigates these artifacts. However, MATLAB’s default extension strategy sometimes leads to an increase in artifacts instead of a reduction. An extreme example can be seen in a visual comparison between both techniques in Extended Data Fig. 5. Consequently, with fCWT we went for an unbiased zero extension strategy aiming for maximal transparency and flexibility.
Time–frequency ridge extraction
To perform quantitative assessment of time–frequency spectra on the synthetic data, a time–frequency ridge extraction methodology is used. This allows a comparison between the ridges (that is, frequency components) in the time–frequency spectra and the actual frequency components used to generate the dataset.
The synthetic dataset (see the Data availability statement for details) consists of three distinct wavepackets. The time–frequency ridge extraction is performed on each wavepacket separately. Each segment is defined such that it trims the first 0.5 s and last 0.5 s of each wavepacket to remove the Gaussian window function influence. In the third wavepacket, 3.0 s is trimmed from the end to remove the influence of boundary effects (Boundary effects section).
MATLAB’s tfridge() is used to extract, respectively, three, two and three ridges from the first, second and third wavepacket, as it is the most used approach to ridge extraction. To do so, tfridge() needs predefined penalty coefficients (P_{coef}), which determine the stability of the ridge estimation. As wavepackets and time–frequency algorithms largely differ in their characteristics, these penalty coefficients need to be optimized manually for each combination. Manual optimization is performed greedy by first testing different orders of magnitude (P_{mag}): P_{mag} ∈ {10^{−3}, 10^{−2}, 10^{−1}, 10^{0}, 10^{1}, 10^{2}, 10^{3}}. When the optimal magnitude range [P_{mag,}_{1}, P_{mag,2}] is selected, ten equally distanced coefficients are tested within that range P_{coef} ∈ P_{mag,1} ⋅ {0, 1, 2, …, 8, 9}. The resulting penalty coefficient is chosen for the benchmark. All penalty coefficients are provided in the source data for Fig. 4.
A fair comparison among the algorithms was secured, as the same stable ridge extraction was applied on all included algorithms. However, in future work, alternate opensource algorithms could be worth exploring^{81}. These might yield highly accurate ridge extractions and/or remove the need for manually tuned parameters. As such, this might result in an even more finegrained comparison among the algorithms.
Data availability
The generated synthetic dataset used in Fig. 4 is provided under ‘data’ in the CodeOcean fCWT capsule^{59}. The ‘EEG During Mental Arithmetic Tasks v1.0.0’ used in Fig. 5 is available at https://physionet.org/content/eegmat/1.0.0/. The in vivo electrophysiology data collected by The Visual Coding—Neuropixels project^{47} and used in Fig. 6 is available in the Neurodata Without Borders (NWB) format via AllenSDK (https://allensdk.readthedocs.io). An example Jupyter Notebook for accessing the LFP data is available at https://allensdk.readthedocs.io/en/latest/_static/examples/nb/ecephys_lfp_analysis.html. Source data are provided with this paper.
Code availability
fCWT is released under Apache License Version 2.0 and will be maintained in a public GitHub repository available at https://github.com/fastlib/fCWT. fCWT is available for Mac OSX, Linux and Windows systems and features a detailed description on how to obtain Visual Studio projectfiles and generate cppbased MEXpackages for easy MATLAB integration. For benchmark reproducibility, a version of fCWT at the time of publication is available on CodeOcean^{59}.
References
Gabor, D. Theory of communication. Part 1: the analysis of information. J. Inst. Electr. Eng. 93, 429–441 (1946).
Fano, R. M. Transmission of Information: A Statistical Theory of Communications (MIT Press, 1961).
Boukouvala, E., Miridakis, N. & Veloni, A. Digital and Statistical Signal Processing (CRC Press, 2019).
Boashash, B. Time–Frequency Signal Analysis and Processing: A Comprehensive Reference 2nd edn (Academic, 2016).
Addison, P. S. Introduction to redundancy rules: the Continuous Wavelet Transform comes of age. Philos. Trans. R. Soc. A Math. Phys. Eng. Sci. 376, 20170258 (2018).
Moca, V. V., Bârzan, H., NagyDabâcan, A. & Mureçan, R. C. Time–frequency superresolution with superlets. Nat. Commun. 12, 337 (2021).
Stockwell, R. G., Mansinha, L. & Lowe, R. P. Localization of the complex spectrum: the S transform. IEEE Trans. Signal Process. 44, 998–1001 (1996).
Cohen, L. Time–Frequency Analysis (Prentice Hall, 1995).
Smeets, H., Ceriotti, M. & Marrón, P. J. Adapting recursive sinusoidal software oscillators for lowpower fixedpoint processors. ACM Trans. Embedded Comput. Syst. 19, 1–26 (2020).
Adeli, H., Zhou, Z. & Dadmehr, N. Analysis of EEG records in an epileptic patient using wavelet transform. J. Neurosci. Methods 123, 69–87 (2003).
Sharma, K., Castellini, C., van den Broek, E. L., AlbuSchaeffer, A. & Schwenker, F. A dataset of continuous affect annotations and physiological signals for emotion analysis. Sci. Data 6, 196 (2019).
Nason, S. R. et al. A lowpower band of neuronal spiking activity dominated by local single units improves the performance of brain–machine interfaces. Nat. Biomed. Eng. 4, 973–983 (2020).
van den Broek, E. L. Affective Signal Processing (ASP): Unraveling the Mystery of Emotions. PhD thesis, Univ. Twente (2011); https://doi.org/10.3990/1.9789036532433
Dalal, M. & Juneja, M. Steganography and steganalysis (in digital forensics): a cybersecurity guide. Multimed. Tools Appl. 80, 5723–5771 (2021).
Derbeko, P., Dolev, S. & Gudes, E. Waveletbased dynamic and privacypreserving similitude data models for edge computing. Wirel. Netw. 27, 351–366 (2021).
Eroğlu, H., Cuce, E., Cuce, P. M., Gul, F. & Iskenderoğlu, A. Harmonic problems in renewable and sustainable energy systems: a comprehensive review. Sustain. Energy Technol. Assess. 48, 101566 (2021).
Adebayo, T. S. & Kirikkaleli, D. Impact of renewable energy consumption, globalization and technological innovation on environmental degradation in Japan: application of wavelet tools. Environ. Dev. Sustain. 23, 16057–16082 (2021).
Carmona, R., Hwang, W.L. & Torresani, B. Practical Time–Frequency Analysis: Gabor and Wavelet Transforms, with an Implementation in S (Academic, 1998).
Lee, G. R., Gommers, R., Waselewski, F., Wohlfahrt, K. & O Leary, A. PyWavelets: a Python package for wavelet analysis. J. Open Source Softw. 4, 1237 (2019).
Virtanen, P. et al. SciPy 1.0: fundamental algorithms for scientific computing in Python. Nat. Methods 17, 261–272 (2020).
Hussain, R. Wavelib (GitHub, 2015); https://github.com/rafat/wavelib
Beerends, J. G., van Nieuwenhuizen, K. & van den Broek, E. L. Quantifying sound quality in loudspeaker reproduction. J. Audio Eng. Soc. 64, 784–799 (2016).
Beerends, J. G. et al. Subjective and objective assessment of full bandwidth speech quality. IEEE/ACM Trans. Audio Speech Lang. Process. 28, 440–449 (2020).
van den Broek, E. L., van der Sluis, F. & Dijkstra, T. in Philips Research Book Series Vol. 12, Ch. 10 (eds Westerink, J. H. D. M., Krans, M. & Ouwerkerk, M.) 153–180 (Springer Science+Business Media B.V., 2011).
Karam, C., Sugimoto, K. & Hirakawa, K. Fast convolutional distance transform. IEEE Signal Process. Lett. 26, 853–857 (2019).
Schouten, T. E. & van den Broek, E. L. Fast exact Euclidean distance (FEED): a new class of adaptable distance transforms. IEEE Trans. Pattern Anal. Mach. Intell. 36, 2159–2172 (2014).
Huang, Z., Shi, Y., Tang, B. & Zhang, J. Unimodular multipleinput–multipleoutput radar waveform design with desired correlation properties. IET Radar Sonar Navigation. (2021); https://doi.org/10.1049/rsn2.12192
Gao, C., Wang, D., Qiao, K. & Jiang, X. Optical system design of fully symmetrical Fourier transform lens. Optical Rev. 28, 349–357 (2021).
Hannon, B., Sergeant, P., Dupré, L. & Pfister, P.D. Twodimensional Fourierbased modeling of electric machines—an overview. IEEE Trans. Magn. 55, 8107217 (2019).
Jalayer, M., Orsenigo, C. & Vercellis, C. Fault detection and diagnosis for rotating machinery: a model based on convolutional LSTM, fast Fourier and continuous wavelet transforms. Comput. Ind. 125, 103378 (2021).
Huang, N. E. & Shen, S. S. P. Hilbert Huang Transform and its Applications 2nd edn, Vol. 16 (World Scientific, 2014).
Gilles, J. Empirical wavelet transform. IEEE Trans. Signal Process. 61, 3999–4010 (2013).
Dremin, I. M., Ivanov, O. V. & Nechitailo, V. A. Wavelets and their uses. Phys. Uspekhi 44, 447–478 (2001).
Huang, N. E. et al. The empirical mode decomposition and the Hilbert spectrum for nonlinear and nonstationary time series analysis. Proc. R. Soc. A Math. Phys. Eng. Sci. 454, 903–995 (1998).
ValdesSosa, P. A. et al. The Cuban Human Brain Mapping Project, a young and middle age populationbased EEG, MRI and cognition dataset. Sci. Data 8, 45 (2021).
Cacioppo, J. T., Tassinary, L. G. & Berntson, G. G. Handbook of Psychophysiology 4th edn (Cambridge Univ. Press, 2017).
Zyma, I. et al. Electroencephalograms during mental arithmetic task performance. Data 4, 14 (2019).
Knyazev, G. G. EEG delta oscillations as a correlate of basic homeostatic and motivational processes. Neurosci. Biobehav. Rev. 36, 677–695 (2012).
Kahana, M. J., Sekuler, R., Caplan, J. B., Kirschen, M. & Madsen, J. R. Human theta oscillations exhibit task dependence during virtual maze navigation. Nature 399, 781–784 (1999).
Engel, A. K., Fries, P. & Singer, W. Dynamic predictions: oscillations and synchrony in top–down processing. Nat. Rev. Neurosci. 2, 704–716 (2001).
Mehring, C. et al. Inference of hand movements from local field potentials in monkey motor cortex. Nat. Neurosci. 6, 1253–1254 (2003).
Womelsdorf, T., Fries, P., Mitra, P. P. & Desimone, R. Gammaband synchronization in visual cortex predicts speed of change detection. Nature 439, 733–736 (2006).
Jun, J. J. et al. Fully integrated silicon probes for highdensity recording of neural activity. Nature 551, 232–236 (2017).
Nordhausen, C. T., Maynard, E. M. & Normann, R. A. Single unit recording capabilities of a 100 microelectrode array. Brain Res. 726, 129–140 (1996).
Frank, J. A., Antonini, M.J. & Anikeeva, P. Nextgeneration interfaces for studying neural function. Nat. Biotechnol. 37, 1013–1023 (2019).
Campbell, P. K., Jones, K. E., Huber, R. J., Horch, K. W. & Normann, R. A. A siliconbased, threedimensional neural interface: manufacturing processes for an intracortical electrode array. IEEE Trans. Biomed. Eng. 38, 758–768 (1991).
Siegle, J. H. et al. Survey of spiking in the mouse visual system reveals functional hierarchy. Nature 592, 86–92 (2021).
Einevoll, G. T., Kayser, C., Logothetis, N. K. & Panzeri, S. Modelling and analysis of local field potentials for studying the function of cortical circuits. Nat. Rev. Neurosci. 14, 770–785 (2013).
Fries, P. A mechanism for cognitive dynamics: neuronal communication through neuronal coherence. Trends Cogn. Sci. 9, 474–480 (2005).
Steinmetz, N. A. et al. Neuropixels 2.0: a miniaturized highdensity probe for stable and longterm brain recordings. Science 372, eabf4588 (2021).
Unser, M. & Chenouard, N. A unifying parametric framework for 2D steerable wavelet transforms. SIAM J. Imaging Sci. 6, 102–135 (2013).
Qiu, Z., Lee, C.M., Xu, Z. & Sui, L. A multiresolution filteredx LMS algorithm based on discrete wavelet transform for active noise control. Mech. Syst. Signal Process. 66, 458–469 (2016).
Huo, Z., Zhang, Y., Francq, P., Shu, L. & Huang, J. Incipient fault diagnosis of roller bearing using optimized wavelet transform based multispeed vibration signatures. IEEE Access 5, 19442–19456 (2017).
Daubechies, I., Lu, J. & Wu, H.T. Synchrosqueezed wavelet transforms: an Empirical Mode Decompositionlike tool. Appl. Comput. Harmonic Anal. 30, 243–261 (2011).
Mann, S. & Haykin, S. in Vision Interface, Vol. 91, 205–212 (Citeseer, 1991).
Coifman, R., Geshwind, F. & Meyer, Y. Noiselets. Appl. Comput. Harmonic Anal. 10, 27–44 (2001).
Strang, G. Wavelets. Am. Sci. 82, 250–255 (1994).
Chu, J. P. & Kemere, C. T. Ghostipy: an efficient signal processing and spectral analysis toolbox for large data. eNeuro 8, ENEURO.020221.2021 (2021); https://doi.org/10.1523/ENEURO.020221.2021
Arts, L. P. A. & van den Broek, E. L. The fast continuous wavelet transformation (fCWT): realtime, high quality, noiseresistant, timefrequency analysis (Code Ocean, 2021); https://doi.org/10.24433/CO.8389373.v1
Goldberger, A. L. et al. PhysioBank, PhysioToolkit and PhysioNet: components of a new research resource for complex physiologic signals. Circulation 101, e215–e220 (2000).
Bracewell, R. N. The Fourier Transform and its Applications Vol. 31999 (McGrawHill, 1986).
Daubechies, I. The Wavelet Transform, Time–Frequency Localization and Signal Analysis (Princeton Univ. Press, 2009).
Mallat, S. G. Multiresolution approximations and wavelet orthonormal bases of l^{2}(r). Trans. Am. Math. Soc. 315, 69–87 (1989).
Halmos, P. R. Introduction to Hilbert Space and the Theory of Spectral Multiplicity (Dover, 2017).
Heil, C., & Walnut, D. F. Fundamental Papers in Wavelet Theory (Princeton Univ. Press, 2009).
Shensa, M. J. The discrete wavelet transform: wedding the à trous and Mallat algorithms. IEEE Trans. Signal Process. 40, 2464–2482 (1992).
AguiarConraria, L. & Soares, M. J. The continuous wavelet transform: moving beyond uni and bivariate analysis. J. Econ. Surv. 28, 344–375 (2014).
Johnson, S. G. & Frigo, M. A modified splitradix FFT with fewer arithmetic operations. IEEE Trans. Signal Process. 55, 111–119 (2006).
Lundy, T. & Van Buskirk, J. A new matrix approach to real FFTs and convolutions of length 2^{k}. Computing 80, 23–45 (2007).
Muñoz, A., Ertlé, R. & Unser, M. Continuous wavelet transform with arbitrary scales and O(N) complexity. Signal Process. 82, 749–757 (2002).
Unser, M., Aldroubi, A. & Schiff, S. J. Fast implementation of the continuous wavelet transform with integer scales. IEEE Trans. Signal Process. 42, 3519–3523 (1994).
Blake, A. M., Witten, I. H. & Cree, M. J. The fastest Fourier transform in the south. IEEE Trans. Signal Process. 61, 4707–4716 (2013).
Frigo, M. & Johnson, S. G. FFTW: an adaptive software architecture for the FFT. In Proc. 1998 IEEE International Conference on Acoustics, Speech and Signal Processing, ICASSP’98 3, (eds Atlas, L., Huang, X., Hermansky, H. & Hwang, J.) 1381–1384 (IEEE, 1998).
Wang, E. et al. in HighPerformance Computing on the Intel® Xeon Phi™ (eds Wang, E. et al.) 167–188 (Springer, 2014).
Frigo, M. & Johnson, S. G. BenchFFT (2017); http://www.fftw.org/benchfft/
Stallings, W. Computer Organization and Architecture: Designing for Performance (Pearson Education India, 2003).
Chakrabarti, C. & Vishwanath, M. Efficient realizations of the discrete and continuous wavelet transforms: from single chip implementations to mappings on SIMD array computers. IEEE Trans. Signal Process. 43, 759–771 (1995).
Jamieson, L. H., Mueller, P. T.Jr & Siegel, H. J. FFT algorithms for SIMD parallel processing systems. J. Parallel Distrib. Comput. 3, 48–71 (1986).
Mallat, S. A Wavelet Tour of Signal Processing (Elsevier, 1999).
Mertins, A. & Mertins, D. A. Signal Analysis: Wavelets, Filter Banks, Time–Frequency Transforms and Applications (Wiley, 1999).
Iatsenko, D., McClintock, P. V. E. & Stefanovska, A. Extraction of instantaneous frequencies from ridges in time–frequency representations of signals. Signal Process. 125, 290–303 (2016).
Abbott, B. P. et al. Observation of gravitational waves from a binary black hole merger. Phys. Rev. Lett. 116, 061102 (2016).
Burnol, A. et al. Waveletbased analysis of ground deformation coupling satellite acquisitions (Sentinel1, SMOS) and data from shallow and deep wells in Southwestern France. Sci. Rep. 9, 8812 (2019).
Petrucco, L. Mouse head schema (Zenodo, 2020); https://doi.org/10.5281/zenodo.3925903
Acknowledgements
Both authors (L.P.A.A. and E.L.v.d.B.) have received funding for this work from the European Union’s Horizon 2020 research and innovation program under grant agreement no. 952095, from the Intrinsic Motivations to Transitional Wearable INtelligent companions for autism spectrum disorder (IMTWIN) project. The funders had no role in study design, data collection and analysis, decision to publish or preparation of the manuscript.
Author information
Affiliations
Contributions
L.P.A.A. carried out all programming, performed the empirical validation experiments and created the figures. E.L.v.d.B. and L.P.A.A. composed the final paper together. All authors reviewed and agreed the source code and manuscript. Figure 1 includes two subfigures from other sources, which are used with permission of respectively Caltech/MIT/Ligo Laboratory and Nature.
Corresponding authors
Ethics declarations
Competing interests
The authors declare no competing interests.
Peer review
Peer review information
Nature Computational Science thanks Leontios Hadjileontiadis, Madhur Srivastava and the other, anonymous, reviewer(s) for their contribution to the peer review of this work. Handling editor: Jie Pan, in collaboration with the Nature Computational Science team.
Additional information
Publisher’s note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Extended data
Extended Data Fig. 1 Algorithmic implementation of fCWT
The algorithmic implementation behind fCWT can be divided into: i) scaleindependent and ii) scaledependent operations. The scaledependent operations each calculate the wavelet coefficients of a single scalefactor in the final time–frequency matrix. By repeating the scaledependent part m = ∣a∣ times, the time–frequency matrix is build up one row at a time.
Extended Data Fig. 2 FFTW’s interleaving storing format
Using an interleaving value format, the Fastest Fourier Transform in the West (FFTW) writes a complexvalued Fourier transform to memory. As the CPU caches adjacent values when accessing memory, accessing the complex and real part only requires single memory access instead of two.
Extended Data Fig. 3 From mother to daughter wavelet
The generation of the daughter wavelet \({\hat{\psi }}_{a}[k]\) is done efficiently by downsampling the mother wavelet \(\hat{\Psi }[k]\). This eliminates the need for expensive Gaussian calculations in the scaledependent step. The mother wavelet is only calculated once in the scaleindependent step.
Extended Data Fig. 4 SIMD multiplication
fCWT combines the generation of the daughter wavelet and its multiplication with the Fourier transformed input signal together in one Single Instruction, Multiple Data (SIMD) multiplication. As the Fourier transformed input signal is complexvalued, the real daughter wavelet values are copied twice such that SIMD can perform an elementwise multiplication between both buffers. In this example a scalefactor of a = 3 is used.
Extended Data Fig. 5 Boundary effects in fCWT and MATLAB
With fCWT we perform zero extension to mitigate boundary effects. In contrast, by default MATLAB uses a content dependent mirror extension. In some cases, such an extension strategy can increase boundary effect severity instead of decreasing it as can be seen here.
Supplementary information
Supplementary Table 1
Detailed statistical descriptions of MAPE error distributions as plotted in Fig. 4. Results are obtained from 100 runs of seven time–frequency methods on a synthetic dataset consisting of three wavepackets with SNR = 0 dB Gaussian noise added.
Source data
Figure 2 source data
Zipped example and heatmap source data.
Figure 3 source data
Statistical and experimental source data.
Figure 4 source data
Zipped statistical and heatmap source data.
Figure 5 source data
Zipped experimental and heatmap source data.
Figure 6 source data
Zipped experimental and heatmap source data.
Source Data Extended Data Fig. 5
Zipped example and heatmap source data.
Rights and permissions
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made. The images or other third party material in this article are included in the article’s Creative Commons license, unless indicated otherwise in a credit line to the material. If material is not included in the article’s Creative Commons license and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/.
About this article
Cite this article
Arts, L.P.A., van den Broek, E.L. The fast continuous wavelet transformation (fCWT) for realtime, highquality, noiseresistant time–frequency analysis. Nat Comput Sci 2, 47–58 (2022). https://doi.org/10.1038/s4358802100183z
Received:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1038/s4358802100183z
Further reading

Revisiting signal analysis in the big data era
Nature Computational Science (2022)