pulse2percept.models.cortex.dynaphos¶
Classes
DynaphosModel (**params) |
Adaptation of the Dynaphos model from [Grinten2023] |
-
class
pulse2percept.models.cortex.dynaphos.
DynaphosModel
(**params)[source]¶ Adaptation of the Dynaphos model from [Grinten2023]
The original and official implementation is available at https://github.com/neuralcodinglab/dynaphos.
Implements the Dynaphos model. Percepts from each electrode are Gaussian blobs, with the size dictated by a magnification factor M determined by the electrode’s position in the visual cortex.
Parameters: - dt (float, optional) – Sampling time step of the simulation (ms)
- regions (list of str, optional) – The visual regions to simulate. Options are ‘v1’, ‘v2’, or ‘v3’. Default : [‘v1’]
- rheobase (float, optional) – Rheobase current constant (uA)
- tau_trace (float, optional) – Trace decay constant (ms)
- kappa_trace (float, optional) – Stimulus input effect modifier constant for memory trace
- excitability (float, optional) – Excitability constant for current spread (uA/mm^2)
- tau_act (float, optional) – Activation decay constant (ms)
- sig_slope (float, optional) – Slope of the sigmoidal brightness curve
- a_thr (float, optional) – Activation threshold value, under which a phosphene is not generated
- a50 (float, optional) – Activation value for which a phosphene reaches half of its maximum brightness
- freq (float, optional) – Default stimulus frequency (Hz)
- p_dur (float, optional) – Default stimulus pulse duration (ms)
- xrange ((x_min, x_max), optional) – A tuple indicating the range of x values to simulate (in degrees of visual angle). Negative values correspond to the right hemisphere of visual cortex, and positive values correspond to the left hemisphere.
- yrange ((y_min, y_max), optional) – A tuple indicating the range of y values to simulate (in degrees of visual angle).
- xystep (int, double, tuple, optional) – Step size for the range of (x,y) values to simulate (in degrees of
visual angle). For example, to create a grid with x values [0, 0.5, 1]
use
x_range=(0, 1)
andxystep=0.5
. - grid_type ({'rectangular', 'hexagonal'}, optional) – Whether to simulate points on a rectangular or hexagonal grid.
- vfmap (
VisualFieldMap
, optional) – An instance of aVisualFieldMap
object that provides visual field mappings. By default,Polimeni2006Map
is used. - n_gray (int, optional) – The number of gray levels to use. If an integer is given, k-means
clustering is used to compress the color space of the percept into
n_gray
bins. If None, no compression is performed. - noise (float or int, optional) – Adds salt-and-pepper noise to each percept frame. An integer will be interpreted as the number of pixels to subject to noise in each frame. A float between 0 and 1 will be interpreted as a ratio of pixels to subject to noise in each frame.
Important
If you change important model parameters outside the constructor (e.g., by directly setting
model.xrange = (-10, 10)
), you will have to callmodel.build()
again for your changes to take effect.-
build
(**build_params)[source]¶ Build the model
Performs expensive one-time calculations, such as building the spatial grid used to predict a percept. You must call
build
before callingpredict_percept
.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)
-
is_built
¶ A flag indicating whether the model has been built
-
plot
(use_dva=False, style=None, autoscale=True, ax=None, figsize=None, fc=None)[source]¶ Plot the model :param use_dva: Plot points in visual field. If false, simulated points will be
plotted in cortexParameters: - style ({'hull', 'scatter', 'cell'}, optional) –
Grid plotting style: * ‘hull’: Show the convex hull of the grid (that is, the outline of
the smallest convex set that contains all grid points).- ’scatter’: Scatter plot all grid points
- ’cell’: Show the outline of each grid cell as a polygon. Note that this can be costly for a high-resolution grid.
- autoscale (bool, optional) – Whether to adjust the x,y limits of the plot to fit the implant
- ax (matplotlib.axes._subplots.AxesSubplot, optional) – A Matplotlib axes object. If None, will either use the current axes (if exists) or create a new Axes object.
- figsize ((float, float), optional) – Desired (width, height) of the figure in inches
Returns: ax (
matplotlib.axes.Axes
) – Returns the axis object of the plot- style ({'hull', 'scatter', 'cell'}, optional) –
-
predict_percept
(implant, t_percept=None)[source]¶ Predict the spatiotemporal response
Parameters: - implant (
ProsthesisSystem
) – A valid prosthesis system. A stimulus can be passed viastim
. - t_percept (float or list of floats, optional) – The time points at which to output a percept (ms).
If None,
implant.stim.time
is used.
Returns: percept (
Percept
) – A Percept object whosedata
container has dimensions Y x X x T. Will return None ifimplant.stim
is None.- implant (