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.

fmralign.alignment.pairwise_alignment.PairwiseAlignment

class fmralign.alignment.pairwise_alignment.PairwiseAlignment(method='identity', labels=None, n_jobs=1, verbose=0)[source]

Performs pairwise alignment between two subjects.

This class performs source-to-target alignment of two subjects’ 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.

Attributes:
labels_array-like

Validated labels used during fitting.

method_str

Validated alignment method used during fitting.

fitted_estimatorBaseAlignment object

List of fitted alignment estimators, one per subject.

Examples

>>> from fmralign import PairwiseAlignment
>>> X = np.random.rand(10, 5)
>>> Y = np.random.rand(10, 5)
>>> test_data = np.random.rand(8, 5)
>>> aligner = PairwiseAlignment(method="procrustes")
>>> aligner.fit(X, Y)
>>> aligned_data = aligner.transform(test_data)
__init__(method='identity', labels=None, n_jobs=1, verbose=0)[source]
fit(X, Y)[source]

Fit the pairwise alignment model to the data.

Parameters:
Xarray-like

Source data for alignment of shape (n_samples, n_features).

Yarray-like

Target data for alignment of shape (n_samples, n_features).

fit_transform()[source]

Parent method not applicable here.

Will raise AttributeError if called.

get_metadata_routing()

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Returns:
routingMetadataRequest

A MetadataRequest encapsulating routing information.

get_params(deep=True)

Get parameters for this estimator.

Parameters:
deepbool, default=True

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns:
paramsdict

Parameter names mapped to their values.

set_output(*, transform=None)

Set output container.

See Introducing the set_output API for an example on how to use the API.

Parameters:
transform{“default”, “pandas”, “polars”}, default=None

Configure output of transform and fit_transform.

  • “default”: Default output format of a transformer

  • “pandas”: DataFrame output

  • “polars”: Polars output

  • None: Transform configuration is unchanged

Added in version 1.4: “polars” option was added.

Returns:
selfestimator instance

Estimator instance.

set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters:
**paramsdict

Estimator parameters.

Returns:
selfestimator instance

Estimator instance.

transform(X)[source]

Transform the input arrays using the fitted model.

Parameters:
Xdict of array-like

Dictionary where keys are subject identifiers and values are array of subject data. Each array should have the same number of samples and features.

Returns:
dict of array-like

Dictionary with transformed subject data.

Examples using fmralign.alignment.pairwise_alignment.PairwiseAlignment

Template-based prediction.

Template-based prediction.

Pairwise functional alignment.

Pairwise functional alignment.

Pairwise functional alignment on a ROI.

Pairwise functional alignment on a ROI.

Pairwise surface alignment.

Pairwise surface alignment.