
- SciPy - Home
- SciPy - Introduction
- SciPy - Environment Setup
- SciPy - Basic Functionality
- SciPy - Relationship with NumPy
- SciPy Clusters
- SciPy - Clusters
- SciPy - Hierarchical Clustering
- SciPy - K-means Clustering
- SciPy - Distance Metrics
- SciPy Constants
- SciPy - Constants
- SciPy - Mathematical Constants
- SciPy - Physical Constants
- SciPy - Unit Conversion
- SciPy - Astronomical Constants
- SciPy - Fourier Transforms
- SciPy - FFTpack
- SciPy - Discrete Fourier Transform (DFT)
- SciPy - Fast Fourier Transform (FFT)
- SciPy Integration Equations
- SciPy - Integrate Module
- SciPy - Single Integration
- SciPy - Double Integration
- SciPy - Triple Integration
- SciPy - Multiple Integration
- SciPy Differential Equations
- SciPy - Differential Equations
- SciPy - Integration of Stochastic Differential Equations
- SciPy - Integration of Ordinary Differential Equations
- SciPy - Discontinuous Functions
- SciPy - Oscillatory Functions
- SciPy - Partial Differential Equations
- SciPy Interpolation
- SciPy - Interpolate
- SciPy - Linear 1-D Interpolation
- SciPy - Polynomial 1-D Interpolation
- SciPy - Spline 1-D Interpolation
- SciPy - Grid Data Multi-Dimensional Interpolation
- SciPy - RBF Multi-Dimensional Interpolation
- SciPy - Polynomial & Spline Interpolation
- SciPy Curve Fitting
- SciPy - Curve Fitting
- SciPy - Linear Curve Fitting
- SciPy - Non-Linear Curve Fitting
- SciPy - Input & Output
- SciPy - Input & Output
- SciPy - Reading & Writing Files
- SciPy - Working with Different File Formats
- SciPy - Efficient Data Storage with HDF5
- SciPy - Data Serialization
- SciPy Linear Algebra
- SciPy - Linalg
- SciPy - Matrix Creation & Basic Operations
- SciPy - Matrix LU Decomposition
- SciPy - Matrix QU Decomposition
- SciPy - Singular Value Decomposition
- SciPy - Cholesky Decomposition
- SciPy - Solving Linear Systems
- SciPy - Eigenvalues & Eigenvectors
- SciPy Image Processing
- SciPy - Ndimage
- SciPy - Reading & Writing Images
- SciPy - Image Transformation
- SciPy - Filtering & Edge Detection
- SciPy - Top Hat Filters
- SciPy - Morphological Filters
- SciPy - Low Pass Filters
- SciPy - High Pass Filters
- SciPy - Bilateral Filter
- SciPy - Median Filter
- SciPy - Non - Linear Filters in Image Processing
- SciPy - High Boost Filter
- SciPy - Laplacian Filter
- SciPy - Morphological Operations
- SciPy - Image Segmentation
- SciPy - Thresholding in Image Segmentation
- SciPy - Region-Based Segmentation
- SciPy - Connected Component Labeling
- SciPy Optimize
- SciPy - Optimize
- SciPy - Special Matrices & Functions
- SciPy - Unconstrained Optimization
- SciPy - Constrained Optimization
- SciPy - Matrix Norms
- SciPy - Sparse Matrix
- SciPy - Frobenius Norm
- SciPy - Spectral Norm
- SciPy Condition Numbers
- SciPy - Condition Numbers
- SciPy - Linear Least Squares
- SciPy - Non-Linear Least Squares
- SciPy - Finding Roots of Scalar Functions
- SciPy - Finding Roots of Multivariate Functions
- SciPy - Signal Processing
- SciPy - Signal Filtering & Smoothing
- SciPy - Short-Time Fourier Transform
- SciPy - Wavelet Transform
- SciPy - Continuous Wavelet Transform
- SciPy - Discrete Wavelet Transform
- SciPy - Wavelet Packet Transform
- SciPy - Multi-Resolution Analysis
- SciPy - Stationary Wavelet Transform
- SciPy - Statistical Functions
- SciPy - Stats
- SciPy - Descriptive Statistics
- SciPy - Continuous Probability Distributions
- SciPy - Discrete Probability Distributions
- SciPy - Statistical Tests & Inference
- SciPy - Generating Random Samples
- SciPy - Kaplan-Meier Estimator Survival Analysis
- SciPy - Cox Proportional Hazards Model Survival Analysis
- SciPy Spatial Data
- SciPy - Spatial
- SciPy - Special Functions
- SciPy - Special Package
- SciPy Advanced Topics
- SciPy - CSGraph
- SciPy - ODR
- SciPy Useful Resources
- SciPy - Reference
- SciPy - Quick Guide
- SciPy - Cheatsheet
- SciPy - Useful Resources
- SciPy - Discussion
SciPy - Wavelet Packet Transform (WPT)
Wavelet Packet Transform in SciPy
The Wavelet Packet Transform (WPT) is an advanced signal processing technique that extends the Discrete Wavelet Transform (DWT) by allowing the decomposition of both approximation and detail coefficients at each level. This provides a more detailed analysis of signals by making WPT useful in applications requiring finer frequency resolution such as feature extraction, compression and denoising.
Mathematically the Wavelet Packet Transform of a signal x(t) can be represented as follows −
$\mathrm{W(j, k, n) = \int_{-\infty}^{\infty} x(t) \psi^* \left( \frac{t - k}{2^j} \right) dt}$
Where −
- x(t) is the input signal.
- (t) is the mother wavelet.
- = 2j is the scale factor.
- = k is the translation parameter.
- n is the node index in the wavelet packet tree.
- W(j, k, n) represents the wavelet packet coefficients at scale j, position k and node n.
Key Properties of WPT
Following are the key properties of the Wavelet Packet Transform −
- Full Decomposition: Unlike DWT, WPT decomposes both approximation and detail coefficients at each level by providing richer signal representation.
- Better Frequency Resolution: WPT offers improved frequency localization compared to DWT by making it suitable for fine-grained spectral analysis.
- Flexible Signal Representation: WPT enables adaptive signal representation based on application-specific requirements.
- Computational Complexity: Due to the full decomposition, WPT requires more computational resources than DWT.
As with DWT, WPT can be implemented using the PyWavelets (pywt) library which offers powerful functions for wavelet packet analysis.
Using PyWavelets (pywt) for WPT
If we want to perform Wavelet Packet Transform in Python, PyWavelets provides easy-to-use functions to handle WPT efficiently.
Basic Example of WPT using PyWavelets
The Wavelet Packet Transform (WPT) provides a more detailed signal decomposition compared to the standard Discrete Wavelet Transform (DWT). In this example we will analyze a composite signal using the Daubechies wavelet ('db1') and decompose it into multiple subbands. WPT allows for a richer frequency-time analysis by making it suitable for applications such as audio processing, biomedical signal analysis and fault detection.
Let's perform a Wavelet Packet Transform on a sample signal and visualize the decomposition −
import numpy as np import pywt import matplotlib.pyplot as plt # Generate a composite signal with two sine waves of different frequencies t = np.linspace(0, 1, 512, endpoint=False) signal = np.sin(2 * np.pi * 50 * t) + np.sin(2 * np.pi * 120 * t) # Perform Wavelet Packet Transform using Daubechies wavelet ('db1') wp = pywt.WaveletPacket(data=signal, wavelet='db1', mode='symmetric', maxlevel=3) # Extract coefficients from level 3 nodes coeffs = [node.data for node in wp.get_level(3, order='freq')] # Plot original signal and wavelet packet coefficients plt.figure(figsize=(10, 8)) # Plot original signal plt.subplot(len(coeffs) + 1, 1, 1) plt.plot(t, signal, label="Original Signal", color='blue') plt.title("Original Signal") plt.legend() # Plot wavelet packet coefficients at different nodes for i, coef in enumerate(coeffs): plt.subplot(len(coeffs) + 1, 1, i + 2) plt.plot(coef, label=f"Node {i}") plt.title(f"Wavelet Packet Coefficients - Node {i}") plt.legend() plt.tight_layout() plt.show()
Following is the output of the Basic Wavelet Packet Transform using PyWavelets −

