pymovements.Phenotype.load#

static Phenotype.load(path: Path | str, metadata: Path | str | dict[str, Any] | None = None, *, separator: str = '\t', rename: dict[str, str] | None = None, read_csv_kwargs: dict[str, Any] | None = None, metadata_encoding: str = 'utf-8', verify_bids: Literal['REQUIRED', 'RECOMMENDED'] | bool = False) → Phenotype[source]#

Load phenotypic data from phenotype files.

By default, values encoded as 'n/a' are read as null values per BIDS. A cell whose literal content is 'n/a' therefore cannot be distinguished from a missing value. To keep such strings, pass a different null_values via read_csv_kwargs (for example read_csv_kwargs={'null_values': []}).

Parameters:
  • path (Path | str) – Path of the phenotype tabular data file, e.g. phenotype/acds_adult.tsv. Each file holds the data of a single measurement tool.

  • metadata (Path | str | dict[str, Any] | None) – Additional metadata. Can be directly passed as a dictionary. If path or string: load metadata from json file. If a relative path given, path is assumed to be relative to parent of path. If None: check for corresponding json file in the same directory and load metadata if available. (default: None)

  • separator (str) – Separator in the tabular data file. (default: \t)

  • rename (dict[str, str] | None) – Rename columns according to mapping in dictionary. (default: None)

  • read_csv_kwargs (dict[str, Any] | None) – Pass these additional keyword arguments to polars.read_csv(). Takes precedence over the separator argument. (default: None)

  • metadata_encoding (str) – Use this encoding for loading the metadata json file. (default: utf-8)

  • verify_bids (Literal['REQUIRED', 'RECOMMENDED'] | bool) – Verify BIDS conformity after loading. If True, raise exception on non-conformity at REQUIRED level. If ‘REQUIRED’ or ‘RECOMMENDED’, emit warnings for non-conformity at that level, except for a missing participant_id column, which raises a ValueError. If False, do not verify. (default: False)

Returns:

Phenotype initialised with data from loaded files.

Return type:

Phenotype