Skip to content

care_algorithm_model

CARE algorithm configuration.

CAREAlgorithm #

Bases: UNetBasedAlgorithm

CARE algorithm configuration.

Attributes:

Name Type Description
algorithm care

CARE Algorithm name.

loss {mae, mse}

CARE-compatible loss function.

Source code in src/careamics/config/algorithms/care_algorithm_model.py
class CAREAlgorithm(UNetBasedAlgorithm):
    """CARE algorithm configuration.

    Attributes
    ----------
    algorithm : "care"
        CARE Algorithm name.
    loss : {"mae", "mse"}
        CARE-compatible loss function.
    """

    algorithm: Literal["care"] = "care"
    """CARE Algorithm name."""

    loss: Literal["mae", "mse"] = "mae"
    """CARE-compatible loss function."""

    model: Annotated[
        UNetModel,
        AfterValidator(model_without_n2v2),
        AfterValidator(model_without_final_activation),
    ]
    """UNet without a final activation function and without the `n2v2` modifications."""

    def get_algorithm_friendly_name(self) -> str:
        """
        Get the algorithm friendly name.

        Returns
        -------
        str
            Friendly name of the algorithm.
        """
        return CARE

    def get_algorithm_keywords(self) -> list[str]:
        """
        Get algorithm keywords.

        Returns
        -------
        list[str]
            List of keywords.
        """
        return [
            "restoration",
            "UNet",
            "3D" if self.model.is_3D() else "2D",
            "CAREamics",
            "pytorch",
            CARE,
        ]

    def get_algorithm_references(self) -> str:
        """
        Get the algorithm references.

        This is used to generate the README of the BioImage Model Zoo export.

        Returns
        -------
        str
            Algorithm references.
        """
        return CARE_REF.text + " doi: " + CARE_REF.doi

    def get_algorithm_citations(self) -> list[CiteEntry]:
        """
        Return a list of citation entries of the current algorithm.

        This is used to generate the model description for the BioImage Model Zoo.

        Returns
        -------
        List[CiteEntry]
            List of citation entries.
        """
        return [CARE_REF]

    def get_algorithm_description(self) -> str:
        """
        Get the algorithm description.

        Returns
        -------
        str
            Algorithm description.
        """
        return CARE_DESCRIPTION

algorithm = 'care' class-attribute instance-attribute #

CARE Algorithm name.

loss = 'mae' class-attribute instance-attribute #

CARE-compatible loss function.

model instance-attribute #

UNet without a final activation function and without the n2v2 modifications.

get_algorithm_citations() #

Return a list of citation entries of the current algorithm.

This is used to generate the model description for the BioImage Model Zoo.

Returns:

Type Description
List[CiteEntry]

List of citation entries.

Source code in src/careamics/config/algorithms/care_algorithm_model.py
def get_algorithm_citations(self) -> list[CiteEntry]:
    """
    Return a list of citation entries of the current algorithm.

    This is used to generate the model description for the BioImage Model Zoo.

    Returns
    -------
    List[CiteEntry]
        List of citation entries.
    """
    return [CARE_REF]

get_algorithm_description() #

Get the algorithm description.

Returns:

Type Description
str

Algorithm description.

Source code in src/careamics/config/algorithms/care_algorithm_model.py
def get_algorithm_description(self) -> str:
    """
    Get the algorithm description.

    Returns
    -------
    str
        Algorithm description.
    """
    return CARE_DESCRIPTION

get_algorithm_friendly_name() #

Get the algorithm friendly name.

Returns:

Type Description
str

Friendly name of the algorithm.

Source code in src/careamics/config/algorithms/care_algorithm_model.py
def get_algorithm_friendly_name(self) -> str:
    """
    Get the algorithm friendly name.

    Returns
    -------
    str
        Friendly name of the algorithm.
    """
    return CARE

get_algorithm_keywords() #

Get algorithm keywords.

Returns:

Type Description
list[str]

List of keywords.

Source code in src/careamics/config/algorithms/care_algorithm_model.py
def get_algorithm_keywords(self) -> list[str]:
    """
    Get algorithm keywords.

    Returns
    -------
    list[str]
        List of keywords.
    """
    return [
        "restoration",
        "UNet",
        "3D" if self.model.is_3D() else "2D",
        "CAREamics",
        "pytorch",
        CARE,
    ]

get_algorithm_references() #

Get the algorithm references.

This is used to generate the README of the BioImage Model Zoo export.

Returns:

Type Description
str

Algorithm references.

Source code in src/careamics/config/algorithms/care_algorithm_model.py
def get_algorithm_references(self) -> str:
    """
    Get the algorithm references.

    This is used to generate the README of the BioImage Model Zoo export.

    Returns
    -------
    str
        Algorithm references.
    """
    return CARE_REF.text + " doi: " + CARE_REF.doi