Note
This page is a reference documentation. It only explains the class signature, and not how to use it. Please refer to the user guide for the big picture.
3.2.1. fmralign.alignment.group_alignment.GroupAlignment¶
- class fmralign.alignment.group_alignment.GroupAlignment(method='identity', labels=None, n_jobs=1, verbose=0, n_iter=2, scale_template=False)[source]¶
Performs group-level alignment of various subject data.
This class aligns multiple subjects’ data either to a computed template or to a specific target subject’s data. It supports various alignment methods and can process data in parallel.
- Parameters:
- methodstr or a BaseAlignment instance, default=”identity”
The alignment method to use. It can be a string representing the method name or an instance of a class derived from BaseAlignment. Available methods include: [“identity”, “procrustes”, “ot”, “sparseuot”, “ridge”].
- labelsarray-like or None, default=None
Describes each voxel label’s in the case of non-overlapping parcels. If provided, local alignments can be performed in parallel. If None, global alignment is performed across all features.
- n_jobsint, default=1
Number of parallel jobs to run. -1 means using all processors.
- verboseint, default=0
Verbosity level. Higher values provide more detailed output.
- n_iterint, default=2
Number of iterations for the template alignment algorithm.
- scale_templatebool, default=False
Whether to scale the features during template learning. If True, features are rescaled to the updating Euclidean mean.
- Attributes:
- labels_array-like
Validated labels used during fitting.
- method_str
Validated alignment method used during fitting.
- fit_list
List of fitted alignment estimators, one per subject.
- templatearray-like or None
Computed template for template alignment. None for pairwise alignment.
Examples
>>> import numpy as np >>> from fmralign import GroupAlignment >>> n_voxels = 5
>>> # Template alignment >>> alignment_dict = { ... "sub-01": np.random.rand(10, n_voxels), ... "sub-02": np.random.rand(10, n_voxels), ... } >>> testing_dict = { ... "sub-01": np.random.rand(8, n_voxels), ... "sub-02": np.random.rand(8, n_voxels), ... } >>> aligner = GroupAlignment(method="procrustes", n_iter=3) >>> aligner.fit(alignment_dict, y="template") >>> aligned_data = aligner.transform(testing_dict)
>>> # Pairwise alignment to target >>> target_data = np.random.rand(10, n_voxels) >>> aligner = GroupAlignment(method="procrustes") >>> aligner.fit(alignment_dict, y=target_data) >>> aligned_data = aligner.transform(testing_dict)
3.2.1.1. Examples using fmralign.alignment.group_alignment.GroupAlignment
¶

Alignment methods benchmark (template-based ROI case)