coco_pipe.io.load#

High-level data loading from a dataset configuration.

Author: Hamza Abdelhedi <hamza.abdelhedi@umontreal.ca>

Functions#

load_data(config, *[, subject_metadata_df, subject_key])

Load a dataset described by a configuration into a DataContainer.

Module Contents#

coco_pipe.io.load.load_data(config, *, subject_metadata_df=None, subject_key=None)#

Load a dataset described by a configuration into a DataContainer.

The configuration says what to load and how: TabularConfig for a feature table, BIDSConfig for a BIDS M/EEG dataset and EmbeddingConfig for an embedding file (read by load_embeddings(), its rows then averaged by aggregate_by when given), each validated when it is built. Only what a configuration cannot hold, tables, is passed here.

Parameters:
  • config (DatasetConfig or {Tabular,BIDS,Embedding}Config) – The dataset to load.

  • subject_metadata_df (DataFrame, optional) – BIDS and embeddings: subject-level metadata attached to each observation, in addition to participants.tsv.

  • subject_key (str, optional) – BIDS and embeddings: the column of subject_metadata_df holding the subject ID.

Return type:

DataContainer

Raises:

TypeError – If config is not a dataset configuration, e.g. a path or a dict.

Examples

>>> from coco_pipe.io import BIDSConfig, TabularConfig, load_data
>>> table = load_data(TabularConfig(path="features.csv", target_col="y"))
>>> epochs = load_data(
...     BIDSConfig(path="/data/bids", task="rest", window_length=2.0)
... )