pulse2percept.models.temporal
Classes
|
A generic temporal model for phosphene fading |
- class pulse2percept.models.temporal.FadingTemporal(**params)[source]
A generic temporal model for phosphene fading
Implements phosphene fading using a leaky integrator:
\[\frac{dB}{dt} = -\frac{A+B}{\tau}\]where \(A\) is the stimulus amplitude, \(B\) is the perceived brightness, and \(\tau\) is the exponential decay constant (
tau).The model makes the following assumptions:
Cathodic currents (negative amplitudes) will increase perceived brightness
Anodic currents (positive amplitudes) will decrease brightness
Brightness is bounded in \([\theta, \infty]\), where \(\theta\) (
thresh_percept) is a nonnegative scalar
- Parameters:
dt (float, optional) – Sampling time step of the simulation (ms)
tau (float, optional) – Time decay constant for the exponential decay (ms). Larger values lead to slower decay. Brightness should decay to half its peak (“half-life”) after \(\ln(2) \tau\) milliseconds.
thresh_percept (float, optional) – Below threshold, the percept has brightness zero.
n_threads (int, optional) – Number of CPU threads to use during parallelization using OpenMP. Defaults to max number of user CPU cores.
versionadded: (..) – 0.7.1:
- build(**build_params)[source]
Build the model
Every model must have a
`buildmethod, which is meant to perform all expensive one-time calculations. You must callbuildbefore callingpredict_percept.Important
Don’t override this method if you are building your own model. Customize
_buildinstead.- Parameters:
build_params (additional parameters to set) – You can overwrite parameters that are listed in
get_default_params. Trying to add new class attributes outside of that will cause aFreezeError. Example:model.build(param1=val)
- find_threshold(stim, bright_th, amp_range=(0, 999), amp_tol=1, bright_tol=0.1, max_iter=100, t_percept=None)[source]
Find the threshold current for a certain stimulus
Estimates
amp_thsuch that the output ofmodel.predict_percept(stim(amp_th))is approximatelybright_th.- Parameters:
stim (
Stimulus) – The stimulus to use. Stimulus amplitude will be up and down regulated untilamp_this found.bright_th (float) – Model output (brightness) that’s considered “at threshold”.
amp_range ((amp_lo, amp_hi), optional) – Range of amplitudes to search (uA).
amp_tol (float, optional) – Search will stop if candidate range of amplitudes is within
amp_tolbright_tol (float, optional) – Search will stop if model brightness is within
bright_tolofbright_thmax_iter (int, optional) – Search will stop after
max_iteriterationst_percept (float or list of floats, optional) – The time points at which to output a percept (ms). If None,
implant.stim.timeis used.
- Returns:
amp_th (float) – Threshold current (uA), estimated so that the output of
model.predict_percept(stim(amp_th))is withinbright_tolofbright_th.
- property is_built
A flag indicating whether the model has been built
- predict_percept(stim, t_percept=None)[source]
Predict the temporal response
Important
Don’t override this method if you are creating your own model. Customize
_predict_temporalinstead.- Parameters:
stim (: py: class: ~pulse2percept.stimuli.Stimulus or) – : py: class: ~pulse2percept.models.Percept Either a Stimulus or a Percept object. The temporal model will be applied to each spatial location in the stimulus/percept.
t_percept (float or list of floats, optional) –
The time points at which to output a percept (ms). If None, the percept will be output once very 20 ms (50 Hz frame rate).
Note
If your stimulus is shorter than 20 ms, you should specify the desired time points manually.
- Returns:
percept (
Percept) – A Percept object whosedatacontainer has dimensions Y x X x T. Will return None ifstimis None.
Notes
If a list of time points is provided for
t_percept, the values will automatically be sorted.