jialucode commited on
Commit
16a6294
·
verified ·
1 Parent(s): 5ef76b7

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +44 -109
README.md CHANGED
@@ -1,167 +1,112 @@
 
1
  ---
2
  license: mit
3
  ---
4
  # 0. FSL_ECG_QA_Dataset
5
-
6
  **FSL_ECG_QA_Dataset** is a **benchmark dataset** specifically designed to accompany the paper *"Electrocardiogram–Language Model for Few-Shot Question Answering with Meta Learning"* (**arXiv:2410.14464v1**). It supports research in combining **electrocardiogram (ECG) signals** with **natural language question answering (QA)**, particularly in **few-shot** and **meta-learning** scenarios.
7
 
8
  ## 1. Dataset Highlights
9
-
10
  - 🧠 **Task Diversification**: Restructured **ECG-QA tasks** promote rapid **few-shot adaptation**.
11
  - 🧬 **Fusion Mapping**: A lightweight **multimodal mapper** bridges **ECG** and **language features**.
12
  - 🚀 **Model Generalization**: **LLM-agnostic design** ensures broad **transferability** and **robustness**.
13
-
14
  ## 2 Developing Datasets
15
- # 2.1 Source Datasets
16
-
17
  The dataset is a structured reorganization of the existing ECG-QA dataset, adapted to suit meta-learning tasks. It draws samples from ECG sources such as [PTB-XL](https://physionet.org/content/ptb-xl/1.0.3/) and [MIMIC-IV-ECG](https://physionet.org/content/mimic-iv-ecg/1.0/), and [ECG-QA dataset](https://github.com/Jwoo5/ecg-qa?tab=readme-ov-file) organizes them into diverse task sets based on question types including **verify(yes/no)**, **choice(Condition_A/Condition_B)**, and **query(open-ended)** question in table 2.2. and clinical attributes (e.g., SCP codes, noise type, axis deviation) used to describing the ECG. This structure enables models to rapidly adapt to new diagnostic tasks with limited annotated examples.
18
 
19
  <img src="img/distribution_attr.png" alt="Figure 1: Illustration of class formation and attribute distribution for different question types." width="600"/>
20
 
21
- # 2.2 Dataset Description
22
- Overview of question types and data distribution within the meta learning benchmark dataset created for few-shot ECG question answering.
23
 
24
- ### Supported Tasks
25
 
26
- -- [CUSTOMIZE THIS] Describe the tasks this dataset supports:
27
- - What tasks can be performed on this dataset?
28
 
 
29
  - Are there any code associated with this dataset?
30
  - Electrocardiogram–Language Model for Few-Shot Question Answering with Meta Learning(ICASSP 2025), https://arxiv.org/html/2410.14464v1
31
 
32
-
33
  **class(template_id_attribute_answer pairs)**
34
 
35
- ### Data Instances
 
 
36
 
37
- <!-- [CUSTOMIZE THIS] Provide examples of data instances from the dataset. Include:
38
- - A description of what each instance represents
39
- - One or more concrete examples in JSON or dictionary format -->
40
- Merge all data in train/val/test dataset in ECG-QA and change it into different class, Use a consistent ID system to track attribute-answer combinations(defination of "way" in meta-learning):
41
- example in ecg-qa:
42
  ```python
43
- # Example data instance
44
- # Example data instance
45
  {
46
- "template_id": 1, # ID of the template used
47
- "question_id": 0, # Unique identifier for the question
48
- "sample_id": 0, # Unique identifier for the data sample
49
- "question_type": "single-verify", # Type of question
50
- "attribute_type": "scp_code", # Type of attribute being verified
51
- "question": "Is there evidence of non-diagnostic t abnormalities on this ECG?", # Natural language question
52
- "answer": [
53
- "yes" # Ground truth answer
54
- ],
55
- "ecg_id": [
56
- 12662 # ID referencing the ECG record
57
- ],
58
- "attribute": [
59
- "non-diagnostic t abnormalities" # The specific attribute being evaluated
60
- ]
61
  }
62
-
63
  ```
64
 
65
- ## new class
66
- Example: 5_atrial_fibrillation_yes represents Template ID *5*, attribute *"atrial fibrillation"*, answer *"yes"*.
67
-
68
- ## class build
69
-
70
-
71
- The output and details amount of dataset in different question type.
72
- <div style="width: 80%; font-size: 14px;">
73
- | Question Type | Attributes | Answers | Classes (train:test) | Samples | Example |
74
- |---------------|------------|---------|---------------------|---------|---------|
75
- | Single-Verify | 94 | yes/no | 156 (124:32) | 34,105 | Q: Does this ECG show 1st degree av block? <br> A: yes/no |
76
- | 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/both/none |
77
- | 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/.../open-ending |
78
- | All | 206 | yes/no/both/none/.../attr_n | 678 (541:137) | 144,885 | ... |
79
- </div>
80
-
81
- ### Loading the Dataset
82
-
83
- ```python
84
-
85
- # Example code to load the dataset ptb-xl
86
 
87
- python load_class.py \
88
- --base_path /your/actual/path/to/ecgqa/ptbxl/paraphrased \
89
- --test_dataset ptb-xl
90
 
91
- # Example code to load the dataset mimiv-iv-ecg
92
 
93
- # the random selected 30k ecg from mimic-iv-ecg used to test
94
- processed_test_30k.json
 
 
 
 
95
 
96
- python load_class.py \
97
- --paraphrased_path /your/actual/path/to/ecgqa/mimic-iv-ecg/paraphrased \
98
- --test_dataset mimic
99
 
 
 
 
100
  ```
101
 
102
- # Access splits
103
  train_data = dataset["train"]
104
  validation_data = dataset["validation"]
105
  test_data = dataset["test"]
106
 
107
- # Example usage
108
  for example in train_data.select(range(3)):
109
  print(example)
110
  ```
111
- ```bash
112
-
113
-
114
-
115
-
116
- ## few-shot build
117
 
 
118
 
119
  ```bash
120
- python data_loader.py \
121
- --paraphrased_path /your/actual/path/to/ecgqa/mimic-iv-ecg/paraphrased \
122
- --test_dataset mimic
123
  ```
124
 
125
- <img src="img/FSL_ECG_QAMeta-Learning.png" alt="An example of n way 1 shot and how to utilize in Meta-learning." style="max-width:100%; height:auto;">
126
 
127
- In summary, FSL_ECG_QA_Dataset serves as a powerful benchmark for developing robust and generalizable ECG-based QA systems in data-scarce clinical environments.
128
 
129
  ## Dataset Structure
130
 
131
  ### Data Fields
132
 
133
- <!-- [CUSTOMIZE THIS] Describe all data fields, including:
134
- - Field name
135
- - Data type
136
- - Description of what the field represents
137
- - For categorical fields, the possible values and their meanings -->
138
-
139
  - `feature1`: a `string` feature representing <!-- description -->
140
  - `feature2`: a `string` feature representing <!-- description -->
141
  - `label`: a `int64` classification label, with 0 indicating <!-- meaning --> and 1 indicating <!-- meaning -->
142
 
143
  ### Data Splits
144
 
145
- -- Describe how the data is split:
146
  - Number of instances in each split (train/test): 8:2
147
- - Criteria used for splitting the data
148
- - first split based on template id, this will keep there's no overlap between expression between training and testing set.
149
- - then split for support and query set: since there's aboudant amout of data randomly select sample from same question class for support and query set.
150
 
151
  ## Dataset Creation
152
 
153
  ### Curation Rationale
154
 
155
- - What need does it address?
156
- Developing robust and reliable multimodal QA systems for ECG interpretation relies on the availability of both high-quality and large quantities of labeled data. Yet, obtaining massive amounts of labeled ECGs from cardiologists is costly, which often results in limited datasets. Traditional supervised learning methods tend to perform well only on data with the same distribution as the training data. In real-world deployment, however, models frequently encounter new tasks and previously unseen populations outside the training distribution, where traditional methods may fail. Meta-learning, a paradigm focused on “learning to learn”, offers a compelling solution to this challenge. By training models on a diverse range of tasks, meta-learning enables them to acquire transferable knowledge and adapt rapidly to new, unseen tasks with minimal labeled data. This adaptive capacity is particularly valuable in the ECG-language QA domain, where new diagnostic questions and data distributions constantly emerge.
157
-
158
-
159
 
160
- ### Citation Information
161
-
162
- <!-- [CUSTOMIZE THIS] Provide citation information:
163
- - How should this dataset be cited?
164
- - BibTeX citation -->
165
 
166
  ```
167
  @inproceedings{10888594,
@@ -169,23 +114,18 @@ Developing robust and reliable multimodal QA systems for ECG interpretation reli
169
  booktitle={ICASSP 2025 - 2025 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP)},
170
  title={Electrocardiogram Report Generation and Question Answering via Retrieval-Augmented Self-Supervised Modeling},
171
  year={2025},
172
- volume={},
173
- number={},
174
  pages={1-5},
175
- keywords={Electric potential;Accuracy;Large language models;MIMICs;Self-supervised learning;Electrocardiography;Signal processing;Question answering (information retrieval);Speech processing;Investment;electrocardiogram;retrieval augmented generation;self-supervised learning;large language models},
176
- doi={10.1109/ICASSP49660.2025.10888594}}
177
  ```
178
 
179
  ## How to Use
180
 
181
-
182
  ### Example Preprocessing and Training
183
 
184
  ```python
185
- # Example preprocessing and model training code
186
  from transformers import AutoTokenizer, AutoModelForSequenceClassification, Trainer, TrainingArguments
187
 
188
- # Load tokenizer and tokenize data
189
  tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
190
 
191
  def tokenize_function(examples):
@@ -193,10 +133,8 @@ def tokenize_function(examples):
193
 
194
  tokenized_dataset = dataset.map(tokenize_function, batched=True)
195
 
196
- # Define model
197
  model = AutoModelForSequenceClassification.from_pretrained("bert-base-uncased", num_labels=2)
198
 
199
- # Define training arguments
200
  training_args = TrainingArguments(
201
  output_dir="./results",
202
  per_device_train_batch_size=16,
@@ -207,7 +145,6 @@ training_args = TrainingArguments(
207
  load_best_model_at_end=True,
208
  )
209
 
210
- # Define trainer
211
  trainer = Trainer(
212
  model=model,
213
  args=training_args,
@@ -215,7 +152,5 @@ trainer = Trainer(
215
  eval_dataset=tokenized_dataset["validation"],
216
  )
217
 
218
- # Train model
219
  trainer.train()
220
  ```
221
-
 
1
+
2
  ---
3
  license: mit
4
  ---
5
  # 0. FSL_ECG_QA_Dataset
6
+
7
  **FSL_ECG_QA_Dataset** is a **benchmark dataset** specifically designed to accompany the paper *"Electrocardiogram–Language Model for Few-Shot Question Answering with Meta Learning"* (**arXiv:2410.14464v1**). It supports research in combining **electrocardiogram (ECG) signals** with **natural language question answering (QA)**, particularly in **few-shot** and **meta-learning** scenarios.
8
 
9
  ## 1. Dataset Highlights
10
+
11
  - 🧠 **Task Diversification**: Restructured **ECG-QA tasks** promote rapid **few-shot adaptation**.
12
  - 🧬 **Fusion Mapping**: A lightweight **multimodal mapper** bridges **ECG** and **language features**.
13
  - 🚀 **Model Generalization**: **LLM-agnostic design** ensures broad **transferability** and **robustness**.
14
+
15
  ## 2 Developing Datasets
16
+ ### 2.1 Source Datasets
17
+
18
  The dataset is a structured reorganization of the existing ECG-QA dataset, adapted to suit meta-learning tasks. It draws samples from ECG sources such as [PTB-XL](https://physionet.org/content/ptb-xl/1.0.3/) and [MIMIC-IV-ECG](https://physionet.org/content/mimic-iv-ecg/1.0/), and [ECG-QA dataset](https://github.com/Jwoo5/ecg-qa?tab=readme-ov-file) organizes them into diverse task sets based on question types including **verify(yes/no)**, **choice(Condition_A/Condition_B)**, and **query(open-ended)** question in table 2.2. and clinical attributes (e.g., SCP codes, noise type, axis deviation) used to describing the ECG. This structure enables models to rapidly adapt to new diagnostic tasks with limited annotated examples.
19
 
20
  <img src="img/distribution_attr.png" alt="Figure 1: Illustration of class formation and attribute distribution for different question types." width="600"/>
21
 
22
+ ### 2.2 Dataset Description
 
23
 
24
+ Overview of question types and data distribution within the meta learning benchmark dataset created for few-shot ECG question answering.
25
 
26
+ #### Supported Tasks
 
27
 
28
+ - What tasks can be performed on this dataset?
29
  - Are there any code associated with this dataset?
30
  - Electrocardiogram–Language Model for Few-Shot Question Answering with Meta Learning(ICASSP 2025), https://arxiv.org/html/2410.14464v1
31
 
 
32
  **class(template_id_attribute_answer pairs)**
33
 
34
+ #### Data Instances
35
+
36
+ Merge all data in train/val/test dataset in ECG-QA and change it into different class, Use a consistent ID system to track attribute-answer combinations (definition of "way" in meta-learning):
37
 
 
 
 
 
 
38
  ```python
 
 
39
  {
40
+ "template_id": 1,
41
+ "question_id": 0,
42
+ "sample_id": 0,
43
+ "question_type": "single-verify",
44
+ "attribute_type": "scp_code",
45
+ "question": "Is there evidence of non-diagnostic t abnormalities on this ECG?",
46
+ "answer": ["yes"],
47
+ "ecg_id": [12662],
48
+ "attribute": ["non-diagnostic t abnormalities"]
 
 
 
 
 
 
49
  }
 
50
  ```
51
 
52
+ #### New Class Naming
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
 
54
+ Example: `5_atrial_fibrillation_yes` represents Template ID *5*, attribute *"atrial fibrillation"*, answer *"yes"*.
 
 
55
 
56
+ #### Class Build
57
 
58
+ | Question Type | Attributes | Answers | Classes (train:test) | Samples | Example |
59
+ |-----------------|------------|----------------------------------|-----------------------|---------|-------------------------------------------------------------------------|
60
+ | Single-Verify | 94 | yes/no | 156 (124:32) | 34,105 | Q: Does this ECG show 1st degree av block? <br> A: yes/no |
61
+ | 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? |
62
+ | 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/... |
63
+ | All | 206 | yes/no/both/none/.../attr_n | 678 (541:137) | 144,885 | ... |
64
 
65
+ #### Loading the Dataset
 
 
66
 
67
+ ```bash
68
+ python load_class.py --base_path /your/actual/path/to/ecgqa/ptbxl/paraphrased --test_dataset ptb-xl
69
+ python load_class.py --paraphrased_path /your/actual/path/to/ecgqa/mimic-iv-ecg/paraphrased --test_dataset mimic
70
  ```
71
 
72
+ ```python
73
  train_data = dataset["train"]
74
  validation_data = dataset["validation"]
75
  test_data = dataset["test"]
76
 
 
77
  for example in train_data.select(range(3)):
78
  print(example)
79
  ```
 
 
 
 
 
 
80
 
81
+ ### Few-shot Build
82
 
83
  ```bash
84
+ python data_loader.py --paraphrased_path /your/actual/path/to/ecgqa/mimic-iv-ecg/paraphrased --test_dataset mimic
 
 
85
  ```
86
 
87
+ <img src="img/FSL_ECG_QAMeta-Learning.png" alt="Few-shot Meta-learning Example" width="600"/>
88
 
 
89
 
90
  ## Dataset Structure
91
 
92
  ### Data Fields
93
 
 
 
 
 
 
 
94
  - `feature1`: a `string` feature representing <!-- description -->
95
  - `feature2`: a `string` feature representing <!-- description -->
96
  - `label`: a `int64` classification label, with 0 indicating <!-- meaning --> and 1 indicating <!-- meaning -->
97
 
98
  ### Data Splits
99
 
 
100
  - Number of instances in each split (train/test): 8:2
101
+ - Criteria: first split based on template id (no expression overlap between train/test), then random split for support/query set in few-shot tasks.
 
 
102
 
103
  ## Dataset Creation
104
 
105
  ### Curation Rationale
106
 
107
+ Developing robust and reliable multimodal QA systems for ECG interpretation relies on the availability of both high-quality and large quantities of labeled data. Meta-learning, a paradigm focused on “learning to learn”, enables them to acquire transferable knowledge and adapt rapidly to new, unseen tasks with minimal labeled data.
 
 
 
108
 
109
+ ## Citation
 
 
 
 
110
 
111
  ```
112
  @inproceedings{10888594,
 
114
  booktitle={ICASSP 2025 - 2025 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP)},
115
  title={Electrocardiogram Report Generation and Question Answering via Retrieval-Augmented Self-Supervised Modeling},
116
  year={2025},
 
 
117
  pages={1-5},
118
+ doi={10.1109/ICASSP49660.2025.10888594}
119
+ }
120
  ```
121
 
122
  ## How to Use
123
 
 
124
  ### Example Preprocessing and Training
125
 
126
  ```python
 
127
  from transformers import AutoTokenizer, AutoModelForSequenceClassification, Trainer, TrainingArguments
128
 
 
129
  tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
130
 
131
  def tokenize_function(examples):
 
133
 
134
  tokenized_dataset = dataset.map(tokenize_function, batched=True)
135
 
 
136
  model = AutoModelForSequenceClassification.from_pretrained("bert-base-uncased", num_labels=2)
137
 
 
138
  training_args = TrainingArguments(
139
  output_dir="./results",
140
  per_device_train_batch_size=16,
 
145
  load_best_model_at_end=True,
146
  )
147
 
 
148
  trainer = Trainer(
149
  model=model,
150
  args=training_args,
 
152
  eval_dataset=tokenized_dataset["validation"],
153
  )
154
 
 
155
  trainer.train()
156
  ```