Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/api/datasets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,11 @@ PyHealth does not ship any data: you download each dataset from its source and p
- `PhysioNet <https://physionet.org/content/challenge-2012/1.0.0/>`__
- Yes
- —
* - :doc:`MIT-BIH Arrhythmia <datasets/pyhealth.datasets.MITBIHDataset>`
- Open
- `PhysioNet <https://physionet.org/content/mitdb/1.0.0/>`__
- No
- —
* - :doc:`PTB-XL <datasets/pyhealth.datasets.PTBXLDataset>`
- Open
- `PhysioNet <https://physionet.org/content/ptb-xl/1.0.3/>`__
Expand Down Expand Up @@ -689,6 +694,7 @@ Available Datasets
datasets/pyhealth.datasets.EEGBCIDataset
datasets/pyhealth.datasets.AHEPADementiaDataset
datasets/pyhealth.datasets.BCICompetitionIV2aDataset
MIT-BIH Arrhythmia Dataset <datasets/pyhealth.datasets.MITBIHDataset>
PTB-XL Dataset <datasets/pyhealth.datasets.PTBXLDataset>
PhysioNet 2012 Dataset <datasets/pyhealth.datasets.PhysioNet2012Dataset>
datasets/pyhealth.datasets.TUABDataset
Expand Down
32 changes: 32 additions & 0 deletions docs/api/datasets/pyhealth.datasets.MITBIHDataset.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
pyhealth.datasets.MITBIHDataset
===============================

Overview
--------

The `MIT-BIH Arrhythmia Database <https://physionet.org/content/mitdb/1.0.0/>`_
contains 48 half-hour, two-lead ambulatory ECG recordings from 47 patients,
sampled at 360 Hz, with every heartbeat annotated by cardiologists. Each
recording is loaded as one patient; waveforms are read lazily with ``wfdb``
(``pip install wfdb``).

:class:`~pyhealth.datasets.MITBIHAnomalyRatioSplit` provides a deterministic
record-level split by abnormal-beat ratio. Its default ``"paper"`` mode
reproduces the anomaly-detection split of MedTsLLM
(`Chan et al., MLHC 2024 <https://arxiv.org/abs/2408.07773>`_): the 6 least
and 4 most abnormal of the 33 MLII+V1 recordings that are not entirely
abnormal, which matches the paper's reported 1,354,170 training and 902,780
test samples at 125 Hz.

API Reference
-------------

.. autoclass:: pyhealth.datasets.MITBIHDataset
:members:
:undoc-members:
:show-inheritance:

.. autoclass:: pyhealth.datasets.MITBIHAnomalyRatioSplit
:members:
:undoc-members:
:show-inheritance:
1 change: 1 addition & 0 deletions docs/api/tasks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ Available Tasks
AHEPA Dementia Classification <tasks/pyhealth.tasks.DementiaClassificationAHEPA>
BCI Competition IV 2a Motor Imagery <tasks/pyhealth.tasks.BCIIV2aMotorImageryClassification>
BCI Competition IV 2a Left vs Right Hand <tasks/pyhealth.tasks.BCIIV2aLeftRightImagery>
MIT-BIH ECG Anomaly Detection <tasks/pyhealth.tasks.mitbih>
PTB-XL Tasks <tasks/pyhealth.tasks.ptbxl>
Sleep Staging v2 <tasks/pyhealth.tasks.sleep_staging_v2>
Benchmark EHRShot <tasks/pyhealth.tasks.benchmark_ehrshot>
Expand Down
23 changes: 23 additions & 0 deletions docs/api/tasks/pyhealth.tasks.mitbih.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
pyhealth.tasks.mitbih
=====================

Overview
--------

ECG anomaly detection on the MIT-BIH Arrhythmia Database, following MedTsLLM
(`Chan et al., MLHC 2024 <https://arxiv.org/abs/2408.07773>`_). Each recording
is resampled from 360 Hz to 125 Hz and cut into 128-sample windows of the
two-lead signal. The label is a per-time-step binary mask in which every
abnormal beat annotation (any beat other than ``N``) is expanded to 150 ms
before and after the beat.

Use with :meth:`pyhealth.datasets.MITBIHDataset.anomaly_ratio_split` to obtain
the paper's train/test split.

API Reference
-------------

.. automodule:: pyhealth.tasks.mitbih
:members:
:undoc-members:
:show-inheritance:
2 changes: 2 additions & 0 deletions pyhealth/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ def __init__(self, *args, **kwargs):
from .bciiv2a import BCICompetitionIV2aDataset as BCICompetitionIV2aDataset
from .hup_ieeg import HUPiEEGDataset as HUPiEEGDataset
from .iiic import IIICDataset as IIICDataset
from .mitbih import MITBIHAnomalyRatioSplit as MITBIHAnomalyRatioSplit
from .mitbih import MITBIHDataset as MITBIHDataset
from .tuab import TUABDataset
from .tuev import TUEVDataset
from .chbmit import CHBMITDataset as CHBMITDataset
Expand Down
17 changes: 17 additions & 0 deletions pyhealth/datasets/configs/mitbih.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: "1.0.0" # PhysioNet MIT-BIH Arrhythmia Database (mitdb) v1.0.0
tables:
records:
# Written by MITBIHDataset.prepare_metadata from the WFDB headers and
# beat annotations, into metadata_cache_dir (not the data root).
file_path: "mitbih-pyhealth.csv"
patient_id: "patient_id"
# Recordings are de-identified and carry no acquisition dates.
timestamp: null
attributes:
- "record_id"
- "signal_file"
- "fs"
- "n_samples"
- "leads" # comma-separated, e.g. "MLII,V1"
- "anomaly_ratio" # fraction of beat annotations other than "N"
- "comments" # header comments: age, sex, medications, notes
Loading
Loading