PreprocessedDataset#

class pypillometry.datasets.PreprocessedDataset(dataset, cache=None, overwrite=False, n_jobs=1, on_error='raise', **kwargs)[source]#

Bases: object

A dataset with all recordings preprocessed.

Made by Dataset.preprocessed; it has the same methods as the dataset, but load() gives preprocessed recordings and the recordings excluded while preprocessing are left out everywhere (subjects(), recordings(), the tables, …) and listed in excluded().

Attributes:
rawDataset

the dataset (raw recordings) with the same subjects, tasks and exclusions

cachestr or None

the folder with the preprocessed recordings

kwargsdict

the arguments passed on to Dataset.preprocess()

What the preprocessing stores in ``d.info[“preprocess”]`` (a dict, e.g.
tuned parameters) is collected for all recordings: see
:meth:`preprocess_info`.

Methods

cite

convert

Write the preprocessed recordings as pypillometry files.

download

Download (and convert) the recordings; see Dataset.download().

exclude

The preprocessed dataset without some subjects or recordings.

excluded

The excluded recordings, with the reason; see Dataset.excluded().

fetch

A file of the dataset; see Dataset.fetch().

files

The files of the dataset; see Dataset.files().

info

A summary; see Dataset.info() (plus cache and kwargs).

iterload

Load many preprocessed recordings, one at a time.

load

Load one preprocessed recording.

load_all

Load many preprocessed recordings; see Dataset.load_all().

participants

The participants; see Dataset.participants().

plot

Plot a preprocessed recording with the raw data.

preprocess_info

What the preprocessing stored in d.info["preprocess"], for all recordings (without loading them).

preprocessed

quality_report

Quality reports of the preprocessed recordings.

recordings

The (not excluded) recordings; see Dataset.recordings().

segments

Segments of all preprocessed recordings, stacked into one object.

select

The preprocessed dataset with only some subjects and/or tasks.

subjects

The subjects with a (not excluded) recording; see Dataset.subjects().

table

A table of the study; see Dataset.table().

trials

The behaviour of each trial; see Dataset.trials().

view

Show a preprocessed recording with the raw data in the viewer.

Details

convert(out_dir, subjects=None, tasks=None, overwrite=False, on_error='raise')[source]#

Write the preprocessed recordings as pypillometry files.

See Dataset.convert(); with a cache folder, the files are already there.

Return type:

list[str]

download(subjects=None, tasks=None, tables=True, n_jobs=4, overwrite=False)[source]#

Download (and convert) the recordings; see Dataset.download().

Return type:

list[str]

exclude(items, reason='')[source]#

The preprocessed dataset without some subjects or recordings.

See Dataset.exclude(); nothing is preprocessed again.

Return type:

Self

excluded()[source]#

The excluded recordings, with the reason; see Dataset.excluded().

Return type:

DataFrame

fetch(path, progressbar=None)[source]#

A file of the dataset; see Dataset.fetch().

Return type:

str

files(pattern=None)[source]#

The files of the dataset; see Dataset.files().

Return type:

DataFrame

info()[source]#

A summary; see Dataset.info() (plus cache and kwargs).

Return type:

dict[str, Any]

iterload(subjects=None, tasks=None, on_error='raise')[source]#

Load many preprocessed recordings, one at a time.

See Dataset.iterload().

Return type:

Iterator[tuple[str, str | None, EyeData]]

load(subject, task=None)[source]#

Load one preprocessed recording.

From the cache folder if it is there, else the raw recording is loaded and preprocessed (see Dataset.preprocess()).

Parameters:
Return type:

EyeData

Returns:

d.info["preprocess_args"] holds the arguments of the preprocessing

load_all(subjects=None, tasks=None, on_error='raise')[source]#

Load many preprocessed recordings; see Dataset.load_all().

Return type:

dict[str | tuple[str, str | None], EyeData]

participants()[source]#

The participants; see Dataset.participants().

Return type:

DataFrame

plot(subject, task=None, excluded=False, variables=None, eyes=None, **kwargs)[source]#

