Skip to content

config

BraiAnConfig

BraiAnConfig(config_file, cache_path)

Reads a YAML configuration file for managing a whole-brain experiment, made of multiple cohorts, with braian.

An example of a valid configuration file is the following:

# SPDX-FileCopyrightText: 2024 Carlo Castoldi <carlo.castoldi@outlook.com>
#
# SPDX-License-Identifier: CC0-1.0

experiment:
name: "example"
output_dir: "data/BraiAn_output"

groups:
HC: ["287HC", "342HC", "343HC", "346HC", "371HC"]
CTX: ["329CTX", "331CTX", "355CTX", "400CTX", "401CTX", "402CTX"]
FC: ["367FC", "368FC", "369FC", "426FC", "427FC", "428FC"]

atlas:
version: "v3"
excluded-branches: ["retina", "VS", "grv", "fiber tracts", "CB"]

brains:
raw-metric: "sum"

qupath:
files:
    dirs:
    output: "data/QuPath_output"
    results_subdir: "results"
    exclusions_subdir: "regions_to_exclude"
    suffix:
    results: "_regions.txt"
    exclusions: "_regions_to_exclude.txt"
    markers:
    AF568: "cFos"
    AF647: "Arc"
exclude-parents: true
min-slices: 0

Parameters:

  • config_file : Path | str

    The path to a valid YAML configuration file.

  • cache_path : Path | str

    A path to a folder used to store files downloaded from the web and used for computations.
    At the moment this is used only to store the brain ontology to which the whole-brain data was aligned to.

read_atlas_ontology

read_atlas_ontology()

Reads the brain ontology specified in the configuration file, and, if necessary, it dowloads it from the web.

Returns:

  • AllenBrainOntology

    The brain ontology associated with the whole-brain data of the experiment.

experiment_from_qupath

experiment_from_qupath(sliced=False, validate=True)

Reads all the slice data exported to files with BraiAn's QuPath extension, and organises them into braian data structure used to identify an experiment.

If read_atlas_ontology() was not called previously, it reads the ontology.

Parameters:

  • sliced : bool, default= False

    If False, after reading all the files about each section of the experiment, it reduces, for each brain, the data of every brain region into a single value accordingly to the method specified in the configuration file.
    Otherwise, it keeps the raw data.

  • validate : bool, default= True

    If True, it validates each region in each brain, checking that they are present in the brain region ontology against which the brains were alligned.

See also

SlicedGroup.from_qupath SlicedExperiment.to_experiment

Returns:

experiment_from_sliced

experiment_from_sliced(sliced_exp, hemisphere_distinction=True, validate=True)

It reduces, for each brain of a sliced experiment, the data of every brain region into a single value accordingly to the method specified in the configuration file.

Parameters:

  • sliced_exp : SlicedExperiment

    The experiment sliced into sections to reduce into one value per-region per-brain.

  • validate : bool, default= True

    If True, it validates each region in each brain, checking that they are present in the brain region ontology against which the brains were alligned.

Returns: