Gramian Angular Field (GAF) Transformation
- Gramian Angular Field transformation is a method that converts univariate time series into 2D images using angular encoding, preserving temporal and magnitude correlations.
- It constructs Gramian Angular Summation and Difference Fields through normalization, polar encoding, and trigonometric mapping, resulting in symmetric and skew-symmetric matrices.
- GAF is widely applied in domains like ECG analysis, finance, and trajectory analysis, enabling improved performance with deep convolutional and transformer-based models.
The Gramian Angular Field (GAF) transformation is a family of mathematically principled mappings that encode a one-dimensional sequence—typically a univariate time series or spectral signature—into a 2D matrix designed for image-based analysis. By representing each time point as an angle on the unit circle and expressing the pairwise angular sum or difference relationships as trigonometric matrix entries, GAF exposes the temporal and magnitude correlations as spatial patterns. This transformation is now a widely deployed foundation for leveraging convolutional and transformer-based models designed for images in time series classification, regression, and transfer learning across domains such as medicine, finance, industrial monitoring, and physical trajectory analysis.
1. Mathematical Foundations and Variants
The construction of the Gramian Angular Field proceeds in three algorithmic steps: rescaling, angular (polar) encoding, and matrix formation.
a. Normalization and Polar Encoding
Given a univariate sequence , the data are first rescaled to or :
or equivalently, in for some variants.
Each normalized value is then mapped to an angle:
where (radius) is optional and primarily used for visualization or indexing.
b. Gramian Matrices: GASF and GADF
From the collection of angles , two matrix-valued fields are constructed:
- Gramian Angular Summation Field (GASF):
GASF is symmetric.
- Gramian Angular Difference Field (GADF):
GADF is skew-symmetric.
These definitions appear consistently across applications and are mathematically justified through trigonometric identities (Wang et al., 2015, Long et al., 1 Apr 2025, Yousuf et al., 2023, Garibo-i-Orts et al., 2023, Yeke et al., 5 Dec 2025, Elmir et al., 4 Nov 2025, Paheding et al., 2022).
2. Algorithmic Implementation and Practical Pipeline
The GAF can be constructed as follows:
9
The typical computational cost is 0 per matrix; output matrices are commonly resized (e.g., to 1, 2, or 3) to fit modern CNN input requirements (Elmir et al., 4 Nov 2025, Elmir et al., 2023, You et al., 2023, Yeke et al., 5 Dec 2025). Multiple channels or features can be handled by stacking GASF/GADF tensors across the channel dimension (You et al., 2023, Paheding et al., 2022).
Normalization to 4 is required before applying 5 to avoid domain errors (Wang et al., 2015, Garibo-i-Orts et al., 2023, Yeke et al., 5 Dec 2025).
3. Theoretical Properties and Intuitive Insights
Several invariants and properties characterize GAF images:
- Temporal Dependency Preservation: As both axes of the GAF correspond to time indices, the spatial structure of the matrix preserves the global and local temporal dependencies in the original sequence; lags correspond to off-diagonals (Wang et al., 2015, Garibo-i-Orts et al., 2023).
- Magnitude and Correlation Encoding: The diagonal encodes the self-relations (absolute values), while off-diagonal patterns capture pairwise (co-)evolution. Symmetry and skew-symmetry (for GASF and GADF, respectively) encode additive and subtractive angular relationships (Yeke et al., 5 Dec 2025, Yousuf et al., 2023, Paheding et al., 2022, You et al., 2023).
- Bijectivity: The mapping is invertible up to a sign ambiguity, as the main diagonal (6) allows for original values to be approximately reconstructed (Wang et al., 2015, Chen et al., 2019).
- Robustness: The angular representation constrains the feature space, improving robustness to amplitude scaling and some forms of outlier distortion (Qin et al., 2024, Garibo-i-Orts et al., 2023).
- Channel and Feature Fusion: Stacking multiple GASF/GADF objects or combining with other representations (recurrence plots, Markov transition fields) allows for multi-view learning (Yeke et al., 5 Dec 2025, You et al., 2023, Wang et al., 2015).
4. Applications and Empirical Impact
GAF has enabled advances in a wide array of sequence modeling domains:
| Domain | Paper Reference | GAF Role |
|---|---|---|
| ECG Analysis | (Qin et al., 2024, Elmir et al., 2023, Yousuf et al., 2023, Elmir et al., 4 Nov 2025) | Image representation for CNN classification, federated learning, arrhythmia and MI detection |
| EEG/fNIRS | (Thanaraj et al., 2020, Kothari et al., 2021) | Epilepsy/attention detection, formation of RGB/14-channel images for CNNs/autoencoders |
| BOLD fMRI | (Kancharala et al., 2023) | Image-based classification of brain signals, outperforming LSTM with 2D CNNs |
| Finance | (Long et al., 1 Apr 2025, Xu et al., 2023, Chen et al., 2019) | Domain similarity for transfer learning, pattern classification, quantum GAF for error reduction |
| Optical Fiber | (Yeke et al., 5 Dec 2025) | Multi-channel event detection, EfficientNet/DenseNet with GASF/GADF/RP channels |
| Hyperspectral | (Paheding et al., 2022) | Pixel-wise classification, 2-channel GAF with Neighborhood Attention U-Net |
| Single-particle | (Garibo-i-Orts et al., 2023) | Trajectory analysis, pretrained ResNet/MobileNet, outperforming ConvLSTM and Transformers |
Empirical improvements reported include 2–3% gains in ECG classification tasks over pure time series models (Qin et al., 2024), up to 22.2% F1-score lift in wearable sensor-based disease detection (Soumma et al., 2024), and significant error reduction in financial forecasting using GAF-based similarity measures over baseline CMD/Coral metrics (Long et al., 1 Apr 2025). In federated IoT medical challenges, GAF-based pipelines achieved ~8 pp higher accuracy relative to single-client setups while remaining computationally viable on edge devices (Elmir et al., 4 Nov 2025).
5. Architectural Integration and Design Considerations
The dominant paradigm since GAF's introduction is to use the produced image-like matrices as direct input to deep convolutional backbones (ResNet, EfficientNet, U-Net, ViT, etc.) either as single-channel or multi-channel composites (Qin et al., 2024, Paheding et al., 2022, You et al., 2023, Yeke et al., 5 Dec 2025). Typical configurations include:
- Image resizing: After GAF computation, raw 7 is interpolated or downsampled (commonly 8, 9, or 0) for compatibility with pretrained computer vision networks (Elmir et al., 4 Nov 2025, Yeke et al., 5 Dec 2025).
- Multi-view stacking: GASF, GADF, and other texture fields (e.g., recurrence plots) concatenated as RGB or higher-order tensors (Yeke et al., 5 Dec 2025, You et al., 2023).
- Attention and fusion: Integration of spatial/channel attention modules to emphasize relevant 2D angular features (Paheding et al., 2022, Qin et al., 2024, You et al., 2023).
- Sliding window and padding: Windowing for fixed-size matrix generation, optional zero-padding to harmonize sequence lengths (Garibo-i-Orts et al., 2023, You et al., 2023).
- Resource constraints: On-device pipelines compress GAF to 1 for memory-efficient federated learning (Elmir et al., 4 Nov 2025).
- Quantum-classical hybrid: Quantum GAF (QGAF) implements the inner product in single-qubit circuits, reducing the need for explicit normalization or 2 (Xu et al., 2023).
The construction and application of GAF require careful normalization to 3 to prevent numerical errors, balancing compute/memory cost with window size and resolution, and, in large-scale contexts, batching or approximation to mitigate 4 complexity (Elmir et al., 2023, Long et al., 1 Apr 2025, Garibo-i-Orts et al., 2023).
6. Limitations and Best Practices
The GAF approach exhibits quadratic complexity in both compute and memory, posing challenges for extremely long sequences or real-time applications. Downsampling, approximate GAF construction, or tiling is recommended for scalability (Yeke et al., 5 Dec 2025, Garibo-i-Orts et al., 2023, Elmir et al., 4 Nov 2025). While GAF images encode comprehensive temporal correlations, the information is "entangled" and spatially distributed; thus, some fine detail or local context may be lost upon aggressive downscaling (Garibo-i-Orts et al., 2023, Elmir et al., 2023).
Best practices include:
- Strict normalization to 5 before angular mapping.
- Consistent use of 6 (vs.\ 7) to ensure interpretive stability.
- Generation of both GASF and GADF for complementary correlation pattern coverage.
- Adaptation of image size to balance resolution demands and CNN scalability.
- Multi-channel/fusion architectures when multiple signals are present.
- Validation and tuning for downstream deep models, as hyperparameters (window size, stride, resizing) significantly influence performance (Yeke et al., 5 Dec 2025, Elmir et al., 4 Nov 2025, Garibo-i-Orts et al., 2023).
7. Future Directions
Recent developments encompass the integration of quantum circuits for GAF computation, purportedly removing normalization and 8 requirements and accelerating training convergence (QGAF) (Xu et al., 2023). Another trend includes expanding GAF utility for multi-modal fusion (combining raw sequences, GAFs, recurrence plots, and MTFs) to improve domain transfer and temporal pattern recognition (Long et al., 1 Apr 2025, Yeke et al., 5 Dec 2025). Applications are rapidly growing, from federated and privacy-preserving healthcare on IoT to robust autonomous vehicle behavior analysis (Soumma et al., 2024, You et al., 2023).
Open research questions remain on approximating GAF for online/streaming settings, optimal resizing without loss of crucial temporal features, formal analysis of information loss across channel fusion, and extending GAFs to non-Euclidean or irregularly sampled data. There is also ongoing interest in interpretable models that leverage the structured 2D output of GAF for attribution and model explanation in time series-based decision systems (Garibo-i-Orts et al., 2023, Wang et al., 2015).
The Gramian Angular Field formulation offers a unified mathematical and computational framework for translating sequential amplitude and temporal correlation structure into spatially organized representations that are both theoretically appealing and empirically powerful in the context of modern image-based machine learning (Wang et al., 2015, Qin et al., 2024, Yeke et al., 5 Dec 2025, Elmir et al., 4 Nov 2025, You et al., 2023, Garibo-i-Orts et al., 2023, Yousuf et al., 2023, Elmir et al., 2023, Paheding et al., 2022, Kothari et al., 2021, Thanaraj et al., 2020, Soumma et al., 2024, Long et al., 1 Apr 2025, Xu et al., 2023, Kancharala et al., 2023, Chen et al., 2019).