"""
Medical Imaging Dataset Registry Definitions.

Contains DatasetMetadata instances for the MedMNIST v2 collection at both
28x28 and 224x224 resolutions. All datasets sourced from Zenodo.
"""

from typing import Dict, Final

from ...paths import DATASET_DIR
from ..base import DatasetMetadata

# MEDMNIST v2 REGISTRY (28x28 Resolution)
REGISTRY_28: Final[Dict[str, DatasetMetadata]] = {
    "pathmnist": DatasetMetadata(
        name="pathmnist",
        display_name="PathMNIST",
        md5_checksum="a8b06965200029087d5bd730944a56c1",
        url="https://zenodo.org/records/5208230/files/pathmnist.npz",
        path=DATASET_DIR / "pathmnist_28.npz",
        classes=[
            "adipose",
            "background",
            "debris",
            "lymphocytes",
            "mucus",
            "smooth muscle",
            "normal colon mucosa",
            "cancer-associated stroma",
            "colorectal adenocarcinoma epithelium",
        ],
        mean=(0.485, 0.456, 0.406),
        std=(0.229, 0.224, 0.225),
        in_channels=3,
        native_resolution=28,
        is_anatomical=False,
        is_texture_based=True,
    ),
    "bloodmnist": DatasetMetadata(
        name="bloodmnist",
        display_name="BloodMNIST",
        md5_checksum="7053d0359d879ad8a5505303e11de1dc",
        url="https://zenodo.org/records/5208230/files/bloodmnist.npz",
        path=DATASET_DIR / "bloodmnist_28.npz",
        classes=[
            "basophil",
            "eosinophil",
            "erythroblast",
            "immature granulocyte",
            "lymphocyte",
            "monocyte",
            "neutrophil",
            "platelet",
        ],
        mean=(0.4914, 0.4822, 0.4465),
        std=(0.2023, 0.1994, 0.2010),
        in_channels=3,
        native_resolution=28,
        is_anatomical=False,
        is_texture_based=False,
    ),
    "dermamnist": DatasetMetadata(
        name="dermamnist",
        display_name="DermaMNIST",
        md5_checksum="0744692d530f8e62ec473284d019b0c7",
        url="https://zenodo.org/records/5208230/files/dermamnist.npz",
        path=DATASET_DIR / "dermamnist_28.npz",
        classes=[
            "actinic keratoses",
            "basal cell carcinoma",
            "benign keratosis",
            "dermatofibroma",
            "melanocytic nevi",
            "melanoma",
            "vascular lesions",
        ],
        mean=(0.485, 0.456, 0.406),
        std=(0.229, 0.224, 0.225),
        in_channels=3,
        native_resolution=28,
        is_anatomical=False,
        is_texture_based=True,
    ),
    "octmnist": DatasetMetadata(
        name="octmnist",
        display_name="OCTMNIST",
        md5_checksum="c68d92d5b585d8d81f7112f81e2d0842",
        url="https://zenodo.org/records/5208230/files/octmnist.npz",
        path=DATASET_DIR / "octmnist_28.npz",
        classes=["choroidal neovascularization", "diabetic macular edema", "drusen", "normal"],
        mean=(0.5,),
        std=(0.5,),
        in_channels=1,
        native_resolution=28,
        is_anatomical=True,
        is_texture_based=True,
    ),
    "pneumoniamnist": DatasetMetadata(
        name="pneumoniamnist",
        display_name="PneumoniaMNIST",
        md5_checksum="28209eda62fecd6e6a2d98b1501bb15f",
        url="https://zenodo.org/records/5208230/files/pneumoniamnist.npz",
        path=DATASET_DIR / "pneumoniamnist_28.npz",
        classes=["normal", "pneumonia"],
        mean=(0.5,),
        std=(0.5,),
        in_channels=1,
        native_resolution=28,
        is_anatomical=True,
        is_texture_based=False,
    ),
    "retinamnist": DatasetMetadata(
        name="retinamnist",
        display_name="RetinaMNIST",
        md5_checksum="bd4c0672f1bba3e3a89f0e4e876791e4",
        url="https://zenodo.org/records/5208230/files/retinamnist.npz",
        path=DATASET_DIR / "retinamnist_28.npz",
        classes=["No DR", "Mild DR", "Moderate DR", "Severe DR", "Proliferative DR"],
        mean=(0.485, 0.456, 0.406),
        std=(0.229, 0.224, 0.225),
        in_channels=3,
        native_resolution=28,
        is_anatomical=False,
        is_texture_based=True,
    ),
    "breastmnist": DatasetMetadata(
        name="breastmnist",
        display_name="BreastMNIST",
        md5_checksum="750601b1f35ba3300ea97c75c52ff8f6",
        url="https://zenodo.org/records/5208230/files/breastmnist.npz",
        path=DATASET_DIR / "breastmnist_28.npz",
        classes=["malignant", "benign"],
        mean=(0.5,),
        std=(0.5,),
        in_channels=1,
        native_resolution=28,
        is_anatomical=True,
        is_texture_based=False,
    ),
    "organmnist": DatasetMetadata(
        name="organmnist",
        display_name="OrganAMNIST",
        md5_checksum="866b832ed4eeba67bfb9edee1d5544e6",
        url="https://zenodo.org/records/5208230/files/organamnist.npz",
        path=DATASET_DIR / "organamnist_28.npz",
        classes=[
            "bladder",
            "femur-left",
            "femur-right",
            "heart",
            "kidney-left",
            "kidney-right",
            "liver",
            "lung-left",
            "lung-right",
            "pancreas",
            "spleen",
        ],
        mean=(0.5,),
        std=(0.5,),
        in_channels=1,
        native_resolution=28,
        is_anatomical=True,
        is_texture_based=False,
    ),
    "tissuemnist": DatasetMetadata(
        name="tissuemnist",
        display_name="TissueMNIST",
        md5_checksum="ebe78ee8b05294063de985d821c1c34b",
        url="https://zenodo.org/records/5208230/files/tissuemnist.npz",
        path=DATASET_DIR / "tissuemnist_28.npz",
        classes=[
            "Collecting Duct",
            "Distal Tubule",
            "Glomerulus",
            "Medulla",
            "Proximal Tubule",
            "Capsule",
            "Large Vessel",
            "Small Vessel",
        ],
        mean=(0.5,),
        std=(0.5,),
        in_channels=1,
        native_resolution=28,
        is_anatomical=False,
        is_texture_based=True,
    ),
    "organcmnist": DatasetMetadata(
        name="organcmnist",
        display_name="OrganCMNIST",
        md5_checksum="0afa5834fb105f7705a7d93372119a21",
        url="https://zenodo.org/records/5208230/files/organcmnist.npz",
        path=DATASET_DIR / "organcmnist_28.npz",
        classes=[
            "bladder",
            "femur-left",
            "femur-right",
            "heart",
            "kidney-left",
            "kidney-right",
            "liver",
            "lung-left",
            "lung-right",
            "pancreas",
            "spleen",
        ],
        mean=(0.5,),
        std=(0.5,),
        in_channels=1,
        native_resolution=28,
        is_anatomical=True,
        is_texture_based=False,
    ),
}

