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.methods.SpectralOT

class fmralign.methods.SpectralOT(evecs, alpha=0.5, reg=0.01, max_iter=1000, tol=1e-07, verbose=False, device='cpu', **kwargs)[source]

Compute the optimal coupling between X and Y using an anatomy-aware cost matrix that combines functional and harmonic distances.

Parameters:
evecs(k, n_features) nd array

Harmonic embedding of the geometry, first k eigenmodes of the Laplace-Beltrami operator.

alphafloat

Trade-off parameter controlling the balance between functional data and the harmonic embedding evecs. Values should lie in the interval [0, 1], where higher values put more weight on the anatomy. Defaults to 0.5.

regfloat (optional)

Strength of the entropic regularization. Defaults to 0.01.

max_iterint (optional)

Maximum number of iterations. Defaults to 1000.

tolfloat (optional)

Tolerance for stopping criterion. Defaults to 1e-7.

verbosebool (optional)

Allow verbose output. Defaults to False.

devicestr

Torch compatible device. Defaults to “cpu”.

kwargsdict

Additional arguments to be passed to the OT solver.

Attributes:
R(n_features, n_features) nd array or LazyTensor

Transport plan computed during fitting.

__init__(evecs, alpha=0.5, reg=0.01, max_iter=1000, tol=1e-07, verbose=False, device='cpu', **kwargs)[source]
fit(X, Y)[source]
Parameters:
X: (n_samples, n_features) nd array

source data

Y: (n_samples, n_features) nd array

target data

fit_transform(X, y=None, **fit_params)

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters:
Xarray-like of shape (n_samples, n_features)

Input samples.

yarray-like of shape (n_samples,) or (n_samples, n_outputs), default=None

Target values (None for unsupervised transformations).

**fit_paramsdict

Additional fit parameters. Pass only if the estimator accepts additional params in its fit method.

Returns:
X_newndarray array of shape (n_samples, n_features_new)

Transformed array.

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)

Transform X using optimal coupling computed during fit.