Opticka 2.16.1
Opticka is an experiment manager for behavioral research.
|
The main experiment manager. More...
The main experiment manager.
RUNEXPERIMENT accepts a variable sequence « taskSequence », stimulus set « metaStimulus » and for behavioural tasks a « stateMachine » state machine file, and runs the stimuli based on the task objects passed. This class uses the fundamental configuration of the screen (calibration, size etc. via « screenManager »), and manages communication to a DAQ systems using digital I/O and communication over a TCP/UDP client⇄server socket (via «dataConnection»). It also interfaces with hardware like eyetrackers
There are 2 main experiment types: 1) MOC (method of constants) tasks – uses stimuli and task objects directly to run standard randomised variable tasks. See optickatest.m for an example. Does not use the «stateMachine». 2) Behavioural tasks that use state machines for control logic. These tasks still use stimuli and task objects to provide stimuli and variable lists, but use a state machine to control the task structure.
Stimuli should be «metaStimulus» class, so for example:
will run a minimal experiment showing a 1c/d circularly masked grating.
Copyright ©2014-2022 Ian Max Andolina — released: LGPL3, see LICENCE.md
Public Member Functions | |
function | runExperiment (in varargin) |
function | runMOC (in me, in tS) |
function | runTask (in me) |
function | runTests (in me, in test) |
function | initialise (in me, in config) |
function | checkTaskEnded (in me) |
function | checkScreenError (in me) |
function | showTimingLog (in me, in h) |
function | updateFixationTarget (in me, in useStimuli, in varargin) |
function | updateExclusionZones (in me, in useStimuli, in radius) |
function | updateConditionalFixationTarget (in me, in stimulus, in variable, in value, in varargin) |
function | keyOverride (in me) |
when running allow keyboard override, so we can edit/debug things within the loop! | |
function set | verbose (in me, in value) |
function set | stimuli (in me, in in) |
function | randomiseTrainingList (in me) |
function | setStrobeValue (in me, in value) |
function | doStrobe (in me, in value) |
function | doSyncTime (in me) |
function | needEyeSample (in me, in value) |
set needSample if eyeManager getSample on current flip? | |
function | needFlip (in me, in value, in trackervalue) |
function | getTaskIndex (in me, in index) |
function | logRun (in me, in tag) |
print run info to command window | |
function | updateTask (in me, in result) |
function | updateStaircaseAfterState (in me, in result, in state) |
function | updateNextState (in me, in type) |
function | updateVariables (in me, in index, in override, in update) |
function | deleteRunLog (in me) |
deletes the run logs | |
function | refreshScreen (in me) |
refresh the screen values stored in the object | |
function | needFlipTracker (in me, in value) |
function | enableFlip (in me) |
function | disableFlip (in me) |
function | noop (in me) |
function | configureTouchScreen (in me, in s) |
function | configureEyetracker (in me, in s) |
Public Member Functions inherited from optickaCore | |
function | optickaCore (in varargin) |
Class constructor. | |
function get | fullName (in me) |
function | getALF (in me, in subject, in sessionPrefix, in lab, in create) |
function | findAttributes (in me, in attrName, in attrValue) |
function | findAttributesandType (in me, in attrName, in attrValue, in type) |
find properties of object with specific attributes, for example all properties whose GetAcccess attribute is public and type is logical. | |
function | findPropertyDefault (in me, in propName) |
function | clone (in me) |
Use this syntax to make a deep copy of the object, i.e. OBJ_OUT has the same field values, but will not behave as a handle-copy of me anymore. | |
function | checkSuperclasses (in List) |
function | editProperties (in me, in properties) |
method to modify a set of properties | |
function | setProp (in me, in property, in value) |
method to fast change a particular value. This is useful for use in anonymous functions, like in the state machine. | |
function | initialiseGlobals (in me, in doReset, in doOpen) |
function | initialiseSaveFile (in me) |
Initialise Save prefix. | |
function | checkPaths (in me) |
checks the paths are valid | |
Static Public Member Functions | |
static function | plotEyeLogs (in tS) |
manage key commands during task loop | |
static function | loadobj (in in) |
loadobj To be backwards compatible to older saved protocols, we have to parse structures / objects specifically during object load | |
static function | rebuild () |
Static Public Member Functions inherited from optickaCore | |
static function | makeArgs (in args) |
Converts cell args to structure array. | |
static function | addDefaults (in args, in defs) |
add default options to arg input | |
static function | hasKey (in in, in key) |
check if a struct / object has a propery / field | |
static function | getKeys (in device) |
PTB Get key presses, stops key bouncing. | |
Public Attributes | |
Property | sessionData |
Property | stimuli |
a metaStimulus class instance holding our stimulus objects | |
Property | task |
a taskSequence class instance determining our stimulus variables | |
Property | screen |
a screenManager class instance managing the PTB Screen | |
Property | stateInfoFile |
filename for a stateMachine state info file | |
Property | userFunctionsFile |
user functions file that can be passed to the state machine | |
Property | strobe |
Property | reward |
what reward device to use | |
Property | eyetracker |
which eyetracker to use | |
Property | touch |
Property | control |
Property | keyboardDevice |
Property | logFrames |
log all frame times? | |
Property | debug |
enable debugging? (poorer temporal fidelity) | |
Property | verbose |
verbose logging to command window? | |
Property | screenSettings |
structure for screenManager on initialisation and info from opticka | |
Property | uiCommand |
this lets the opticka UI leave commands to runExperiment | |
Property | isRunning |
return if runExperiment is running (true) or not (false) | |
Property | benchmark |
flip as fast as possible? | |
Property | drawFixation |
draw simple fixation cross during trial for MOC tasks? | |
Property | visualDebug |
shows the info text and position grid during stimulus presentation | |
Property | stimList |
used to select single stimulus in training mode | |
Property | thisStim |
which stimulus is selected? | |
Property | tS |
tS is the runtime settings structure, saved here as a backup | |
Property | askForComments |
ask for comments? | |
Property | photoDiode |
Property | diaryMode |
turn diary on for runTask, saved to the same folder as the data | |
Property | optickaVersion |
opticka version, passed on first use by opticka | |
Property | logStateTimers |
do we record times for every function run by state machine? | |
Property | comments |
do we ask for comments for runMOC | |
Property | stimulus |
our old stimulus structure used to be a simple cell, now we use metaStimulus | |
Property | audioDevice |
audio device | |
Property | subjectName |
DEPRECATED. | |
Property | researcherName |
DEPRECATED. | |
Property | lastXPosition |
keep track of several task values during runTask() | |
Property | lastYPosition |
Property | lastXExclusion |
Property | lastYExclusion |
Property | lastSize |
Property | lastIndex |
Public Attributes inherited from optickaCore | |
Property | name |
object name | |
Property | comment |
comment | |
Property | verbose |
verbose logging, subclasses must assign this. This is normally logical true/false | |
Property | dateStamp |
clock() dateStamp set on construction | |
Property | uuid |
universal ID | |
Property | paths |
storage of various paths | |
Property | fullName |
The fullName is the object name combined with its uuid and class name. | |
Additional Inherited Members | |
Protected Member Functions inherited from optickaCore | |
function | parseArgs (in me, in args, in allowedProperties) |
Sets properties from a structure or normal arguments pairs, ignores invalid or non-allowed properties. | |
function | addArgs (in me, in args) |
function | setPaths (in me) |
Sets properties from a structure or normal arguments pairs, ignores invalid or non-allowed properties. | |
function | getFonts (in me) |
set paths for object | |
function | toStructure (in me) |
Converts properties to a structure. | |
function | getType (in me, in in) |
function | logOutput (in me, in in, in message, in override) |
Give a metaproperty return the likely property class. | |
function | salutation (in me, in varargin) |
Prints messages dependent on verbosity. | |
Protected Attributes inherited from optickaCore | |
Property | cloning |
are we cloning this from another object | |
Property | mversion |
Matlab version number, this is transient so it is not saved. | |
Property | sansFont |
sans font | |
Property | monoFont |
monoFont | |
Property | className |
class name | |
Property | savePrefix |
save prefix generated from clock time | |
Property | fullName_ |
cached full name | |
runExperiment::runExperiment | ( | in | varargin | ) |
runExperiment CONSTRUCTOR
varargin | can be passed as a structure or name,arg pairs |
runExperiment::checkScreenError | ( | in | me | ) |
check if screenManager is in a good state
runExperiment::checkTaskEnded | ( | in | me | ) |
Check if stateMachine has finished, set me.stopTask true
runExperiment::configureEyetracker | ( | in | me, |
in | s | ||
) |
Configures (calibration etc.) the eyetracker.
s | screen object |
function runExperiment::configureTouchScreen | ( | in | me, |
in | s | ||
) |
runExperiment::deleteRunLog | ( | in | me | ) |
deletes the run logs
function runExperiment::disableFlip | ( | in | me | ) |
runExperiment::doStrobe | ( | in | me, |
in | value | ||
) |
set I/O strobe to trigger on NEXT FLIP
value | true or false |
runExperiment::doSyncTime | ( | in | me | ) |
send SYNCTIME message to eyetracker after flip
runExperiment::enableFlip | ( | in | me | ) |
Enable screen flipping for main [and optionally tracker screen]
value | - true/false for subject screen |
trackervalue | - 0=disable flip, 1=enable + don't clear, 2= enable + clear, 3=force, 4=force first frame then switch to 1 |
runExperiment::getTaskIndex | ( | in | me, |
in | index | ||
) |
This method gets the unique value of the current trial from taskSequence. This is useful for sending to the eyetracker or I/O devices to label which variable value is being shown.
the | index to a particular trial |
runExperiment::initialise | ( | in | me, |
in | config | ||
) |
Prepares run for the local machine
config | [nostimuli | noscreen | notask] allows excluding screen / task initialisation |
runExperiment::keyOverride | ( | in | me | ) |
when running allow keyboard override, so we can edit/debug things within the loop!
|
static |
loadobj To be backwards compatible to older saved protocols, we have to parse structures / objects specifically during object load
in | input object/structure |
runExperiment::logRun | ( | in | me, |
in | tag | ||
) |
print run info to command window
tag | what name to give this log printout |
runExperiment::needEyeSample | ( | in | me, |
in | value | ||
) |
set needSample if eyeManager getSample on current flip?
value |
disableFlip deprecated for runExperiment::needFlip | ( | in | me, |
in | value, | ||
in | trackervalue | ||
) |
Enable screen flip
Disable screen flip
runExperiment::needFlipTracker | ( | in | me, |
in | value | ||
) |
Enables/disable the flip for the tracker display window
trackervalue | - 0=disable flip, 1=enable + don't clear, 2= enable + clear, 3=force, 4=force first frame then switch to 1 |
runExperiment::noop | ( | in | me | ) |
no operation, tests method call overhead
|
static |
manage key commands during task loop
args | input structure |
runExperiment::randomiseTrainingList | ( | in | me | ) |
For single stimulus presentation, randomise stimulus choice
|
static |
runExperiment::refreshScreen | ( | in | me | ) |
refresh the screen values stored in the object
runExperiment::runMOC | ( | in | me, |
in | tS | ||
) |
runMOC uses built-in loop for experiment control and runs a methods-of-constants (MOC) experiment with the settings passed to it (stimuli,task and screen). This is different to the runTask method as it doesn't use a stateMachine for experimental logic, just a minimal deterministic trial+block loop.
me | required class object |
tS | structure with some options to pass |
runExperiment::runTask | ( | in | me | ) |
runTask runs a state machine (behaviourally) driven task.
Uses a StateInfo.m file to control the behavioural paradigm. The state machine controls the logic of the experiment, and this method manages the display loop.
runExperiment::runTests | ( | in | me, |
in | test | ||
) |
Tests the hardware interfaces
test | - marker | reward | audio | eyetracker |
runExperiment::setStrobeValue | ( | in | me, |
in | value | ||
) |
Set strobe value
value | the value to set the I/O system |
runExperiment::showTimingLog | ( | in | me, |
in | h | ||
) |
Prints out the frame time plots from a run
function set runExperiment::stimuli | ( | in | me, |
in | in | ||
) |
runExperiment::updateConditionalFixationTarget | ( | in | me, |
in | stimulus, | ||
in | variable, | ||
in | value, | ||
in | varargin | ||
) |
Checks the variable value of a stimulus (e.g. its angle) and then sets a fixation target based on that value, so you can use multiple test stimuli and set the target to one of them in a forced choice paradigm that matches the variable value
stimulus | which stimulus or stimuli to check |
variable | which variable to check |
value | which value to check for |
varargin | additional parameters to set the fixation window |
runExperiment::updateExclusionZones | ( | in | me, |
in | useStimuli, | ||
in | radius | ||
) |
Updates eyetracker with current stimuli tagged for exclusion using metaStimulus.exclusionChoice
useStimuli | use the metaStimulus parameters |
radius | of the exclusion zone |
runExperiment::updateFixationTarget | ( | in | me, |
in | useStimuli, | ||
in | varargin | ||
) |
Sometimes you want the fixation to follow the position of a particular stimulus. We can 'tag' the stimulus using metaStimulus.fixationChoice and then use this method to get the current position and update the eyetracker fixation window[s] to match the stimuli we tagged.
useStimuli | do we use the current stimuli positions or the last known positions that are stored in me.stimuli.last[X|Y]Position. If this is a number we force it to the specific stimuli. |
varargin | the rest of the parameters normally passed to eyeTracker.updateFixationValues: inittime,fixtime,radius,strict |
runExperiment::updateNextState | ( | in | me, |
in | type | ||
) |
taskSequence can generate a trial factor, and we can set these to the name of a state in the stateMachine. This means we can choose a state based on the trial factor in taskSequence. This sets stateMacine.tempNextState to override the state table next field.
type | - whether to use 'trial' [default] or 'block' factor |
runExperiment::updateStaircaseAfterState | ( | in | me, |
in | result, | ||
in | state | ||
) |
Updates taskSequence with current info and the result for that trial running the taskSequence.updateTask function
result | an integer result, e.g. 1 = correct or -1 = breakfix |
runExperiment::updateTask | ( | in | me, |
in | result | ||
) |
Updates taskSequence with current info and the result for that trial running the taskSequence.updateTask function
result | an integer result, e.g. 1 = correct or -1 = breakfix |
runExperiment::updateVariables | ( | in | me, |
in | index, | ||
in | override, | ||
in | update | ||
) |
Updates the stimulus objects with the current variable set from taskSequence()
index | a single value of which the overall trial number is |
override | [true] - forces updating even if it is the same trial |
update | [false] - do we also run taskSequence.updateTask() as well? |
function set runExperiment::verbose | ( | in | me, |
in | value | ||
) |
Property runExperiment::askForComments |
ask for comments?
Property runExperiment::audioDevice |
audio device
Property runExperiment::benchmark |
flip as fast as possible?
Property runExperiment::comments |
do we ask for comments for runMOC
Property runExperiment::control |
use control commands to start / stop recording device = intan | plexon | none port = tcp port
Property runExperiment::debug |
enable debugging? (poorer temporal fidelity)
Property runExperiment::diaryMode |
turn diary on for runTask, saved to the same folder as the data
Property runExperiment::drawFixation |
draw simple fixation cross during trial for MOC tasks?
Property runExperiment::eyetracker |
which eyetracker to use
Property runExperiment::isRunning |
return if runExperiment is running (true) or not (false)
Property runExperiment::keyboardDevice |
Keyboard device, use -1 for all keyboards (slower) or [] for default
Property runExperiment::lastIndex |
Property runExperiment::lastSize |
Property runExperiment::lastXExclusion |
Property runExperiment::lastXPosition |
keep track of several task values during runTask()
Property runExperiment::lastYExclusion |
Property runExperiment::lastYPosition |
Property runExperiment::logFrames |
log all frame times?
Property runExperiment::logStateTimers |
do we record times for every function run by state machine?
Property runExperiment::optickaVersion |
opticka version, passed on first use by opticka
Property runExperiment::photoDiode |
show a white square in the top-right corner to trigger a photodiode attached to screen for MOC task. For stateMachine tasks you need to pass in the drawing command for this to take effect.
Property runExperiment::researcherName |
DEPRECATED.
Property runExperiment::reward |
what reward device to use
Property runExperiment::screen |
a screenManager class instance managing the PTB Screen
Property runExperiment::screenSettings |
structure for screenManager on initialisation and info from opticka
Property runExperiment::sessionData |
Property runExperiment::stateInfoFile |
filename for a stateMachine state info file
Property runExperiment::stimList |
used to select single stimulus in training mode
set runExperiment::stimuli |
a metaStimulus class instance holding our stimulus objects
Migrate to use a metaStimulus object to manage stimulus objects
Property runExperiment::stimulus |
our old stimulus structure used to be a simple cell, now we use metaStimulus
Property runExperiment::strobe |
what strobe device to use device = '' | display++ | datapixx | labjackt | labjack | nirsmart optional port = not needed for most of the interfaces optional config = plain | plexon style strobe default stim OFF strobe value
Property runExperiment::subjectName |
DEPRECATED.
Property runExperiment::task |
a taskSequence class instance determining our stimulus variables
Property runExperiment::thisStim |
which stimulus is selected?
Property runExperiment::touch |
Property runExperiment::tS |
tS is the runtime settings structure, saved here as a backup
Property runExperiment::uiCommand |
this lets the opticka UI leave commands to runExperiment
Property runExperiment::userFunctionsFile |
user functions file that can be passed to the state machine
set runExperiment::verbose |
verbose logging to command window?
Let us cascase verbosity to other classes
Property runExperiment::visualDebug |
shows the info text and position grid during stimulus presentation