pyhealth.tasks.covid19_cxr_classification#

class pyhealth.tasks.covid19_cxr_classification.COVID19CXRClassification(code_mapping=None)[source]#

Bases: BaseTask

A task for classifying chest disease from chest X-ray images.

This task classifies chest X-ray images into different disease categories. It expects a single chest X-ray image per patient and returns the corresponding disease label.

task_name#

The name of the task, set to “COVID19CXRClassification”.

Type:

str

input_schema#

The input schema specifying the required input format. Contains a single key “image” with value “image”.

Type:

Dict[str, str]

output_schema#

The output schema specifying the output format. Contains a single key “disease” with value “multiclass”.

Type:

Dict[str, str]

Examples

>>> from pyhealth.datasets import COVID19CXRDataset
>>> from pyhealth.tasks import COVID19CXRClassification
>>> dataset = COVID19CXRDataset(root="/path/to/covid19_cxr")
>>> task = COVID19CXRClassification()
>>> samples = dataset.set_task(task)

Initialize a task with optional code mapping.

Parameters:

code_mapping (Optional[Dict[str, Tuple[str, str]]]) –

optional dict mapping feature keys to (source_vocab, target_vocab) tuples. For example:

code_mapping={
    "conditions": ("ICD9CM", "CCSCM"),
    "procedures": ("ICD9PROC", "CCSPROC"),
    "drugs": ("NDC", "ATC"),
}

When provided, the corresponding input_schema entries are upgraded from "sequence" to ("sequence", {"code_mapping": (src, tgt)}) so that the SequenceProcessor maps raw codes at fit/process time.

task_name: str = 'COVID19CXRClassification'#
input_schema: Dict = {'image': ('image', {'mode': 'RGB'})}#
output_schema: Dict[str, str] = {'disease': 'multiclass'}#
__init__(code_mapping=None)#

Initialize a task with optional code mapping.

Parameters:

code_mapping (Optional[Dict[str, Tuple[str, str]]]) –

optional dict mapping feature keys to (source_vocab, target_vocab) tuples. For example:

code_mapping={
    "conditions": ("ICD9CM", "CCSCM"),
    "procedures": ("ICD9PROC", "CCSPROC"),
    "drugs": ("NDC", "ATC"),
}

When provided, the corresponding input_schema entries are upgraded from "sequence" to ("sequence", {"code_mapping": (src, tgt)}) so that the SequenceProcessor maps raw codes at fit/process time.

pre_filter(df)#
Return type:

LazyFrame