psiaudio.queue module
- class AbstractSignalQueue(fs=None)
Bases:
object
- append(source, trials, delays=None, duration=None, metadata=None)
- cancel(t, delay=0)
- connect(callback, event='added')
- count_factories()
- count_requested_trials()
Count total trials
- count_trials()
Count remaining trials
- decrement_key(key, n=1)
Decrement trials for key
- Parameters
key (UUID) – Key to decrement
n (int) – Number of trials to decrement by
- Returns
complete – True if no trials left for key, False otherwise.
- Return type
bool
- extend(sources, trials, delays=None, duration=None, metadata=None)
- property fs
- get_closest_key(t)
- get_info(key)
- get_max_duration()
- get_ts()
- insert(source, trials, delays=None, duration=None, metadata=None)
- is_empty()
- next_key()
- next_trial(decrement=True)
Setup the next trial
This has immediate effect. If you call this (from external code), the current trial will not finish.
- pause(t=None)
- pop_buffer(samples, decrement=True)
Return the requested number of samples
Removes stack of waveforms in order determined by pop, but only returns requested number of samples. If a partial fragment of a waveform is returned, the remaining part will be returned on subsequent calls to this function.
- pop_key(key, decrement=True)
Removes one trial of specified key from queue and returns waveform
- pop_next(decrement=True)
- remaining_trials(key)
- remove_key(key)
Removes key from queue entirely, regardless of number of trials
- requeue(t)
Requeues all trials scheduled after t0
Note that this only requeues trials for which the trial counter was automatically decremented when the waveform was generated by the queue. When using artifact reject, trial counters are sometimes decremented by the artifact reject algorithm instead (e.g., ABRs) and the assumption is that the external algorithm will not recieve “cancelled” trials and, therefore, not decrement the counter.
- resume(t=None)
Resumes generating trials from queue
- Parameters
t (float) – Time, in sec, to resume generating trials from queue.
- rewind_samples(t)
- set_fs(fs)
- set_t0(t0)
- class BlockedFIFOSignalQueue(fs=None, *args, **kwargs)
Bases:
GroupedFIFOSignalQueue
Like the GroupedFIFOSignalQueue except block size is automatically set to the number of waveforms queued. If you have 8 waveforms queued:
A B C D E F G H
The queue iterates through A B C D E F G H until all trials have been presented.
- append(*args, **kwargs)
- class BlockedRandomSignalQueue(fs, seed=0, *args, **kwargs)
Bases:
InterleavedFIFOSignalQueue
- next_key()
- class FIFOSignalQueue(fs=None)
Bases:
AbstractSignalQueue
Return waveforms based on the order they were added to the queue
- next_key()
- class GroupedFIFOSignalQueue(group_size, fs=None, *args, **kwargs)
Bases:
FIFOSignalQueue
Like the FIFOSignalQueue, this queue iterates through each waveform in the order it was added. However, the iteration is performed in blocks. If the block size is 4 and you have 8 waveforms queued:
A B C D E F G H
The queue iterates through A B C D until all trials have been presented, then it shifts to E F G H.
- decrement_key(key, n=1)
Decrement trials for key
- Parameters
key (UUID) – Key to decrement
n (int) – Number of trials to decrement by
- Returns
complete – True if no trials left for key, False otherwise.
- Return type
bool
- next_key()
- class InterleavedFIFOSignalQueue(*args, **kwargs)
Bases:
AbstractSignalQueue
Return waveforms based on the order they were added to the queue; however, trials are interleaved.
- count_trials()
Count remaining trials
- decrement_key(key, n=1)
Decrement trials for key
- Parameters
key (UUID) – Key to decrement
n (int) – Number of trials to decrement by
- Returns
complete – True if no trials left for key, False otherwise.
- Return type
bool
- next_key()
- exception QueueEmptyError
Bases:
Exception
- class RandomSignalQueue(fs=None)
Bases:
AbstractSignalQueue
Return waveforms in random order
- next_key()
- as_iterator(x)