coco_pipe.transforms.temporal_alignment#
Group-aware alignment of temporal trajectories.
Classes#
Align participant-specific PCA trajectories to a training template. |
Module Contents#
- class coco_pipe.transforms.temporal_alignment.TemporalProcrustesAlignment(n_components=30, *, adaptation='transductive', rotate=True, use_shared_basis=False, augment=(), augment_only=False, trajectory_metrics=None, random_state=42)#
Bases:
sklearn.base.BaseEstimator,sklearn.base.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#
- n_components = 30#
- adaptation = 'transductive'#
- rotate = True#
- augment = ()#
- augment_only = False#
- trajectory_metrics = None#
- random_state = 42#
- fit(X, y=None, groups=None)#
Fit the training-fold template and participant mappings.
- Parameters:
X (Any)
y (Any)
groups (Any)
- transform(X, groups=None)#
Project and align known or unseen participant trajectories.
- Parameters:
X (Any)
groups (Any)
- Return type:
- fit_transform(X, y=None, groups=None, **fit_params)#
Fit and align one training fold.
- Parameters:
X (Any)
y (Any)
groups (Any)
fit_params (Any)
- Return type: