loader
lacuna.assets.parcellations.loader
¶
Parcellation loading functions for bundled and user-registered parcellations.
This module provides functions to load parcellations from the registry. Supports both bundled parcellations (shipped with Lacuna) and user-registered custom parcellations.
Examples:
>>> from lacuna.assets.parcellations import load_parcellation
>>>
>>> # Load a bundled parcellation
>>> parcellation = load_parcellation("schaefer2018parcels100networks7")
>>> print(parcellation.image.shape)
>>> print(list(parcellation.labels.keys())[:5])
>>>
>>> # Access metadata
>>> print(parcellation.metadata.space)
>>> print(parcellation.metadata.citation)
Parcellation
dataclass
¶
Loaded parcellation with image data, labels, and metadata.
Attributes:
| Name | Type | Description |
|---|---|---|
image |
Nifti1Image
|
The parcellation image (3D or 4D for probabilistic parcellations) |
labels |
dict[int, str]
|
Mapping from region ID to region name |
metadata |
ParcellationMetadata
|
Parcellation metadata from registry |
Source code in src/lacuna/assets/parcellations/loader.py
load_parcellation(parcellation_name)
¶
Load an parcellation by name from the registry.
Loads bundled parcellations or user-registered custom parcellations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parcellation_name
|
str
|
Name of the parcellation from PARCELLATION_REGISTRY |
required |
Returns:
| Type | Description |
|---|---|
Parcellation
|
Loaded parcellation with image, labels, and metadata |
Raises:
| Type | Description |
|---|---|
KeyError
|
If parcellation_name is not in the registry |
FileNotFoundError
|
If parcellation files are not found |
Examples:
>>> parcellation = load_parcellation("schaefer2018parcels100networks7")
>>> print(f"Parcellation has {len(parcellation.labels)} regions")
>>> print(f"Space: {parcellation.metadata.space}")