Head-turn Preference Procedure

This class is an extension of the PyHab Class (base) base class.

class PyHab.PyHabClassHPP.PyHabHPP(settingsDict, testMode=False)

A head-turn preference procedure version of PyHab. Uses some of the same code, but drastically more complex, needing to juggle which screen things are presented on, simultaneous presentation on multiple screens, and more.

SetupWindow()

An HPP-specific version of the function that sets up the windows and loads everything. With four windows to set up it’s a real doozy, and has the added problem of needing to assign things properly to each window for stim presentation.

TODO: Windows audio bug when loading an audio file before a movie means that we should change load order to movie first

Returns:
Return type:
abortTrial(onArray, offArray, trial, ttype, onArrayL, onArrayR, stimName='', habTrialNo=0, habCrit=0.0)

Aborts a trial in progress, saves any data recorded thus far to the bad-data structures

Parameters:
  • onArray (list of dicts {trial, trialType, startTime, endTime, duration}) – Gaze-on Center events
  • offArray (list of dicts {trial, trialType, startTime, endTime, duration}) – Gaze-off events
  • trial (int) – Trial number
  • ttype (string) – Trial type
  • onArrayL (list of dicts {trial, trialType, startTime, endTime, duration}) – Gaze-on Left events
  • onArrayR (list of dicts {trial, trialType, startTime, endTime, duration}) – Gaze-on Right events
  • stimName (string) – If presenting stimuli, name of the stim file
  • habTrialNo (int) – Tracking if this is a habituation trial and if so what number
  • habCrit (float) – Habituation criterion, if it’s been set
Returns:

Return type:

dataRec(onArray, offArray, trial, type, onArrayL, onArrayR, stimName='', habTrialNo=0, habCrit=0.0)

Records the data for a trial that ended normally.

Parameters:
  • onArray (list of dicts {trial, trialType, startTime, endTime, duration}) – Gaze-on Center events
  • offArray (list of dicts {trial, trialType, startTime, endTime, duration}) – Gaze-off events
  • trial (int) – Trial number
  • ttype (string) – Trial type
  • onArrayL (list of dicts {trial, trialType, startTime, endTime, duration}) – Gaze-on Left events
  • onArrayR (list of dicts {trial, trialType, startTime, endTime, duration}) – Gaze-on Right events
  • stimName (string) – If presenting stimuli, name of the stim file
  • habTrialNo (int) – Tracking if this is a habituation trial and if so what number
  • habCrit (float) – Habituation criterion, if it’s been set
Returns:

Return type:

dispCoderWindow(trialType=-1)

Because there are three looking keys, the experimenter window has three boxes. Also things work differently with there being no ‘secondkey’ really. :param trialType: :type trialType: :return: :rtype:

dispTrial(trialType, dispMovie=False)

An HPP-specific version of dispTrial that can display on multiple things, read the new stimDict, etc.

Parameters:
  • trialType (str) – The trial type of the current trial being displayed
  • dispMovie (bool or dict) – Now a dictionary C/L/R each index of which contains what this function expects in the base class
Returns:

1 or 0. 1 = end of movie for trials that end on that. TODO: for HPP currently returns 1 if EVERYTHING IN IT is done.

Return type:

int

doTrial(number, ttype, disMovie)

Control function for individual trials, to be called by doExperiment Returns a status value (int) that tells doExperiment what to do next HPP experiments works very differently from everything else, and this is where the bulk of that is happening.

Parameters:
  • number (int) – Trial number
  • ttype (string) – Trial type
  • disMovie (dict) – A dictionary with three indexes, one per screen. Any screen with stimuli on it will have a dictionary {stimType:,stim:}
Returns:

int, 0 = proceed to next trial, 1 = hab crit met, 2 = end experiment, 3 = trial aborted

Return type:

endExperiment()

End experiment, save all data, calculate reliability if needed, close up shop :return: :rtype:

lookKeysPressed()

A simple boolean function to allow for more modularity with preferential looking Basically, allows you to set an arbitrary set of keys to start a trial once the attngetter has played. In this case, any of V, B, or N are sufficient.

Returns:True if the V, B, or N key is pressed, False otherwise.
Return type:
lookScreenKeyPressed(screen=['C'])

A function that primarily exists for HPP, because of the need to distinguish between any key being pressed and the key corresponding to the HPP screen in question being pressed

Parameters:screen (list of strings) – List of screens for next stim.
Returns:for non-HPP versions, the value of lookKeysPressed.
Return type:bool
printCurrentData()

Prints current data to output window, HPP variant. Only called when stimulus presentation is off.

Returns:
Return type: