File size: 4,355 Bytes
16a6294
d08f5d9
 
 
468ddfd
16a6294
468ddfd
5fc8125
468ddfd
16a6294
8bab1ee
 
 
16a6294
468ddfd
bea3f8e
468ddfd
5fc8125
 
 
 
 
 
468ddfd
35b1cb2
16a6294
7aa7a1f
 
 
 
5ef76b7
35b1cb2
468ddfd
35b1cb2
7aa7a1f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35b1cb2
468ddfd
7aa7a1f
696fc5c
 
 
 
 
 
35b1cb2
468ddfd
35b1cb2
 
696fc5c
 
5ef76b7
696fc5c
 
16a6294
35b1cb2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122

---
license: mit
---
# FSL ECG QA Dataset

**FSL ECG QA Dataset** is a **benchmark dataset** used in paper [*"Electrocardiogram–Language Model for Few-Shot Question Answering with Meta Learning"*] (https://arxiv.org/abs/2410.14464). It supports research in combining **electrocardiogram (ECG) signals** with **natural language question answering (QA)**, particularly in **few-shot** and **meta-learning** scenarios.

## Dataset Highlights

- 🧠 **Task Diversification**: Restructured **ECG-QA tasks** promote rapid **few-shot adaptation**.
- 🧬 **Fusion Mapping**: A lightweight **multimodal mapper** bridges **ECG** and **language features**.
- 🚀 **Model Generalization**: **LLM-agnostic design** ensures broad **transferability** and **robustness**.

# 1. Datasets

## 1.1 Load the classes

```python
python load_class.py --base_path /your/actual/path/to/ecgqa/ptbxl/paraphrased --test_dataset ptb-xl
python load_class.py --paraphrased_path /your/actual/path/to/ecgqa/mimic-iv-ecg/paraphrased --test_dataset mimic
(all tested mimic-iv-ecg dataset is listed in "data/processed_test_30k.json")
```
## 1.2 Load ECG QA FSL dataset

```python
python data_loader.py
--model_name /your/actual/path/to/model/download/from/hugging/face
--paraphrased_path /your/actual/path/to/ecgqa/mimic-iv-ecg/paraphrased
--test_dataset ptb-xl
```

## 1.3 Sample of ECG QA FSL dataset

```python
episode = {
    # --- Support Set ---
    "support_x": [  # ECG feature tensors or preprocessed arrays
        ecg_sample_1,  # typically a NumPy array or tensor
        ecg_sample_2,
        # ...
    ],
    "support_y_q": [  # Question token sequences (padded)
        [12, 45, 78, 0, 0, 0],
        [23, 67, 89, 90, 0, 0],
        # ...
    ],
    "support_y_a": [  # Answer token sequences (padded)
        [1, 0, 0, 0, 0, 0],
        [1, 1, 0, 0, 0, 0],
        # ...
    ],
    "support_y_q_mask": [  # Mask for question tokens (1 = valid, 0 = pad)
        [1, 1, 1, 0, 0, 0],
        [1, 1, 1, 1, 0, 0],
        # ...
    ],
    "support_y_a_mask": [  # Mask for answer tokens
        [1, 0, 0, 0, 0, 0],
        [1, 1, 0, 0, 0, 0],
        # ...
    ],
    "flatten_support_x": [  # File paths to raw ECG signals
        "/path/to/support/ecg_1.npy",
        "/path/to/support/ecg_2.npy",
        # ...
    ],

    # --- Query Set ---
    "query_x": [
        ecg_query_1,
        ecg_query_2,
        # ...
    ],
    "query_y_q": [
        [34, 78, 56, 0, 0, 0],
        [90, 12, 45, 76, 0, 0],
        # ...
    ],
    "query_y_a": [
        [0, 1, 1, 0, 0, 0],
        [1, 0, 0, 0, 0, 0],
        # ...
    ],
    "query_y_q_mask": [
        [1, 1, 1, 0, 0, 0],
        [1, 1, 1, 1, 0, 0],
        # ...
    ],
    "query_y_a_mask": [
        [1, 1, 1, 0, 0, 0],
        [1, 0, 0, 0, 0, 0],
        # ...
    ],
    "flatten_query_x": [
        "/path/to/query/ecg_1.npy",
        "/path/to/query/ecg_2.npy",
        # ...
    ],
}
```

### 1.4 Class distribution

| Question Type   | Attributes | Answers                          | Classes (train:test) | Samples | Example                                                                 |
|-----------------|------------|----------------------------------|-----------------------|---------|-------------------------------------------------------------------------|
| Single-Verify   | 94         | yes/no                           | 156 (124:32)          | 34,105  | Q: Does this ECG show 1st degree av block? <br> A: yes/no               |
| Single-Choose   | 165        | both/none/attr_1/attr_2          | 262 (209:53)          | 47,655  | Q: Which noise does this ECG show, baseline drift or static noise? <br> A:  baseline drift /static noise   |
| Single-Query    | 30         | attr_1/attr_2/.../attr_n         | 260 (208:52)          | 63,125  | Q: What direction is this ECG deviated to? <br> A: Normal axis/...     |
| All             | 206        | yes/no/both/none/.../attr_n      | 678 (541:137)         | 144,885 | ...                                                                     |

# 2. Citation

```
@article{tang2024electrocardiogram,
  title={Electrocardiogram-Language Model for Few-Shot Question Answering with Meta Learning},
  author={Tang, Jialu and Xia, Tong and Lu, Yuan and Mascolo, Cecilia and Saeed, Aaqib},
  journal={arXiv preprint arXiv:2410.14464},
  year={2024}
}
```