Fairseq-signals is a collection of deep learning models for ECG data processing based on the fairseq
.
We provide implementations of various deep learning methods on ECG data, including official implementations of our works.
- PyTorch version == 1.13.1+cu117
- Python version == 3.9
- For training new models, you'll also need an NVIDIA GPU and NCCL
- To install fairseq-signals from source and develop locally:
git clone https://github.com/Jwoo5/fairseq-signals
cd fairseq-signals
pip install --editable ./
pip install scikit-learn transformers
- To preprocess ECG datasets:
pip install scipy wfdb
- To build cython components:
python setup.py build_ext --inplace
- For large datasets install PyArrow:
pip install pyarrow
We provide pre-processing codes for various ECG datasets.
- PhysioNet2021
- The dataset must be in the given form:
- physionet_org
|===> training
|----> chapman_shaoxing
|----> cpsc_2018
|----> cpsc_2018_extra
|----> georgia
|----> ningbo
|----> ptb
|----> ptb-xl
|----> st_petersburg_incart
|===> dx_mapping_scored.csv
|===> dx_mapping_unscored.csv
|===> evaluate_model.m
|===> evaluate_model.py
|===> helper_code.py
|===> weights.csv
|===> weights_abbreviations.csv
Given a directory that contains WFDB directories to be pre-processed for PhysioNet2021:
$ python fairseq_signals/data/ecg/preprocess/preprocess_physionet2021.py \
/path/to/physionet2021/ \
--dest /path/to/output \
--workers $N
Given a directory that contains pre-processed data:
$ python fairseq_signals/data/ecg/preprocess/manifest.py \
/path/to/data/ \
--dest /path/to/manifest \
--pretrain-valid-percent $valid
Before training, you should prepare training data manifest required for training CLOCS model.
$ python /path/to/fairseq_signals/data/ecg/preprocess/convert_to_clocs_manifest.py \
/path/to/pretrain/train.tsv \
--dest /path/to/manifest
The expected results are like:
/path/to/manifest
├─ cmsc
│ └─ train.tsv
├─ cmlc
│ └─ train.tsv
└─ cmsmlc
└─ train.tsv
This configuration was used for the W2V+CMSC+RLM
model pre-trained on the PhysioNet2021
dataset in the original paper.
$ fairseq-hydra-train \
task.data=/path/to/manifest/cmsc \ #Absolute path in windows
--config-dir examples/w2v_cmsc/config/pretraining \
--config-name w2v_cmsc_rlm