Skip to content
Open
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
1 change: 1 addition & 0 deletions docs/api/tasks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ Available Tasks
In-Hospital Mortality (MIMIC-IV) <tasks/pyhealth.tasks.InHospitalMortalityMIMIC4>
MIMIC-III ICD-9 Coding <tasks/pyhealth.tasks.MIMIC3ICD9Coding>
Cardiology Detection <tasks/pyhealth.tasks.cardiology_detect>
ECG Multi-Label Cardiology Task <tasks/pyhealth.tasks.ecg_classification>
COVID-19 CXR Classification <tasks/pyhealth.tasks.COVID19CXRClassification>
DKA Prediction (MIMIC-IV) <tasks/pyhealth.tasks.dka>
Drug Recommendation <tasks/pyhealth.tasks.drug_recommendation>
Expand Down
94 changes: 94 additions & 0 deletions docs/api/tasks/pyhealth.tasks.ecg_classification.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
pyhealth.tasks.ecg_classification
=================================

.. currentmodule:: pyhealth.tasks.ecg_classification

ECG Multi-Label Cardiology Task
-------------------------------

This module provides an implementation of a multi-label ECG classification task
for the PyHealth framework.

The task processes 12-lead electrocardiogram (ECG) signals and predicts
multiple cardiac conditions simultaneously. It extends the PyHealth
``BaseTask`` class and integrates with PyHealth datasets and models.

Key Features
------------

- Multi-label classification support
- PhysioNet-style ECG file handling (``.mat`` and ``.hea``)
- Sliding window segmentation
- Metadata extraction (age, sex, diagnosis codes)
- Compatibility with PyHealth pipelines

Input Format
------------

Each patient visit is represented as a dictionary:

.. code-block:: python

{
"load_from_path": "...",
"patient_id": "...",
"signal_file": "record.mat",
"label_file": "record.hea",
}

Output Format
-------------

Each processed sample contains:

.. code-block:: python

{
"signal": numpy.ndarray,
"label": numpy.ndarray,
"patient_id": str,
"visit_id": str,
"record_id": str,
"Sex": str,
"Age": int,
}

Parameters
----------

- ``labels``: list of target diagnosis labels
- ``epoch_sec``: window size in seconds
- ``shift``: step size between windows
- ``sampling_rate``: signal sampling frequency

Ablation Support
----------------

This task enables experimentation across:

- Label set variation
- Temporal segmentation

Example
-------

.. code-block:: python

from pyhealth.tasks.ecg_classification import ECGMultiLabelCardiologyTask

task = ECGMultiLabelCardiologyTask(
labels=["AF", "RBBB"],
epoch_sec=10,
shift=5,
sampling_rate=500,
)

samples = task(visit_dict)

Module Reference
----------------

.. automodule:: pyhealth.tasks.ecg_classification
:members:
:undoc-members:
:show-inheritance:
Loading