expyfun.stimuli.TrackerMHW#
- class expyfun.stimuli.TrackerMHW(callback, x_min, x_max, base_step=5, factor_down=2, factor_up_nr=4, start_value=40, n_up_stop=2, repeat_limit='reversals')[source]#
Up-down adaptive tracker for the modified Hughson-Westlake Procedure
This class implements a standard up-down adaptive tracker object. It is configured to run a fixed-step m*base-down n*base-up tracker (staircase), with a different z*base-up if there is “no response” to the start_value.
- Parameters:
- callbackcallable | ExperimentController | None
The function that will be used to print the data, usually to the experiment .tab file. It should follow the prototype of
ExperimentController.write_data_line
. If an instance ofExperimentController
is given, then it will take that object’swrite_data_line
function. If None is given, then it will not write the data anywhere.- x_minfloat
The minimum value that the tracker level (
x
) is allowed to take. A value must be provided and cannot be “None”.- x_maxfloat
The maximum value that the tracker level (
x
) is allowed to take. A value must be provided and cannot be “None”.- base_stepfloat
The size of the base step when the tracker moves up or down.
- factor_downfloat
The factor multiplier of the base step when the tracker moves down. The default is 2.
- factor_up_nrfloat
The factor multiplier of the base step when there is “no response” (i.e., “incorrect” response) to the start_value. The default is 4.
- start_valuefloat
The starting level of the tracker.
- n_up_stopint
The number of times the level has a correct response in order to stop.
- repeat_limitstr
How to treat trials that try to exceed either x_min or x_max.
reversals
will consider these trials as reversals while staying at the same level.ignore
does not consider these trials as reversals.
- Attributes:
- base_step
- factor_down
- factor_up_nr
- n_correct_levels
n_reversals
The number of reversals so far
n_trials
The number of trials so far
- n_up_stop
- repeat_limit
responses
The response history
reversal_inds
The trial indices which had reversals
reversals
The reversal history (0 where there was no reversal)
- start_value
stopped
Has the tracker stopped
- threshold
threshold_reached
Which levels have threshold reached
x
The staircase
x_current
The current level
- x_max
- x_min
Methods
check_valid
(n_reversals)If last reversals contain reversals exceeding x_min or x_max.
plot
([ax, threshold])Plot the adaptive track.
plot_thresh
([ax])Plot a line showing the threshold.
respond
(correct)Update the tracker based on the last response.
- Returns:
- trackerinstance of TrackerMHW
The up-down modified Hughson-Westlake tracker object.
Notes
In the modified Hughson-Westlake procedure, the up-step is the base-step, (e.g., 5) and the down-step is 2 * base-step (e.g., 10), except when there is “no response” to the starting value. Then the up-step is 4 * base-step (e.g., 20) in order to quickly get within a suitable range for audibility and finding threshold.
- check_valid(n_reversals)[source]#
If last reversals contain reversals exceeding x_min or x_max.
- Parameters:
- n_reversalsint
Number of reversals (starting from the end to check).
- Returns:
- validbool
True if none of the reversals are at x_min or x_max and False otherwise.
- property n_reversals#
The number of reversals so far
- property n_trials#
The number of trials so far
- plot(ax=None, threshold=True)[source]#
Plot the adaptive track.
- Parameters:
- axAxesSubplot | None
The axes to make the plot on. If
None
defaults to current axes.- thresholdbool
Whether to plot the estimated threshold on the axes. Default is True.
- Returns:
- figFigure
The figure handle.
- axAxesSubplot
The axes handle.
- lineslist of Line2D
The handles to the staircase line and the reversal dots.
- plot_thresh(ax=None)[source]#
Plot a line showing the threshold.
- Parameters:
- axAxes
The handle to the axes object. If None, the current axes will be used.
- Returns:
- linelist Line2D
The handle to the threshold line, as returned from
plt.plot
.
- respond(correct)[source]#
Update the tracker based on the last response.
- Parameters:
- correctboolean
Was the most recent subject response correct?
- property responses#
The response history
- property reversal_inds#
The trial indices which had reversals
- property reversals#
The reversal history (0 where there was no reversal)
- property stopped#
Has the tracker stopped
- property threshold_reached#
Which levels have threshold reached
- property x#
The staircase
- property x_current#
The current level
Examples using expyfun.stimuli.TrackerMHW
#
Do an adaptive track staircase with MHW procedure