loader
lacuna.assets.masks.loader
¶
Brain mask loading.
Downloads (with SHA-256 verification) and caches a binary brain mask for a given
coordinate space and resolution via pooch, then validates that the file is a
binary mask on Lacuna's canonical grid for that space/resolution before use.
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. |