coco_pipe.io.load_embeddings#
- coco_pipe.io.load_embeddings(source, *, representation='epoch', conditions=None, subjects=None, subject_metadata_df=None, subject_key=None)#
Load embedding files into a DataContainer.
The files are read one at a time into one float32 array, so memory holds the result and a block of 1,024 windows of one file. Only the windows of
conditionsandsubjectsare read.- Parameters:
source (path-like or BIDSPath, or a sequence of them) – Embedding files of one model, label and view: one file holding every recording, or recordings’ files (see
find_embeddings()).representation ({"epoch", "recording"}) –
"epoch": one row per window."recording": one row per recording and condition, the mean of its windows.conditions (str or sequence of str, optional) – The conditions to load; every condition when omitted.
subjects (str or sequence of str, optional) – The subjects to load, labels without
sub-; every subject when omitted. A subject no file holds is not an error.subject_metadata_df (DataFrame, optional) – Subject-level metadata to attach, in addition to
participants.tsv.subject_key (str, optional) – The column of
subject_metadata_dfholding the subject ID. It matches rows to subjects and is not attached itself.
- Returns:
Xis float32, with the file’s axes andwindowrenamedobs:("obs", "feature")for window and cov files, andchannel,time_patchor the model’s token axes beforefeaturefor the others.idsisobs. Alongobsare the file’s window coordinates (recording_id,subject,session,task,run,condition,epoch,start,stop), each recording’sbad_channelsand each subject’s metadata: the columns ofparticipants.tsv, found in the files’ dataset or, followingSourceDatasets, in a dataset it comes from (seeload_participants_tsv()), and those ofsubject_metadata_df.sessionandrunare dropped when no recording has one. A channel axis keeps itschannelnames.metaholdsmodel_key,config,config_hash,description(the label),view,representation,files,recordings(each loaded recording’s row of the files’ recording table) and, for tokens,token_sourceandtoken_feature_axis.- Return type:
- Raises:
ValueError – If
sourcenames no file or a file that is not an embedding file; if the files differ in model, settings (config_hash), label, view, axes, shape, token layout or channel names; if a condition is in no file, no window is selected, an observation appears twice or a value is not finite; ifsubject_metadata_dfcomes withoutsubject_key, or a subject metadata column is named like a coordinate the loader sets.
Notes
The recording level is the mean of the window vectors as stored, which are L2-normalised when the extractor normalises them; its
obsis<recording_id>_cond-<condition>andepoch_countholds the number of windows. Channel axes that hold the same channels in another order are put in the first file’s order.