spectralbrain.SpectralDecomposition#
- class spectralbrain.SpectralDecomposition(eigenvalues, eigenvectors, *, stiffness=None, mass=None, surface_area=None, metadata=None)[source]#
Bases:
objectEigenvalues and eigenvectors of a Laplace–Beltrami operator.
This is the central object of SpectralBrain. It is produced by
core.meshes.BrainMesh.decompose()orcore.pointclouds.BrainPointCloud.decompose()and consumed by every function inspectral/.- Parameters:
eigenvalues (ndarray, shape (k,)) – Non-negative LBO eigenvalues, sorted ascending.
eigenvectors (ndarray, shape (N, k)) – Corresponding eigenvectors, M-orthonormal.
stiffness (SparseMatrix, optional) – The Laplacian matrix L.
mass (MassMatrix, optional) – The mass matrix M.
surface_area (float, optional) – Total surface area (for eigenvalue normalisation).
metadata (dict, optional) – Provenance info (subject, hemisphere, structure, backend, …).
- eigenvalues#
- Type:
ndarray
- eigenvectors#
- Type:
ndarray
- stiffness#
- Type:
SparseMatrix or None
- mass#
- Type:
MassMatrix or None
Examples
>>> mesh = sb.core.BrainMesh(vertices, faces) >>> decomp = mesh.decompose(k=100) >>> decomp.n_eigenvalues 100 >>> decomp.fiedler_value 0.0023 >>> decomp.truncate(50).n_eigenvalues 50
>>> # Pass to spectral descriptors: >>> hks = sb.spectral.compute_hks(decomp, t_values)
- __init__(eigenvalues, eigenvectors, *, stiffness=None, mass=None, surface_area=None, metadata=None)[source]#
Initialise from eigenvalues, eigenvectors, and optional matrices.
Methods
__init__(eigenvalues, eigenvectors, *[, ...])Initialise from eigenvalues, eigenvectors, and optional matrices.
load(path)Load from an HDF5 cache file.
normalize_eigenvalues([method, area, volume])Return a copy with normalised eigenvalues.
save(path, **kwargs)Save to HDF5 via
spectralbrain.io.export.save_hdf5().truncate(k)Return a copy with only the first k eigenpairs.
Attributes
First non-trivial eigenvalue λ₁ (the Fiedler value).
Alias for
n_eigenvalues.Number of stored eigenpairs.
Number of vertices/points.
ShapeDNA — the raw eigenvalue sequence (excluding λ₀ ≈ 0).
Area-normalised ShapeDNA.
Gap between λ₁ and λ₂.
- classmethod load(path)[source]#
Load from an HDF5 cache file.
- Parameters:
path (PathLike)
- Returns:
SpectralDecomposition
- Return type:
- normalize_eigenvalues(method='area', area=None, volume=None)[source]#
Return a copy with normalised eigenvalues.
- Parameters:
- Returns:
SpectralDecomposition
- Return type:
- save(path, **kwargs)[source]#
Save to HDF5 via
spectralbrain.io.export.save_hdf5().
- truncate(k)[source]#
Return a copy with only the first k eigenpairs.
- Parameters:
k (int) – Number of eigenpairs to keep (must be ≤ current k).
- Returns:
SpectralDecomposition
- Return type:
- property fiedler_value: float#
First non-trivial eigenvalue λ₁ (the Fiedler value).
Encodes global connectivity of the shape. Larger values indicate tighter geometry.
- property k: int#
Alias for
n_eigenvalues.
- property shape_dna: ndarray[tuple[Any, ...], dtype[floating]]#
ShapeDNA — the raw eigenvalue sequence (excluding λ₀ ≈ 0).
- Returns:
ndarray, shape (k-1,)