PreprocessedDataset#
- class pypillometry.datasets.PreprocessedDataset(dataset, cache=None, overwrite=False, n_jobs=1, on_error='raise', **kwargs)[source]#
Bases:
objectA dataset with all recordings preprocessed.
Made by
Dataset.preprocessed; it has the same methods as the dataset, butload()gives preprocessed recordings and the recordings excluded while preprocessing are left out everywhere (subjects(),recordings(), the tables, …) and listed inexcluded().- 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
citeWrite the preprocessed recordings as pypillometry files.
Download (and convert) the recordings; see
Dataset.download().The preprocessed dataset without some subjects or recordings.
The excluded recordings, with the reason; see
Dataset.excluded().A file of the dataset; see
Dataset.fetch().The files of the dataset; see
Dataset.files().A summary; see
Dataset.info()(pluscacheandkwargs).Load many preprocessed recordings, one at a time.
Load one preprocessed recording.
Load many preprocessed recordings; see
Dataset.load_all().The participants; see
Dataset.participants().Plot a preprocessed recording with the raw data.
What the preprocessing stored in
d.info["preprocess"], for all recordings (without loading them).preprocessedQuality reports of the preprocessed recordings.
The (not excluded) recordings; see
Dataset.recordings().Segments of all preprocessed recordings, stacked into one object.
The preprocessed dataset with only some subjects and/or tasks.
The subjects with a (not excluded) recording; see
Dataset.subjects().A table of the study; see
Dataset.table().The behaviour of each trial; see
Dataset.trials().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.
- download(subjects=None, tasks=None, tables=True, n_jobs=4, overwrite=False)[source]#
Download (and convert) the recordings; see
Dataset.download().
- exclude(items, reason='')[source]#
The preprocessed dataset without some subjects or recordings.
See
Dataset.exclude(); nothing is preprocessed again.- Return type:
- excluded()[source]#
The excluded recordings, with the reason; see
Dataset.excluded().- Return type:
- fetch(path, progressbar=None)[source]#
A file of the dataset; see
Dataset.fetch().- Return type:
- files(pattern=None)[source]#
The files of the dataset; see
Dataset.files().- Return type:
- iterload(subjects=None, tasks=None, on_error='raise')[source]#
Load many preprocessed recordings, one at a time.
See
Dataset.iterload().
- 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()).
- load_all(subjects=None, tasks=None, on_error='raise')[source]#
Load many preprocessed recordings; see
Dataset.load_all().
- participants()[source]#
The participants; see
Dataset.participants().- Return type:
- 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 (legendraw_<eye>), in the plots of the variables that the raw recording has too, on the clock of the preprocessed recording (as inview()).- Parameters:
subject (str or int) – subject ID (see
subjects())task (
Optional[str]) – task (seetasks); 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 datavariables (str or list, optional) – which variables and eyes (see
d.plot.plot_timeseries); default alleyes (str or list, optional) – which variables and eyes (see
d.plot.plot_timeseries); default all**kwargs – passed on to
d.plot.plot_timeseriesof 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:
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 inpreprocess_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:
- 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.
- Return type:
- recordings(subjects=None, tasks=None)[source]#
The (not excluded) recordings; see
Dataset.recordings().With a cache, the column
preprocessedholds the preprocessed file of each recording.- Return type:
- segments(event=None, window=None, **kwargs)[source]#
Segments of all preprocessed recordings, stacked into one object.
See
Dataset.segments().- Return type:
- 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:
- subjects(task=None)[source]#
The subjects with a (not excluded) recording; see
Dataset.subjects().
- table(name)[source]#
A table of the study; see
Dataset.table().- Return type:
- trials(task=None, subject=None)[source]#
The behaviour of each trial; see
Dataset.trials().- Return type:
- 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, labelledraw), on the clock of the preprocessed recording (also afterreset_time()andremove_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 (seetasks); 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:
- 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).