Optimal Subband Selection in WPT
Wavelet Packet Transform (WPT) provides a more flexible decomposition of signals compared to standard Discrete Wavelet Transform (DWT) by allowing decomposition at all frequency bands. Selecting the optimal subband in WPT is crucial for applications like signal compression, denoising and feature extraction.
The selection is typically based on criteria such as entropy, energy or statistical measures that quantify the amount of useful information in each subband.
Common Criteria for Subband Selection
- Energy-based Selection: Measures the total energy within each subband to select the most significant one.
- Entropy-based Selection: Chooses the subband with the highest entropy which contains the most information.
- Reconstruction Error: Selecting subbands that minimize reconstruction error to retain the most relevant data.
- Variance or Statistical Measures: Uses variance to quantify the spread of coefficients which helps in feature extraction tasks.
In this example we will perform a Wavelet Packet Transform on a synthetic signal and select the subband with the highest energy −
import numpy as np import pywt import matplotlib.pyplot as plt # Generate a synthetic signal (sum of sine waves) t = np.linspace(0, 1, 512, endpoint=False) signal = np.sin(2 * np.pi * 50 * t) + np.sin(2 * np.pi * 120 * t) # Perform 3-level Wavelet Packet Transform using 'db1' wavelet wp = pywt.WaveletPacket(data=signal, wavelet='db1', mode='symmetric', maxlevel=3) # Retrieve all subbands at the maximum decomposition level nodes = wp.get_level(3, order='freq') # Calculate energy for each subband subband_energies = [np.sum(node.data**2) for node in nodes] # Identify the optimal subband (maximum energy) optimal_subband_index = np.argmax(subband_energies) optimal_subband = nodes[optimal_subband_index].data # Plot original signal and the optimal subband plt.figure(figsize=(10, 6)) # Plot original signal plt.subplot(2, 1, 1) plt.plot(t, signal, label="Original Signal", color='blue') plt.title("Original Signal") plt.legend() # Plot optimal subband plt.subplot(2, 1, 2) plt.plot(optimal_subband, label=f"Optimal Subband (Node {optimal_subband_index})", color='red') plt.title(f"Optimal Subband with Highest Energy - Node {optimal_subband_index}") plt.legend() plt.tight_layout() plt.show()
The following output shows the original signal along with the selected optimal subband containing the highest energy by making it useful for further analysis −

Applications of WPT
The Wavelet Packet Transform (WPT) is widely used in various fields, especially where fine frequency analysis is required. Some key applications are as follows −
- Speech and Audio Processing: WPT provides enhanced resolution for audio compression and speech recognition.
- Biomedical Signal Analysis: Used in ECG and EEG analysis for feature extraction and noise reduction.
- Image Compression: WPT helps in efficient compression by offering adaptive subband decomposition.
- Fault Diagnosis: WPT is employed in mechanical and electrical systems for detecting abnormalities in vibration signals.
Choosing the Right Wavelet for WPT
Choosing an appropriate wavelet function for WPT is crucial for optimal signal representation. Some commonly used wavelets include −
Wavelet | Best For | Example Use Cases |
---|---|---|
Daubechies (db) | Smooth signals | Speech and audio processing |
Coiflet | Biomedical signals | EEG/ECG analysis |
Symlet | Symmetric signals | Compression |