pyhealth.tasks.cardiology_detect#

pyhealth.tasks.cardiology_detect.cardiology_isAR_fn(record, epoch_sec=10, shift=5)[source]#

Processes a single patient for the Arrhythmias symptom in cardiology on the CardiologyDataset

Cardiology symptoms can be divided into six categories. The task focuses on Arrhythmias and is defined as a binary classification.

Parameters:
  • record

    a singleton list of one subject from the CardiologyDataset. The (single) record is a dictionary with the following keys:

    load_from_path, signal_file, label1_file, label2_file, save_to_path, subject_id

  • epoch_sec – how long will each epoch be (in seconds).

  • shift – the step size for the sampling window (with a width of epoch_sec)

Returns:

a list of samples, each sample is a dict with patient_id, record_id,

and epoch_path (the path to the saved epoch {“X”: signal, “Sex”: gender, “Age”: age, Y”: label} as key.

Return type:

samples

Note that we define the task as a binary classification task.

Examples

>>> from pyhealth.datasets import CardiologyDataset
>>> isAR = CardiologyDataset(
...         root="physionet.org/files/challenge-2020/1.0.2/training",
            chosen_dataset=[1,1,1,1,1,1],
...     )
>>> from pyhealth.tasks import cardiology_isAR_fn
>>> cardiology_ds = isAR.set_task(cardiology_isAR_fn)
>>> cardiology_ds.samples[0]
{
    'patient_id': '0_0',
    'visit_id': 'A0033',
    'record_id': 1,
    'Sex': ['Female'],
    'Age': ['34'],
    'epoch_path': '/Users/liyanjing/.cache/pyhealth/datasets/46c18f2a1a18803b4707a934a577a331/0_0-0.pkl',
    'label': '0'
}
pyhealth.tasks.cardiology_detect.cardiology_isBBBFB_fn(record, epoch_sec=10, shift=5)[source]#

Processes a single patient for the Bundle branch blocks and fascicular blocks symptom in cardiology on the CardiologyDataset

Cardiology symptoms can be divided into six categories. The task focuses on Bundle branch blocks and fascicular blocks and is defined as a binary classification.

Parameters:
  • record

    a singleton list of one subject from the CardiologyDataset. The (single) record is a dictionary with the following keys:

    load_from_path, signal_file, label1_file, label2_file, save_to_path, subject_id

  • epoch_sec – how long will each epoch be (in seconds).

  • shift – the step size for the sampling window (with a width of epoch_sec)

Returns:

a list of samples, each sample is a dict with patient_id, record_id,

and epoch_path (the path to the saved epoch {“X”: signal, “Sex”: gender, “Age”: age, Y”: label} as key.

Return type:

samples

Note that we define the task as a binary classification task.

Examples

>>> from pyhealth.datasets import CardiologyDataset
>>> isBBBFB = CardiologyDataset(
...         root="physionet.org/files/challenge-2020/1.0.2/training",
            chosen_dataset=[1,1,1,1,1,1],
...     )
>>> from pyhealth.tasks import cardiology_isBBBFB_fn
>>> cardiology_ds = isBBBFB.set_task(cardiology_isBBBFB_fn)
>>> cardiology_ds.samples[0]
{
    'patient_id': '0_0',
    'visit_id': 'A0033',
    'record_id': 1,
    'Sex': ['Female'],
    'Age': ['34'],
    'epoch_path': '/Users/liyanjing/.cache/pyhealth/datasets/46c18f2a1a18803b4707a934a577a331/0_0-0.pkl',
    'label': '0'
}
pyhealth.tasks.cardiology_detect.cardiology_isAD_fn(record, epoch_sec=10, shift=5)[source]#

Processes a single patient for the Axis deviations symptom in cardiology on the CardiologyDataset

Cardiology symptoms can be divided into six categories. The task focuses on Axis deviations and is defined as a binary classification.

Parameters:
  • record

    a singleton list of one subject from the CardiologyDataset. The (single) record is a dictionary with the following keys:

    load_from_path, signal_file, label1_file, label2_file, save_to_path, subject_id

  • epoch_sec – how long will each epoch be (in seconds).

  • shift – the step size for the sampling window (with a width of epoch_sec)

Returns:

a list of samples, each sample is a dict with patient_id, record_id,

and epoch_path (the path to the saved epoch {“X”: signal, “Sex”: gender, “Age”: age, Y”: label} as key.

Return type:

samples

Note that we define the task as a binary classification task.

Examples

>>> from pyhealth.datasets import CardiologyDataset
>>> isAD = CardiologyDataset(
...         root="physionet.org/files/challenge-2020/1.0.2/training",
            chosen_dataset=[1,1,1,1,1,1],
...     )
>>> from pyhealth.tasks import cardiology_isAD_fn
>>> cardiology_ds = isAD.set_task(cardiology_isAD_fn)
>>> cardiology_ds.samples[0]
{
    'patient_id': '0_0',
    'visit_id': 'A0033',
    'record_id': 1,
    'Sex': ['Female'],
    'Age': ['34'],
    'epoch_path': '/Users/liyanjing/.cache/pyhealth/datasets/46c18f2a1a18803b4707a934a577a331/0_0-0.pkl',
    'label': '0'
}
pyhealth.tasks.cardiology_detect.cardiology_isCD_fn(record, epoch_sec=10, shift=5)[source]#

Processes a single patient for the Conduction delays symptom in cardiology on the CardiologyDataset

Cardiology symptoms can be divided into six categories. The task focuses on Conduction delays and is defined as a binary classification.

Parameters:
  • record

    a singleton list of one subject from the CardiologyDataset. The (single) record is a dictionary with the following keys:

    load_from_path, signal_file, label1_file, label2_file, save_to_path, subject_id

  • epoch_sec – how long will each epoch be (in seconds).

  • shift – the step size for the sampling window (with a width of epoch_sec)

Returns:

a list of samples, each sample is a dict with patient_id, record_id,

and epoch_path (the path to the saved epoch {“X”: signal, “Sex”: gender, “Age”: age, Y”: label} as key.

Return type:

samples

Note that we define the task as a binary classification task.

Examples

>>> from pyhealth.datasets import CardiologyDataset
>>> isCD = CardiologyDataset(
...         root="physionet.org/files/challenge-2020/1.0.2/training",
            chosen_dataset=[1,1,1,1,1,1],
...     )
>>> from pyhealth.tasks import cardiology_isCD_fn
>>> cardiology_ds = isCD.set_task(cardiology_isCD_fn)
>>> cardiology_ds.samples[0]
{
    'patient_id': '0_0',
    'visit_id': 'A0033',
    'record_id': 1,
    'Sex': ['Female'],
    'Age': ['34'],
    'epoch_path': '/Users/liyanjing/.cache/pyhealth/datasets/46c18f2a1a18803b4707a934a577a331/0_0-0.pkl',
    'label': '0'
}
pyhealth.tasks.cardiology_detect.cardiology_isWA_fn(record, epoch_sec=10, shift=5)[source]#

Processes a single patient for the Wave abnormalities symptom in cardiology on the CardiologyDataset

Cardiology symptoms can be divided into six categories. The task focuses on Wave abnormalities and is defined as a binary classification.

Parameters:
  • record

    a singleton list of one subject from the CardiologyDataset. The (single) record is a dictionary with the following keys:

    load_from_path, signal_file, label1_file, label2_file, save_to_path, subject_id

  • epoch_sec – how long will each epoch be (in seconds).

  • shift – the step size for the sampling window (with a width of epoch_sec)

Returns:

a list of samples, each sample is a dict with patient_id, record_id,

and epoch_path (the path to the saved epoch {“X”: signal, “Sex”: gender, “Age”: age, Y”: label} as key.

Return type:

samples

Note that we define the task as a binary classification task.

Examples

>>> from pyhealth.datasets import CardiologyDataset
>>> isWA = CardiologyDataset(
...         root="physionet.org/files/challenge-2020/1.0.2/training",
            chosen_dataset=[1,1,1,1,1,1],
...     )
>>> from pyhealth.tasks import cardiology_isWA_fn
>>> cardiology_ds = isWA.set_task(cardiology_isWA_fn)
>>> cardiology_ds.samples[0]
{
    'patient_id': '0_0',
    'visit_id': 'A0033',
    'record_id': 1,
    'Sex': ['Female'],
    'Age': ['34'],
    'epoch_path': '/Users/liyanjing/.cache/pyhealth/datasets/46c18f2a1a18803b4707a934a577a331/0_0-0.pkl',
    'label': '0'
}