spectralbrain.utils.datasets#

Template data, example datasets, and public dataset fetchers.

Provides quick access to template geometries (fsaverage, MNI152) and synthetic example datasets for tutorials and testing.

Functions

example_point_cloud([n_points, shape, seed])

Quick point cloud for testing.

example_sphere([n_lat, n_lon, radius])

Quick sphere mesh for testing.

fetch_fsaverage([mesh, hemisphere])

Load fsaverage template surfaces from nibabel's bundled data.

make_connectome_example([n_subjects, ...])

Generate synthetic geometric connectomes for two groups.

make_laterality_example([n_subjects, ...])

Generate synthetic bilateral descriptors for asymmetry analysis.

make_normative_example([n_subjects, ...])

Generate a synthetic normative cohort with age effects.

make_two_group_example([n_per_group, ...])

Generate a two-group synthetic dataset for tutorials.

spectralbrain.utils.datasets.example_point_cloud(n_points=1000, shape='sphere', seed=0)[source]#

Quick point cloud for testing.

Parameters:
  • n_points (int)

  • shape (str) – "sphere", "ellipsoid", "blob", "multi_cluster".

  • seed (int)

Returns:

ndarray, shape (n_points, 3)

Return type:

ndarray

spectralbrain.utils.datasets.example_sphere(n_lat=30, n_lon=60, radius=50.0)[source]#

Quick sphere mesh for testing.

Returns:

vertices, faces

Parameters:
Return type:

tuple[ndarray[tuple[Any, …], dtype[floating]], ndarray[tuple[Any, …], dtype[int64]]]

spectralbrain.utils.datasets.fetch_fsaverage(mesh='pial', hemisphere='lh')[source]#

Load fsaverage template surfaces from nibabel’s bundled data.

Parameters:
  • mesh (str) – "pial", "white", "inflated", "sphere".

  • hemisphere (str) – "lh" or "rh".

Returns:

vertices, faces

Return type:

tuple[ndarray[tuple[Any, …], dtype[floating]], ndarray[tuple[Any, …], dtype[int64]]]

spectralbrain.utils.datasets.make_connectome_example(n_subjects=40, n_parcels=50, n_networks=5, group_effect=0.3, seed=42)[source]#

Generate synthetic geometric connectomes for two groups.

Parameters:
Returns:

dict – Keys: "connectomes" (S, R, R), "labels" (S,), "network_assignments" dict.

Return type:

dict[str, Any]

spectralbrain.utils.datasets.make_laterality_example(n_subjects=40, n_features=50, asymmetry=0.3, seed=42)[source]#

Generate synthetic bilateral descriptors for asymmetry analysis.

Parameters:
  • n_subjects (int)

  • n_features (int)

  • asymmetry (float) – Planted L > R asymmetry in patients.

  • seed (int)

Returns:

dict – Keys: "left" (S, d), "right" (S, d), "labels" (S,).

Return type:

dict[str, Any]

spectralbrain.utils.datasets.make_normative_example(n_subjects=200, n_vertices=500, age_range=(20, 80), seed=42)[source]#

Generate a synthetic normative cohort with age effects.

Parameters:
Returns:

dict – Keys: "descriptors" (S, N), "ages" (S,), "sex" (S,), "age_slope" (N,).

Return type:

dict[str, Any]

spectralbrain.utils.datasets.make_two_group_example(n_per_group=30, n_vertices=500, n_scales=10, effect_size=0.5, seed=42)[source]#

Generate a two-group synthetic dataset for tutorials.

Creates descriptors for controls and patients with a focal spectral difference at a subset of vertices.

Parameters:
  • n_per_group (int)

  • n_vertices (int)

  • n_scales (int)

  • effect_size (float) – Cohen’s d of the planted difference.

  • seed (int)

Returns:

dict – Keys: "controls" (n, N, T), "patients" (n, N, T), "labels" (2n,), "affected_vertices" (bool mask), "ages" (2n,), "metadata".

Return type:

dict[str, Any]