ibl_alignment_gui.utils.parse_yaml

Functions

load_alignment_yaml

Load and parse alignment configuration YAML file.

resolve_path

Resolve dataset path using hierarchical path resolution.

Classes

AlignmentYAML

Root-level YAML configuration structure.

Configuration

Configuration for a single experimental configuration.

DatasetPaths

Container for resolved dataset paths for a single probe.

Datasets

Dataset configuration.

Probe

Configuration for a single probe.

class ibl_alignment_gui.utils.parse_yaml.AlignmentYAML(**data)[source]

Bases: BaseModel

Root-level YAML configuration structure.

Variables:
  • defaults (dict[str, Datasets]) – Default dataset configurations applied to all probes

  • configurations (dict[str, Configuration]) – Dictionary mapping configuration names to their configurations

  • path (Path | None) – Global root path for resolving all relative paths

configurations: dict[str, Configuration]
defaults: dict[str, Datasets] | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

path: Path | None
class ibl_alignment_gui.utils.parse_yaml.Configuration(**data)[source]

Bases: BaseModel

Configuration for a single experimental configuration.

Variables:
  • probes (dict[str, Probe]) – Dictionary mapping probe names to their configurations

  • path (Path | None) – Configuration-level base path for resolving relative probe paths

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

path: Path | None
probes: dict[str, Probe]
class ibl_alignment_gui.utils.parse_yaml.DatasetPaths(**data)[source]

Bases: BaseModel

Container for resolved dataset paths for a single probe.

Variables:
  • spike_sorting (Path | None) – Path to spike sorting output directory

  • processed_ephys (Path | None) – Path to processed electrophysiology data directory

  • raw_ephys (Path | None) – Path to raw electrophysiology recordings directory

  • task (Path | None) – Path to task data directory

  • raw_task (Path | None) – Path to raw task data directory

  • picks (Path | None) – Path to probe trajectory pick files directory

  • histology (Path | None) – Path to histology volume directory

  • output (Path | None) – Path to alignment output directory

  • features (Path | None) – Path to a per-channel ephys-features parquet file (used by the local channel-prediction plugin so the features travel with the session config).

  • transforms (Path | None) – Path to a folder of registration transforms used to warp channel locations into the Allen CCF (anatomical workflow only). When set, channel locations are additionally saved in CCF coordinates.

features: Path | None
histology: Path | None
histology_space: str
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

output: Path | None
picks: Path | None
processed_ephys: Path | None
raw_ephys: Path | None
raw_task: Path | None
spike_sorting: Path | None
task: Path | None
transforms: Path | None
class ibl_alignment_gui.utils.parse_yaml.Datasets(**data)[source]

Bases: BaseModel

Dataset configuration.

Variables:
  • path (Path) – Relative or absolute path to the dataset directory

  • space ({'ccf', 'anatomical'} | None) – Only meaningful for the histology entry of the top-level defaults section: the session-level coordinate space to use for histology slice loading. ‘ccf’ loads via NrrdSliceLoader using the Allen CCF atlas; ‘anatomical’ loads via AnatomicalSliceLoader using the original image space produced by the histology registration pipeline.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

path: Path | None
space: Optional[Literal['ccf', 'anatomical']]
class ibl_alignment_gui.utils.parse_yaml.Probe(**data)[source]

Bases: BaseModel

Configuration for a single probe.

Variables:
  • datasets (dict[str, Datasets] | None) – Dictionary mapping dataset names to their configurations

  • path (Path | None) – Probe-level base path for resolving relative dataset paths

datasets: dict[str, Datasets] | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

path: Path | None
ibl_alignment_gui.utils.parse_yaml.load_alignment_yaml(yaml_file)[source]

Load and parse alignment configuration YAML file.

Resolves all dataset paths using hierarchical path resolution and applies defaults.

Parameters:

yaml_file (str) – Path to the YAML configuration file

Return type:

tuple[list[str], list[str], dict[str, dict[str, DatasetPaths]], str]

Returns:

  • configs (list of str) – List of configuration names

  • probes (list of str) – List of unique probe names across all configurations

  • data_paths (A dict of dicts of DatasetPaths) – Nested dictionary of resolved paths: data_paths[config_name][probe_name] -> DatasetPaths

  • histology_space (str) – Session-level histology coordinate space, read from the space field of the defaults histology entry (‘ccf’ if unspecified). ‘ccf’ loads histology via the Allen CCF atlas; ‘anatomical’ loads the original image space from the registration pipeline.

Notes

  • If no ‘configurations’ section exists, creates a ‘default’ configuration

  • Falls back to the spike_sorting path if raw_ephys is not specified

  • Falls back to the raw_ephys path if processed_ephys is not specified

  • Falls back to the spike_sorting path, and then the picks path, if output is not specified

Raises:
  • FileNotFoundError – If the yaml file does not exist.

  • ValueError – If the yaml file is empty or does not contain a mapping.

ibl_alignment_gui.utils.parse_yaml.resolve_path(dataset_path=None, probe_path=None, config_path=None, global_path=None, default_path=None)[source]

Resolve dataset path using hierarchical path resolution.

If path is absolute at any stage, it is returned immediately. Otherwise path is resolved progressively through the provided paths.

Return type:

Path | None

Resolution order:

dataset probe / dataset config / probe/ dataset global / config / probe / dataset

If that path is still relative at the end, an error is raised.