Index
lacuna.assets.masks
¶
Brain mask assets.
Binary brain masks per coordinate space and resolution, redistributed via OSF and
downloaded/cached on first use. See :func:load_brain_mask.
BrainMaskMetadata
dataclass
¶
Bases: SpatialAssetMetadata
Metadata for a binary brain mask.
Attributes:
| Name | Type | Description |
|---|---|---|
space |
str
|
Coordinate space (e.g. "MNI152NLin6Asym"). |
resolution |
float
|
Voxel resolution in mm (1.0 or 2.0). |
url |
str
|
Download URL (fetched and cached on first use). |
sha256 |
str
|
Expected SHA-256 of the file (verified on download). |
source |
str
|
Origin of the mask data. |
Source code in src/lacuna/assets/masks/registry.py
load_brain_mask(space, resolution, *, validate=True)
¶
Load a binary brain mask for space/resolution, caching on first use.
Anatomically identical spaces (e.g. MNI152NLin2009[abc]Asym) are normalized to their canonical form before lookup.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
space
|
str
|
Coordinate space identifier (e.g. "MNI152NLin6Asym"). |
required |
resolution
|
float
|
Voxel resolution in mm (1.0 or 2.0). |
required |
validate
|
bool
|
Verify the downloaded file is a binary 3D mask on the canonical grid. |
True
|
Returns:
| Type | Description |
|---|---|
Path
|
Path to the locally cached brain mask (.nii.gz). |
Raises:
| Type | Description |
|---|---|
KeyError
|
If no mask is registered for the space/resolution. |
FileNotFoundError
|
If the mask has no URL or the download fails. |
ValueError
|
If validation fails. |