pyhealth.tasks.COVID19CXRImageGeneration#

class pyhealth.tasks.covid19_cxr_generation.COVID19CXRImageGeneration(code_mapping=None)[source]#

Bases: BaseTask

A task for generating chest X-ray images.

Every X-ray becomes one sample holding only the image, so the output schema is empty. Images are loaded as single-channel grayscale, since the X-rays carry no color, and resized to 128 x 128.

task_name#

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

Type:

str

input_schema#

A single key “image”, processed as a grayscale image of 128 x 128 pixels.

Type:

dict[str, Any]

output_schema#

Empty, since generation has no label.

Type:

dict[str, Any]

Examples

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

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 = 'COVID19CXRImageGeneration'#
input_schema: ClassVar[dict[str, Any]] = {'image': ('image', {'image_size': 128, 'mode': 'L'})}#
output_schema: ClassVar[dict[str, Any]] = {}#
__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