SubjectDescription¶
- class brainsets.descriptions.SubjectDescription(*args, **kwargs)[source]¶
Bases:
DataA class for describing a subject.
Fields are automatically normalized during construction: -
speciesaccepts a Species enum, string, int, or None (defaults to Species.UNKNOWN) -ageaccepts a float, int, numeric string, or None (defaults to 0.0) -sexaccepts a Sex enum, string, int, or None (defaults to Sex.UNKNOWN)- Parameters:
id (str) – Unique identifier for the subject
species (Species) – Species of the subject
age (float, optional) – Age of the subject in days, defaults to 0.0
sex (Sex, optional) – Sex of the subject, defaults to UNKNOWN
genotype (str, optional) – Genotype of the subject, defaults to “unknown”
cre_line (Cre_line, optional) – Cre line of the subject, defaults to None
- classmethod normalize_age(age=None)[source]¶
Normalize an age value to a float in days.
- Parameters:
age (
Union[float,int,str,None]) – Age of the subject. Can be a float, int, numeric string, or None.- Return type:
- Returns:
Normalized age as a float. Defaults to 0.0 if None or unparseable.
- Raises:
ValueError – If the age is negative.
TypeError – If the age is not a float, int, numeric string, or None.
- classmethod normalize_sex(sex=None)[source]¶
Normalize a sex value to a Sex enum member.
- Parameters:
sex (
Union[str,int,Sex,None]) – Sex of the subject. Can be a string (e.g. “M”, “MALE”), an int (0=UNKNOWN, 1=MALE, 2=FEMALE, 3=OTHER), a Sex enum member, or None.- Return type:
- Returns:
Normalized Sex enum member. Defaults to Sex.UNKNOWN if None or unrecognized.
- Raises:
TypeError – If the sex is not a Sex enum, string, int, or None.
- classmethod normalize_species(species=None)[source]¶
Normalize a species value to a Species enum member.
- Parameters:
species (
Union[str,int,Species,None]) – Species of the subject. Can be a string, an int, a Species enum member, or None.- Return type:
- Returns:
Normalized Species enum member. Defaults to Species.UNKNOWN if None or unrecognized.
- Raises:
TypeError – If the species is not a Species enum, string, int, or None.