A Lightweight Transformer for Pain Recognition from Brain Activity
Authors: Stefanos Gkikas, Christian Arzate Cruz, Yu Fang, Lu Cao, Muhammad Umar Khan, Thomas Kassiotis, Giorgos Giannakakis, Raul Fernandez Rojas, Randy Gomez
Organizations: Honda Research Institute Japan, Wako City, Japan · BioSIS (Biosensing & Intelligent Systems) Lab, Centre for Intelligent Computing and Systems, University of Canberra, Canberra, Australia · Department of Electronic Engineering, Hellenic Mediterranean University, Chania, Greece
Pain is a multifaceted and widespread phenomenon with substantial clinical and societal burden, making reliable automated assessment a critical objective. This paper presents a lightweight transformer architecture that fuses multiple fNIRS representations through a unified tokenization mechanism, enabling joint modeling of complementary signal views without requiring modality-specific adaptations or increasing architectural complexity. The proposed token-mixing strategy preserves spatial, temporal, and time-frequency characteristics by projecting heterogeneous inputs onto a shared latent representation, using a structured segmentation scheme to control the granularity of local aggregation and global interaction. The model is evaluated on the AI4Pain dataset using stacked raw waveform and power spectral density representations of fNIRS inputs. Experimental results demonstrate competitive pain recognition performance while remaining computationally compact, making the approach suitable for real-time inference on both GPU and CPU hardware.
Figures & tables
Fig. 1 : Overview of the proposed tokenization framework, using the two fNIRS representations.
Hyperparameter
Value
Depth ( L )
4
Number of latents ( M )
32
Latent dimension ( d )
128
Cross-attention heads
1
Latent self-attention heads
8
Cross-attention head dimension
64
TABLE I : Architectural details.
Optimizer
LR
LR decay
Weight decay
Total epochs
Warmup epochs
Cooldown epochs
Batch size
AdamW
2e-5
cosine
0.1
200
20
10
32
TABLE II : Training configuration.
Input
#Segm.
Computational Cost
Inference Cost
Performance
Params(M)
GFLOPs
Latency (ms) GPU ↓
Samples/s GPU ↑
Latency (ms) CPU ↓
Samples/s CPU ↑
Accuracy
Precision
F1
fNIRS-Wave
–
7.81
2.58
14.26
70.14
22.44
44.56
43.94
42.94
39.34
fNIRS-PSD
–
15.05
15.07
14.36
69.64
56.14
17.81
49.26
47.91
39.90
fNIRS-Wave
2
7.81
0.25
13.33
74.99
11.33
88.27
46.06
42.63
43.20
fNIRS-PSD
2
15.05
12.74
13.40
74.62
51.03
19.59
52.31
46.66
47.76
fNIRS-Wave
4
7.81
0.41
14.31
69.90
11.80
84.75
46.99
44.32
43.59
TABLE III : performance and computational/inference cost of fNIRS representations across latent segmentation settings.
Fig. 2 : Effect of latent segmentation on fNIRS accuracy (averaged across waveform and spectrogram representations) versus computational and inference cost.
Modality
Fusion
Computational Cost
Inference Cost
Performance
Params(M)
GFLOPs
Latency (ms) GPU ↓
Samples/s GPU ↑
Latency (ms) CPU ↓
Samples/s CPU ↑
Accuracy
Precision
F1
fNIRS-Wave
stack
15.15
15.20
13.79
72.54
49.00
20.41
48.52
45.62
44.62
fNIRS-PSD
TABLE IV : performance and computational/inference cost for the representation fusion.
Study
Modality
Method
Accuracy
Video
fNIRS
Features
Model
—
✓
43.30
✓
—
40.10
[ 49 ]
✓
✓
Handcrafted
SVM
41.70
[ 51 ]
✓
✓
Deep
Transformer
46.67
[ 52 ]
✓
—
Deep
2D CNN
49.00
TABLE V : Comparison of studies on the AI4Pain testing set.
Pain is a complex and pervasive phenomenon affecting a large percentage of the population, and accurate assessment is essential for effective clinical management and intervention. Computational pain recognition systems enable continuous monitoring, support clinical decision-making, and help mitigate pain-related distress and functional decline. This study introduces a unified tokenization framework for heterogeneous 3D modalities in pain recognition that provides a single processing pipeline across behavioral and brain-activity 3D data, without requiring separate architectures for each modality or handcrafted inductive biases. The framework preserves spatial, temporal, and time--frequency structure while mapping diverse inputs into a shared token space. Extensive experiments show that the proposed approach effectively processes facial videos and fNIRS data in both raw-signal and spectrogram-based representations. On the AI4Pain benchmark dataset, the proposed framework achieves state-of-the-art performance while maintaining high computational efficiency and enabling real-time assessment on both GPU and CPU hardware.
Stefanos Gkikas, Christian Arzate Cruz, Valentina Becchetti +3
Honda Research Institute Japan Wako City, Japan · Sapienza University of Rome Rome, Italy · University of Canberra Canberra, Australia
Automatic pain localization, which involves identifying the anatomical origin of pain from peripheral physiological signals without patient self-report, is a clinically critical but largely unaddressed problem, particularly for non-verbal patients. This paper presents a systematic comparison of classical feature engineering and deep sequence learning for subject-independent three-class pain localization using the AI4Pain 2026 Challenge dataset, which comprises four synchronously recorded wearable modalities: electrodermal activity, blood volume pulse, respiration, and peripheral oxygen saturation recorded from 65 participants under controlled TENS-induced pain. A 115-dimensional hand-crafted feature set spanning time-domain, frequency-domain, modality-specific, and cross-modal descriptors is benchmarked against end-to-end deep architectures. Extremely Randomized Trees achieves the highest macro-F1 of 0.539, outperforming the best deep model by 7.4 percentage points, with EDA spectral features emerging as the dominant discriminators. A consistent 26-point gap between pain detection (F1,=,0.815) and localization (F1,=,0.552) across all models points to a fundamental ceiling imposed by the anatomical diffuseness of peripheral autonomic pathways at 10-second resolution.
Ioannis Kyprakis, Stefanos Gkikas, Eric Nichols +2
Hellenic Mediterranean University Heraklion, Greece · Honda Research Institute Japan Wako City, Japan
Automatic pain assessment from facial video remains challenging due to the spatial heterogeneity of pain-related facial cues. This study proposes ReFace, a spatial reorganization pipeline that divides facial input into four spatial quadrants before tokenization, rather than processing the entire face as a single region. Evaluated on the AI4Pain dataset, the proposed approach achieves 56.00% accuracy on the test set using video only, achieving the highest reported accuracy under the fixed AI4Pain benchmark protocol among the compared methods. Notably, the four-quadrant configuration processes the same total pixel budget as the full-face input, yet achieves higher accuracy, suggesting that spatial reorganization can improve performance under the proposed tokenization design. A single quadrant region, processing just one quarter of those pixels, remains competitive at a fraction of the computational cost.
Stefanos Gkikas, Yu Fang, Christian Arzate Cruz +2
Honda Research Institute Japan Wako City, Japan · BioSIS (Biosensing & Intelligent Systems) Lab Centre for Intelligent Computing and Systems University of Canberra Canberra, Australia