Skip to content

Brain Atlas

BrainGlobe-backed atlas integration. Downloads atlas data on first use and registers anatomical meshes into the lab coordinate frame. See the Brain Atlas user guide.

BG_Atlas

BG_Atlas(
    atlas_name=None,
    region_names=None,
    *,
    whs_voxels=None,
    manual_fit=None,
    verbose=False,
)

Wrap a BrainGlobe atlas and align it to the eSDIva brain coordinate space.

Parameters:

Name Type Description Default
atlas_name str

BrainGlobe atlas name (e.g. "whs_sd_rat"). If None, a list of available atlases is printed. Default is None.

None
region_names str or list[str]

Structure name(s) to load. Default is None (falls back to "root").

None
whs_voxels dict

Landmark voxel coordinates with keys "origin", "bregma", "lambda" (each a length-3 ndarray). Default is None.

None
manual_fit dict

Manual alignment with keys "origin" (voxel, length-3 ndarray) and "bregma_lambda_um" (scalar distance in micrometres). Default is None.

None
verbose bool

If True, print intermediate matrices during alignment. Default is False.

False

set_bgatlas

set_bgatlas(
    atlas_name,
    region_names=None,
    *,
    whs_voxels=None,
    manual_fit=None,
    verbose=False,
)

Load a BrainGlobe atlas and update the instance attributes.

Parameters:

Name Type Description Default
atlas_name str

The name of the BrainGlobe atlas to load.

required
region_names str or list[str]

Structure name(s) to retrieve. Default is None (falls back to "root").

None
whs_voxels dict

Landmark voxel coordinates with keys "origin", "bregma", "lambda". Default is None.

None
manual_fit dict

Manual alignment with keys "origin" and "bregma_lambda_um". Default is None.

None
verbose bool

If True, print intermediate matrices. Default is False.

False

get_pv_mesh_from_atlas

get_pv_mesh_from_atlas(bg_atlas, region_names)

Load PyVista mesh(es) from a BrainGlobe atlas for the given structures.

Parameters:

Name Type Description Default
bg_atlas BrainGlobeAtlas

The BrainGlobe atlas object.

required
region_names str or list[str]

The name(s) of the structure(s) to retrieve.

required

Returns:

Type Description
dict[str, PolyData]

Mapping of region name to its PyVista mesh.

transform

transform(T_matrix=None, pv_mesh=None, *, inplace=False)

Apply an affine transformation to the stored or supplied PyVista mesh.

Parameters:

Name Type Description Default
T_matrix (4, 4) numpy.ndarray

Homogeneous transformation matrix to apply. If None, no transformation is performed. Default is None.

None
pv_mesh dict[str, PolyData]

Mesh(es) to transform. If None, the atlas mesh stored on the instance is used. Default is None.

None
inplace bool

If True, mutate the instance's mesh in place and return None. If False, return a transformed copy. Default is False.

False

Returns:

Type Description
dict[str, PolyData] or None

Transformed mesh(es), or None when inplace=True.

reset_mesh

reset_mesh()

Reload the PyVista mesh from the atlas and re-apply the BPS transform.

Returns:

Type Description
dict[str, PolyData]

The freshly loaded and transformed mesh(es).

summary

summary()

Print a summary of the BG_Atlas object.

show_atlases

show_atlases()

Show available BrainGlobe atlases.