Medformer: A Multi-Granularity Patching Transformer for Medical Time-Series Classification

Yihe Wang,Nan Huang,Taida Li,Yujun Yan,Xiang Zhang
2024-10-19
Abstract:Medical time series (MedTS) data, such as Electroencephalography (EEG) and Electrocardiography (ECG), play a crucial role in healthcare, such as diagnosing brain and heart diseases. Existing methods for MedTS classification primarily rely on handcrafted biomarkers extraction and CNN-based models, with limited exploration of transformer-based models. In this paper, we introduce Medformer, a multi-granularity patching transformer tailored specifically for MedTS classification. Our method incorporates three novel mechanisms to leverage the unique characteristics of MedTS: cross-channel patching to leverage inter-channel correlations, multi-granularity embedding for capturing features at different scales, and two-stage (intra- and inter-granularity) multi-granularity self-attention for learning features and correlations within and among granularities. We conduct extensive experiments on five public datasets under both subject-dependent and challenging subject-independent setups. Results demonstrate Medformer's superiority over 10 baselines, achieving top averaged ranking across five datasets on all six evaluation metrics. These findings underscore the significant impact of our method on healthcare applications, such as diagnosing Myocardial Infarction, Alzheimer's, and Parkinson's disease. We release the source code at <a class="link-external link-https" href="https://github.com/DL4mHealth/Medformer" rel="external noopener nofollow">this https URL</a>.
Signal Processing,Artificial Intelligence,Machine Learning
What problem does this paper attempt to address?
The paper attempts to address several key challenges in the classification of medical time series (MedTS). Specifically, existing methods mainly rely on manually extracted biomarkers and convolutional neural network (CNN)-based models, with limited exploration of transformer-based methods. These existing methods fail to fully utilize the unique characteristics of MedTS data, such as local temporal dynamics, cross-channel correlations, and multi-scale feature analysis. To address these issues, the authors propose Medformer, a multi-granularity patch transformer specifically designed for MedTS classification. Medformer enhances learning capabilities through the following three novel mechanisms: 1. **Cross-Channel Patch Embedding**: Effectively captures multi-timestamp and cross-channel features through a cross-channel patch embedding method. This is the first application of cross-channel patch embedding in time series analysis. 2. **Multi-Granularity Patches**: Uses patches of different lengths, enabling the model to capture features at different scales. This approach can simulate different frequency bands and capture features of specific bands without relying on manual up/down sampling and band-pass filters. 3. **Two-Stage Multi-Granularity Self-Attention Mechanism**: Captures features within each granularity and their correlations through a two-stage self-attention mechanism (intra-granularity and cross-granularity), achieving complementary integration of cross-scale information. The authors conducted extensive experiments on five public datasets, including three EEG datasets and two ECG datasets, tested under both subject-dependent and subject-independent settings. The results show that Medformer achieved the highest average ranking across all six evaluation metrics, highlighting its superiority and potential practical application value in medical applications, such as diagnosing myocardial infarction, Alzheimer's disease, and Parkinson's disease.