Class: ExperimentHandler

data.ExperimentHandler(options)

new ExperimentHandler(options)

An ExperimentHandler keeps track of multiple loops and handlers. It is particularly useful for generating a single data file from an experiment with many different loops (e.g. interleaved staircases or loops within loops.

Parameters:
Name Type Description
options Object
Properties
Name Type Description
psychoJS module:core.PsychoJS the PsychoJS instance
name string name of the experiment
extraInfo Object additional information, such as session name, participant name, etc.
Source:

Extends

  • PsychObject

Methods

(protected) _getLoopAttributes(loop)

Get the attribute names and values for the current trial of a given loop.

Only info relating to the trial execution are returned.

Parameters:
Name Type Description
loop Object the loop
Source:

addData(key, value)

Add the key/value pair.

Multiple key/value pairs can be added to any given entry of the data file. There are considered part of the same entry until a call to nextEntry is made.

Parameters:
Name Type Description
key Object the key
value Object the value
Source:

addLoop(loop)

Add a loop.

The loop might be a TrialHandler, for instance.

Data from this loop will be included in the resulting data files.

Parameters:
Name Type Description
loop Object the loop, e.g. an instance of TrialHandler or StairHandler
Source:

experimentEnded()

Getter for experimentEnded.
Source:

experimentEnded()

Setter for experimentEnded.
Source:

isEntryEmpty() → {boolean}

Whether or not the current entry (i.e. trial data) is empty.

Note: this is mostly useful at the end of an experiment, in order to ensure that the last entry is saved.

Source:
To Do:
  • This really should be renamed: IsCurrentEntryNotEmpty
Returns:
whether or not the current entry is empty
Type
boolean

nextEntry(snapshots)

Inform this ExperimentHandler that the current trial has ended. Further calls to addData will be associated with the next trial.
Parameters:
Name Type Description
snapshots Object | Array.<Object> | undefined array of loop snapshots
Source:

removeLoop(loop)

Remove the given loop from the list of unfinished loops, e.g. when it has completed.
Parameters:
Name Type Description
loop Object the loop, e.g. an instance of TrialHandler or StairHandler
Source:

save(options)

Save the results of the experiment.
  • For an experiment running locally, the results are offered for immediate download.
  • For an experiment running on the server, the results are uploaded to the server.

Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Default Description
attributes Array.<Object> <optional>
the attributes to be saved
sync boolean <optional>
false whether or not to communicate with the server in a synchronous manner
tag string <optional>
'' an optional tag to add to the filename to which the data is saved (for CSV and XLSX saving options)
clear boolean <optional>
false whether or not to clear all experiment results immediately after they are saved (this is useful when saving data in separate chunks, throughout an experiment)
Source: