coco_pipe.transforms.TemporalProcrustesAlignment#
- class coco_pipe.transforms.TemporalProcrustesAlignment(n_components=30, *, adaptation='transductive', rotate=True, use_shared_basis=False, augment=(), augment_only=False, trajectory_metrics=None, random_state=42)#
Bases:
BaseEstimator,TransformerMixinAlign participant-specific PCA trajectories to a training template.
fitlearns a shared PCA template and participant mappings from the training fold.transformreuses stored mappings for known participants and estimates a label-free PCA/rotation from the transform batch for unseen participants. The latter is explicit transductive adaptation.Two options turn this into its own controls.
rotate=Falsekeeps the per-participant PCA but drops the Procrustes step, which isolates whether a participant-specific basis alone transfers (it does not) or whether the rotation is what does the work.adaptation="calibration"estimates an unseen participant’s PCA and rotation from one random half of their trials and applies it to the other half (and vice versa), so no trial ever contributes to its own mapping — a non-transductive variant that still returns every row.use_shared_basis=Trueis a third control: every participant is projected through the pooled training template directly (the sameshared_pca_fitfit()already uses as the rotation target), ignoring per-participant identity androtateentirely. This is the continuous, temporally-stable analogue of a single spatial filter shared by everyone — as opposed tococo_pipe.decoding’sReducerConfigPCA, which is fold-local but refit independently at every sliding-window latency.augmentconcatenates extra channels derived from each component’s own trajectory onto the raw scores, still computed fold-locally insidetransformso nothing about a held-out participant leaks into them:"envelope"(Hilbert amplitude),"velocity"(index-based first derivative — only rank-invariant reparametrizations of time reach the classifier, and any downstreamStandardScalerabsorbs a fixed sampling-rate scale factor, so the true sampling interval isn’t needed), and"scalar"(each component’s peak amplitude, index-based peak latency, mean power, and signed AUC over the whole supplied window, broadcast as constant channels across time). Requestingnof these turnsn_componentsraw channels inton_components * (1 + n).augment_only=Truedrops the raw per-componentscoreschannels entirely, leaving only whateveraugmentrequests (e.g. just the ~10"trajectory"geometry channels, independent ofn_components- for analyses where the raw PC scores aren’t wanted as features at all, only derived channels computed from the embedding they define).trajectory_metricsrestricts"trajectory"to a chosen subset of its ~10 metrics (by name, e.g.("speed",)) instead of computing and returning all of them -None(default) means all.- Parameters:
- fold_local = True#
- fit(X, y=None, groups=None)#
Fit the training-fold template and participant mappings.
- transform(X, groups=None)#
Project and align known or unseen participant trajectories.
- fit_transform(X, y=None, groups=None, **fit_params)#
Fit and align one training fold.
- get_metadata_routing()#
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequestencapsulating routing information.- Return type:
MetadataRequest
- get_params(deep=True)#
Get parameters for this estimator.
- set_fit_request(*, groups='$UNCHANGED$')#
Configure whether metadata should be requested to be passed to the
fitmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
groups (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
groupsparameter infit.self (TemporalProcrustesAlignment)
- Returns:
self – The updated object.
- Return type:
- set_output(*, transform=None)#
Set output container.
Refer to the user guide for more details and 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:
self – Estimator instance.
- Return type:
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:
**params (dict) – Estimator parameters.
- Returns:
self – Estimator instance.
- Return type:
estimator instance
- set_transform_request(*, groups='$UNCHANGED$')#
Configure whether metadata should be requested to be passed to the
transformmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed totransformif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it totransform.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
groups (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
groupsparameter intransform.self (TemporalProcrustesAlignment)
- Returns:
self – The updated object.
- Return type: