Skip to content

Architecture

Spunc edited this page May 2, 2016 · 3 revisions

Software components

ExperimentController

This class is the starting point of an experiment. Its most important methods are start() and stop() for starting and stopping of an experimental session.

The constructor is: ExperimentController(config) config is a struct with the following fields:

  • audioPlayer - an instance of AudioPlayer
  • audioObjectGenerator - an instance of AudioObjectGenerator
  • ioDevice - an instance of InputOutputDevice
  • pins - a struct with the fields:
    • sensor, which contains a number identifying a channel at which the InputOutputDevice receives inputs.
    • feeder, which contains a number identifying a channel of the InputOutputDevice to which a give-reward-signal can be sent.

An important property of ExperimentController is maxReactionTime. maxReactionTime defines the length of the time window during which responses of the subject will be taken into account. The time window starts with the onset of the last played Stimulus (this point in time is stored within the property lastAOTime of AudioPlayer). A response that was made within maxReactionTime will be classified as hit or false alarm, depending on the trial involved being a target or a non-target (sham or catch) trial. Responses that happen outside the time window are ignored.

AudioObjectGenerator

AudioObjectGenerator is just very basic iterator interface. The method next() provides the next AudioObject to be played by the AudioPlayer. The kind of AudioObject determines what will be played.

AudioObject

This is the base class for something that can be played by an AudioPlayer. The properties are:

  • id - an arbitrary string identifying a single instance
  • startDelay - This is the random waiting interval that the subject has to wait before the AudioObject actually will be played.
  • duration - how long the AudioObject lasts. This property is used so that the ExperimentController does not start a new AudioObject while an old one is still playing.

The method getEvent() returns a ExperimentEventData object that characterizes the AudioObject. It is similar function as the toString() method in Java.

Stimulus

AudioObjects whereupon the subject's reaction is critical, inherit from Stimulus. Therefore, Stimulus has the additional property target. target must be of the enumeration type Target, which defines the constants:

  • Yes_Reward - it is a target and a response should be rewarded
  • Yes_NoReward it is a target, but a response should not be rewarded
  • No it is not a target, a response will not be rewarded

Subclasses of Stimulus define further properties that are used by the AudioPlayer to create the sound corresponding to the Stimulus. E. g. the class ToneStimulus defines the properties frequency and level.

Attention: Although catch trials typically do not require the AudioPlayer to create sound samples for them, they are still sent to the AudioPlayer. And because responses are critical for catch trials, catch trials must inherit from Stimulus and the property target must be set to Target.No. You can use NullStimulus as an implementation for catch trials. Often the only thing an AudioPlayer does after receiving a catch trial is to actualize lastAOTime.

AudioPlayer

This class makes the sound. It plays AudioObjects and potentially other things e. g. background noise (like ContinuousBgndAudioPlayer does) for distraction or masking. The methods it must implement are:

  • start() - to start the sound
  • stop() - to stop the sound
  • playAudioObject() - to play an AudioObject

It also must actualize the property lastAOTime which contains the system time point, when the last AudioObject was played. This time must correspond as exact as possible to the time when the AudioObject actually was emitted by the loudspeakers or headphones.

InputOutputDevice

This class represents the software interface of a physical or a software-emulated I/O device. Its interface is best adapted to the Arduino (the actual implementation of InputOutputDevice to be used with an Arduino is ArduinoDevice). It has two methods:

  • send(pin, value) - use this function to send a value to the specified pin of the I/O device. ExperimentController uses this function to send a trigger pulse to the pin specified in ExperimentController.pins.feeder for releasing rewards.
  • signalEvent(pin, value) - this function should be called, when the I/O device registered subject inputs (e. g. subject signals ready state or subject responds). Each call to this function will trigger a DataReceived event with an InputDeviceData data object that contains the pin involved and the new value. ExperimentController listens to these events. At the moment, it only reacts upon events that involve the pin specified in ExperimentController.pins.sensor. A value of 1 at this pins signals that the subject is ready. A change to 0 signals a response.

Clone this wiki locally