"""Brain atlases"""
{% raw -%}
from pydantic import BaseModel, ConfigDict
{% endraw %}

class BrainStructureModel(BaseModel):
    """Base model for brain strutures"""
    model_config = ConfigDict(frozen=True)
    atlas: str
    name: str
    acronym: str
    id: str

class CCFv3:
    """CCFv3"""
{% for _, row in data.iterrows() %}
    {{ row['acronym'] | to_class_name | upper }} = BrainStructureModel(
        atlas="CCFv3",
        name="{{ row['name'] }}",
        acronym="{{ row['acronym'] }}",
        id="{{ row['id'] }}",
    )
{%- endfor %}

{% raw %}
    @classmethod
    def from_id(cls, id: str):
        """Get structure by ID"""
        for attr_name in dir(cls):
            attr = getattr(cls, attr_name)
            if isinstance(attr, BrainStructureModel) and attr.id == id:
                return attr
        raise ValueError(f"Structure with ID {id} not found.")

    @classmethod
    def by_name(cls, name: str):
        """Get structure by name"""
        for attr_name in dir(cls):
            attr = getattr(cls, attr_name)
            if isinstance(attr, BrainStructureModel) and attr.name == name:
                return attr
        raise ValueError(f"Structure with name '{name}' not found.")

    @classmethod
    def by_acronym(cls, acronym: str):
        """Get structure by acronym"""
        for attr_name in dir(cls):
            attr = getattr(cls, attr_name)
            if isinstance(attr, BrainStructureModel) and attr.acronym == acronym:
                return attr
        raise ValueError(f"Structure with acronym '{acronym}' not found.")
{% endraw %}