FSL_ECG_QA_Dataset / README.md
jialucode's picture
Update README.md
3d4098c verified
metadata
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 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 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

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?
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?
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?
A: Normal axis/...
All 206 yes/no/both/none/.../attr_n 678 (541:137) 144,885 ...

2. Citation

@InProceedings{pmlr-v287-tang25a,
  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},
  booktitle = {Proceedings of the Sixth Conference on Health, Inference, and Learning},
  pages = {89--104},
  year = {2025},
  editor = {Xu, Xuhai Orson and Choi, Edward and Singhal, Pankhuri and Gerych, Walter and Tang, Shengpu and Agrawal, Monica and Subbaswamy, Adarsh and Sizikova, Elena and Dunn, Jessilyn and Daneshjou, Roxana and Sarker, Tasmie and McDermott, Matthew and Chen, Irene},
  volume = {287},
  series = {Proceedings of Machine Learning Research},
  month = {25--27 Jun},
  publisher = {PMLR},
  url = {https://proceedings.mlr.press/v287/tang25a.html}
}