# MEDMNIST v2 REGISTRY (224x224 Resolution)
REGISTRY_224: Final[Dict[str, DatasetMetadata]] = {
    "pathmnist": DatasetMetadata(
        name="pathmnist",
        display_name="PathMNIST",
        md5_checksum="2c51a510bcdc9cf8ddb2af93af1eadec",
        url="https://zenodo.org/records/10519652/files/pathmnist_224.npz?download=1",
        path=DATASET_DIR / "pathmnist_224.npz",
        classes=[
            "adipose",
            "background",
            "debris",
            "lymphocytes",
            "mucus",
            "smooth muscle",
            "normal colon mucosa",
            "cancer-associated stroma",
            "colorectal adenocarcinoma epithelium",
        ],
        mean=(0.485, 0.456, 0.406),
        std=(0.229, 0.224, 0.225),
        in_channels=3,
        native_resolution=224,
        is_anatomical=False,
        is_texture_based=True,
    ),
    "bloodmnist": DatasetMetadata(
        name="bloodmnist",
        display_name="BloodMNIST",
        md5_checksum="b718ff6835fcbdb22ba9eacccd7b2601",
        url="https://zenodo.org/records/10519652/files/bloodmnist_224.npz?download=1",
        path=DATASET_DIR / "bloodmnist_224.npz",
        classes=[
            "basophil",
            "eosinophil",
            "erythroblast",
            "immature granulocyte",
            "lymphocyte",
            "monocyte",
            "neutrophil",
            "platelet",
        ],
        mean=(0.4914, 0.4822, 0.4465),
        std=(0.2023, 0.1994, 0.2010),
        in_channels=3,
        native_resolution=224,
        is_anatomical=False,
        is_texture_based=False,
    ),
    "dermamnist": DatasetMetadata(
        name="dermamnist",
        display_name="DermaMNIST",
        md5_checksum="8974907d8e169bef5f5b96bc506ae45d",
        url="https://zenodo.org/records/10519652/files/dermamnist_224.npz?download=1",
        path=DATASET_DIR / "dermamnist_224.npz",
        classes=[
            "actinic keratoses",
            "basal cell carcinoma",
            "benign keratosis",
            "dermatofibroma",
            "melanocytic nevi",
            "melanoma",
            "vascular lesions",
        ],
        mean=(0.485, 0.456, 0.406),
        std=(0.229, 0.224, 0.225),
        in_channels=3,
        native_resolution=224,
        is_anatomical=False,
        is_texture_based=True,
    ),
    "octmnist": DatasetMetadata(
        name="octmnist",
        display_name="OCTMNIST",
        md5_checksum="abc493b6d529d5de7569faaef2773ba3",
        url="https://zenodo.org/records/10519652/files/octmnist_224.npz?download=1",
        path=DATASET_DIR / "octmnist_224.npz",
        classes=["choroidal neovascularization", "diabetic macular edema", "drusen", "normal"],
        mean=(0.5,),
        std=(0.5,),
        in_channels=1,
        native_resolution=224,
        is_anatomical=True,
        is_texture_based=True,
    ),
    "pneumoniamnist": DatasetMetadata(
        name="pneumoniamnist",
        display_name="PneumoniaMNIST",
        md5_checksum="d6a3c71de1b945ea11211b03746c1fe1",
        url="https://zenodo.org/records/10519652/files/pneumoniamnist_224.npz?download=1",
        path=DATASET_DIR / "pneumoniamnist_224.npz",
        classes=["normal", "pneumonia"],
        mean=(0.5,),
        std=(0.5,),
        in_channels=1,
        native_resolution=224,
        is_anatomical=True,
        is_texture_based=False,
    ),
    "retinamnist": DatasetMetadata(
        name="retinamnist",
        display_name="RetinaMNIST",
        md5_checksum="eae7e3b6f3fcbda4ae613ebdcbe35348",
        url="https://zenodo.org/records/10519652/files/retinamnist_224.npz?download=1",
        path=DATASET_DIR / "retinamnist_224.npz",
        classes=["No DR", "Mild DR", "Moderate DR", "Severe DR", "Proliferative DR"],
        mean=(0.485, 0.456, 0.406),
        std=(0.229, 0.224, 0.225),
        in_channels=3,
        native_resolution=224,
        is_anatomical=False,
        is_texture_based=True,
    ),
    "breastmnist": DatasetMetadata(
        name="breastmnist",
        display_name="BreastMNIST",
        md5_checksum="b56378a6eefa9fed602bb16d192d4c8b",
        url="https://zenodo.org/records/10519652/files/breastmnist_224.npz?download=1",
        path=DATASET_DIR / "breastmnist_224.npz",
        classes=["malignant", "benign"],
        mean=(0.5,),
        std=(0.5,),
        in_channels=1,
        native_resolution=224,
        is_anatomical=True,
        is_texture_based=False,
    ),
    "organamnist": DatasetMetadata(
        name="organmnist",
        display_name="OrganAMNIST",
        md5_checksum="50747347e05c87dd3aaf92c49f9f3170",
        url="https://zenodo.org/records/10519652/files/organamnist_224.npz?download=1",
        path=DATASET_DIR / "organamnist_224.npz",
        classes=[
            "bladder",
            "femur-left",
            "femur-right",
            "heart",
            "kidney-left",
            "kidney-right",
            "liver",
            "lung-left",
            "lung-right",
            "pancreas",
            "spleen",
        ],
        mean=(0.5,),
        std=(0.5,),
        in_channels=1,
        native_resolution=224,
        is_anatomical=True,
        is_texture_based=False,
    ),
    "tissuemnist": DatasetMetadata(
        name="tissuemnist",
        display_name="TissueMNIST",
        md5_checksum="b077128c4a949f0a4eb01517f9037b9c",
        url="https://zenodo.org/records/10519652/files/tissuemnist_224.npz?download=1",
        path=DATASET_DIR / "tissuemnist_224.npz",
        classes=[
            "Collecting Duct",
            "Distal Tubule",
            "Glomerulus",
            "Medulla",
            "Proximal Tubule",
            "Capsule",
            "Large Vessel",
            "Small Vessel",
        ],
        mean=(0.5,),
        std=(0.5,),
        in_channels=1,
        native_resolution=224,
        is_anatomical=False,
        is_texture_based=True,
    ),
    "organcmnist": DatasetMetadata(
        name="organcmnist",
        display_name="OrganCMNIST",
        md5_checksum="050f5e875dc056f6768abf94ec9995d1",
        url="https://zenodo.org/records/10519652/files/organcmnist_224.npz?download=1",
        path=DATASET_DIR / "organcmnist_224.npz",
        classes=[
            "bladder",
            "femur-left",
            "femur-right",
            "heart",
            "kidney-left",
            "kidney-right",
            "liver",
            "lung-left",
            "lung-right",
            "pancreas",
            "spleen",
        ],
        mean=(0.5,),
        std=(0.5,),
        in_channels=1,
        native_resolution=224,
        is_anatomical=True,
        is_texture_based=False,
    ),
}
