pyoperant.queues module

class pyoperant.queues.AdaptiveBase(**kwargs)[source]

Bases: object

docstring for AdaptiveBase This is an abstract object for implementing adaptive procedures, such as a staircase. Importantly, any objects inheriting this need to define the update() and next() methods.

next()[source]
no_response()[source]
on_load()[source]
update(correct, no_resp)[source]
update_error_msg()[source]
class pyoperant.queues.DoubleStaircase(stims, rate_constant=0.05, **kwargs)[source]

Bases: pyoperant.queues.AdaptiveBase

Generates conditions from a list of stims that monotonically vary from most easily left to most easily right i.e. left is low and right is high

The goal of this queue is to estimate the 50% point of a psychometric curve.

This will probe left and right trials, if the response is correct, it will move the indices closer to each other until they are adjacent.

stims: an array of stimuli names ordered from most easily left to most easily right rate_constant: the step size is the rate_constant*(high_idx-low_idx)

next()[source]
no_response()[source]
update(correct, no_resp)[source]
update_error_msg()[source]
class pyoperant.queues.DoubleStaircaseReinforced(stims, rate_constant=0.05, probe_rate=0.1, sample_log=False, **kwargs)[source]

Bases: pyoperant.queues.AdaptiveBase

Generates conditions as with DoubleStaircase, but 1-probe_rate proportion of the trials easier/known trials to reduce frustration.

Easier trials are sampled from a log shaped distribution so that more trials are sampled from the edges than near the indices

stims: an array of stimuli names ordered from most easily left to most easily right rate_constant: the step size is the rate_constant*(high_idx-low_idx) probe_rate: proportion of trials that are between [0, low_idx] or [high_idx, length(stims)]

next()[source]
no_response()[source]
on_load()[source]
update(correct, no_resp)[source]
update_error_msg()[source]
class pyoperant.queues.KaernbachStaircase(start_val=100, stepsize_up=3, stepsize_dn=1, min_val=0, max_val=100, crit=100, crit_method='trials')[source]

Bases: pyoperant.queues.AdaptiveBase

generates values for a staircase procedure from Kaernbach 1991 This procedure returns values for each trial and assumes that larger values are easier. Thus, after a correct trial, the next value returned will be smaller and after incorrect trials, the next value returned will be larger. The magnitudes of these changes are stepsize_dn and stepsize_up, respectively. :param start_val: the starting value of the procedure (default: 100) :type start_val: float/int

Kwargs:
stepsize_up (int): number of steps to take after incorrect trial (default: 3) stepsize_dn (int): number of steps to take after correct trial (default: 1) min_val (float): minimum parameter value to allow (default: 0) max_val (float): maximum parameter value to allow (default: 100) crit (int): minimum number of trials (default: 0) crit_method (int): maximum number of trials (default: 100)
Returns:float
next()[source]
update(correct, no_resp)[source]
class pyoperant.queues.MixedAdaptiveQueue(sub_queues, probabilities=None, **kwargs)[source]

Bases: pyoperant.queues.PersistentBase, pyoperant.queues.AdaptiveBase

Generates conditions from multiple adaptive sub queues.

Use the generator MixedAdaptiveQueue.load(filename, sub_queues) to load a previously saved MixedAdaptiveQueue or generate a new one if the pkl file doesn’t exist.

sub_queues: a list of adaptive queues probabilities: a list of weights with which to sample from sub_queues

should be same length as sub_queues NotImplemented

filename: filename of pickle to save itself

next()[source]
on_load()[source]
update(correct, no_resp)[source]
class pyoperant.queues.PersistentBase(filename=None, **kwargs)[source]

Bases: object

A mixin that allows for the creation of an obj through a load command that first checks for a pickled file to load an object before generating a new one.

classmethod load(filename, *args, **kwargs)[source]
on_load()[source]
save()[source]
pyoperant.queues.block_queue(conditions, reps=1, shuffle=False)[source]

generate trial conditions from a block

Parameters:conditions (list) – The conditions to sample from.
Kwargs:
reps (int): number of times each item in conditions will be presented (default: 1) shuffle (bool): Shuffles the queue (default: False)
Returns:whatever the elements of ‘conditions’ are
pyoperant.queues.random_queue(conditions, tr_max=100, weights=None)[source]

generator which randomly samples conditions

Parameters:
  • conditions (list) – The conditions to sample from.
  • weights (list of ints) – Weights of each condition
Kwargs:
tr_max (int): Maximum number of trial conditions to generate. (default: 100)
Returns:whatever the elements of ‘conditions’ are