sleepless.data.loader#

Data loading code.

Functions

load_annotation_raw(path)

Loads annotation sample from an EDF or TXT file.

load_edf_raw(path, infer_types, preload[, ...])

Loads PSG signals sample from an EDF file.

make_delayed(sample, loader[, key, metadata])

Returns a delayed-loading Sample object.

Classes

Loader(transform_parameters, csv_subset, ...)

class sleepless.data.loader.Loader(transform_parameters, csv_subset, protocol_name)[source]#

Bases: ABC

sleepless.data.loader.load_edf_raw(path, infer_types, preload, misc=None, exclude=[])[source]#

Loads PSG signals sample from an EDF file.

Parameters:
  • path (str) – The full path to the EDF file to be loaded

  • infer_types (bool) – If True mne will try to to infer the type of channel (e.g. eeg) from their name

  • preload (bool) – If True data will be loaded in memory

  • misc (Optional[list[str]]) – Name of misc channels

  • exclude (Optional[list[str]]) – A list of channel to not load

Return type:

RawEDF

Returns:

A mne raw object

sleepless.data.loader.load_annotation_raw(path)[source]#

Loads annotation sample from an EDF or TXT file.

Parameters:

path (str) – The full path to the EDF or TXT file to be loaded

Return type:

Annotations

Returns:

A mne object for annotating segments of raw data

sleepless.data.loader.make_delayed(sample, loader, key=None, metadata={})[source]#

Returns a delayed-loading Sample object.

Parameters:
  • sample (dict[str, str]) – A dictionary that maps field names to sample data values (e.g. paths)

  • loader (Callable) – A function that inputs sample dictionaries and returns the loaded data.

  • key (Optional[str]) – A unique key identifier for this sample. If not provided, assumes sample is a dictionary with a data entry and uses its path as key.

Return type:

DelayedSample

Returns:

In which key is as provided and data can be accessed to trigger sample loading.