coco_pipe.io.write_transformed_embeddings#
- coco_pipe.io.write_transformed_embeddings(source, embeddings, root, *, transform, fitted_on=None, view=None, token_dtype='float32')#
Write transformed embeddings as one file holding every recording.
sourceis whatload_embeddings()returned for one label and view, one row per window, andembeddingsits transform, row for row: of the same shape for a transform that keeps it (EuclideanAlign,LeaceEraser), or(window, feature)withview="cov"forRiemannAlign’s tangent vectors. The file keeps the windows, the recordings and the channels ofsource; its settings are those ofsourcewithTransformadded, so itsconfig_hashdiffers, and withoutNormalizeEmbeddings, which says how the source’s vectors were made, not the transformed ones. Its label is that ofsourcefollowed by the transform’s (seeembedding_label()), e.g.baseRandom3EaCoralCh. It is named byembedding_path(), with the task of the windows when they share one, and written to a temporary name, then moved into place.- Parameters:
source (DataContainer) – Embeddings read by
load_embeddings(), one row per window.embeddings (np.ndarray) – The transformed embeddings, one row per row of
source.root (path-like) – The derivative dataset, e.g.
derivatives/coco-pipe-cbramod.transform (SubjectAlignment) – The fitted transform that made
embeddings, e.g. anEuclideanAlign. Itsname,labeland parameters are recorded as the settingTransform, with its fittedrank_andn_subjects_when it has them (LEACE).fitted_on (str, optional) – What the transform was fitted on, recorded in
Transform, e.g."every window of base, both conditions".view (str, optional) – The view of the file; that of
sourceby default.token_dtype ({"float32", "float16"}) – The dtype of a token file; other views are float32.
- Returns:
The file written.
- Return type:
BIDSPath
- Raises:
ValueError – If
sourceis not one row per window of an embedding file, or is already transformed, ifembeddingsdoes not have one row per window, has axes its view cannot have or holds non-finite values, iftransformworks per channel (channel_axis) along an axis ofsourcethat is notchannel, or if the label is not a BIDS label.