Plot a preprocessed recording with the raw data.

The preprocessed recording is plotted with d.plot.plot_timeseries, the raw data in gray below it (legend raw_<eye>), in the plots of the variables that the raw recording has too, on the clock of the preprocessed recording (as in view()).

Parameters:
  • subject (str or int) – subject ID (see subjects())

  • task (Optional[str]) – task (see tasks); can be left out if the dataset has only one task (or none)

  • excluded (bool) – also plot an excluded recording (else an error): preprocessed as with the other recordings; if the preprocessing excludes it (or fails), only the raw data

  • variables (str or list, optional) – which variables and eyes (see d.plot.plot_timeseries); default all

  • eyes (str or list, optional) – which variables and eyes (see d.plot.plot_timeseries); default all

  • **kwargs – passed on to d.plot.plot_timeseries of the preprocessed recording (e.g., plot_range, units, show_layers); plot_range and units also for the raw data. Default title: the recording (and why it is excluded)

Return type:

Figure

Examples

>>> dsp = ds.preprocessed(cache="prep")
>>> fig = dsp.plot("002", variables="pupil", plot_range=(0, 60))
preprocess_info()[source]#

What the preprocessing stored in d.info["preprocess"], for all recordings (without loading them).

Dataset.preprocess() can keep parameters there (a dict, e.g. tuned parameters or a quality value). They are collected while preprocessing and, with a cache, kept in preprocess_info.json. Values that are not parameters (e.g. arrays) are stored as a short text; the recordings keep them as they are. Recordings excluded by the preprocessing have no info.

Return type:

DataFrame

Returns:

one row per recording (index: subject, and task if the dataset has tasks), one column per key; nested dicts give columns like "blink.winsize"

quality_report(subjects=None, tasks=None, on_error='raise', **kwargs)[source]#

Quality reports of the preprocessed recordings.

See Dataset.quality_report().

Return type:

QualityReports

recordings(subjects=None, tasks=None)[source]#

The (not excluded) recordings; see Dataset.recordings().

With a cache, the column preprocessed holds the preprocessed file of each recording.

Return type:

DataFrame

segments(event=None, window=None, **kwargs)[source]#

Segments of all preprocessed recordings, stacked into one object.

See Dataset.segments().

Return type:

SegmentedEyeData

select(subjects=None, tasks=None)[source]#

The preprocessed dataset with only some subjects and/or tasks.

See Dataset.select(); nothing is preprocessed again.

Return type:

Self

subjects(task=None)[source]#

The subjects with a (not excluded) recording; see Dataset.subjects().

Return type:

list[str]

table(name)[source]#

A table of the study; see Dataset.table().

Return type:

DataFrame

trials(task=None, subject=None)[source]#

The behaviour of each trial; see Dataset.trials().

Return type:

DataFrame

view(subject, task=None, excluded=False, **kwargs)[source]#

Show a preprocessed recording with the raw data in the viewer.

Opens pypillometry.view() with the preprocessed recording and the raw recording as an overlay (in gray behind the data, labelled raw), on the clock of the preprocessed recording (also after reset_time() and remove_intervals()). If the time axes differ (e.g., downsampled or cropped while preprocessing), the raw data are interpolated onto that of the preprocessed recording.

Parameters:
  • subject (str or int) – subject ID (see subjects())

  • task (Optional[str]) – task (see tasks); can be left out if the dataset has only one task (or none)

  • excluded (bool) – also show an excluded recording (else an error): preprocessed as with the other recordings; if the preprocessing excludes it (or fails), only the raw data

  • **kwargs – passed on to pypillometry.view() (e.g., variables, eyes); more overlays in overlay are added to the raw data, colors can change the color of the raw data (key "raw")

Return type:

Optional[dict[str, Intervals]]

Returns:

the selections made in the viewer (see pypillometry.view())

Examples

>>> dsp = ds.preprocessed(cache="prep")
>>> dsp.view("002", variables="pupil")
>>> dsp.view(10, excluded=True)
property tasks: dict[str, str]#

task -> description (see Dataset.tasks).