import pysera
from core.node import Node
from core.contracts_radiomics import RadiomicsFeatureTableContract


class RadiomicsFeatureGenerator(Node):
    def __init__(self, output_path="./results"):
        self.output_path = output_path

        super().__init__(
            name="RadiomicsFeatureGenerator",
            inputs={"image": None, "mask": None},
            outputs={"features": RadiomicsFeatureTableContract()}
        )

    def run(self, image_path, mask_path):
        result = pysera.process_batch(
            image_input=image_path,
            mask_input=mask_path,
            output_path=self.output_path,
            report="info"
        )
        return result
