pulse2percept.models.cortex.dynaphos

DynaphosModel

Classes

DynaphosModel(implant, *[, dt, regions, ...])

Adaptation of the Dynaphos model from [vanderGrinten2023]

class pulse2percept.models.cortex.dynaphos.DynaphosModel(implant, *, dt=20, regions=None, rheobase=23.9, tau_trace=1967655.20573, kappa_trace=13.95528162, excitability=675, tau_act=111.111111, sig_slope=19152642.500946816, a_thr=9.141886000943878e-08, a50=1.057631326853325e-07, freq=300, p_dur=0.17, xrange=(-5, 5), yrange=(-5, 5), step=0.25, grid_type='rect', visual_field_map=None, n_gray=None, implant_position=(0, 0), implant_rotation=0, implant_depth=0, location_noise=None, verbose=True)[source]

Adaptation of the Dynaphos model from [vanderGrinten2023]

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.

The blob’s Gaussian standard deviation is a quarter of the phosphene diameter P (dva), following the reference implementation’s radius_to_sigma = 0.5.

Parameters:
  • implant (Implant) –

    The implant whose stimulation this model predicts.

    Added in version 0.11.0.

  • dt (float, optional) – Sampling time step of the simulation (ms)

  • regions (list of str, optional) – The visual regions to simulate. Only ['v1'] is supported: the model’s magnification, location noise, and phosphene size use 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).

  • step (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 xrange=(0, 1) and step=0.5. Pass a tuple to give the x and y axes different step sizes.

  • grid_type ({'rect', 'hex'}, optional) – Whether to simulate points on a rectangular or hexagonal grid.

  • visual_field_map (VisualFieldMap, optional) – An instance of a VisualFieldMap 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.

  • implant_position ((x, y) or Quantity, optional) –

    Position of the device-local origin, in tissue coordinates or dva.

    Added in version 0.11.0.

  • implant_rotation (float or Quantity, optional) –

    In-plane rotation (deg), positive counter-clockwise.

    Added in version 0.11.0.

  • implant_depth (float or Quantity, optional) –

    Signed offset (um) along the normal of a 2D tissue map.

    Added in version 0.11.0.

  • location_noise (float or None, optional) –

    Standard deviation of fixed electrode-specific phosphene offsets, in dva. Requires an invertible 2D visual_field_map. None or 0 disables it.

    Added in version 0.11.0.

  • important:: (..) – Changing a model parameter outside the constructor (e.g., by directly setting model.xrange = (-10, 10)) invalidates the build, and the next predict_percept builds it again.

property implant

The prosthesis system this model predicts percepts for

Model context rather than trial input: named once, and predict_percept() is then given the stimulus. Rebinding invalidates the build.

Added in version 0.11.0.

get_default_params()[source]

Returns all settable parameters of the Dynaphos model

get_param_units()[source]

Return a dict of the units that parameters are stored in

This model’s equations mix units: they take microamps, milliseconds and hertz as input, and the published cascade they implement is written in SI (seconds and amperes). What is declared here is the input contract – the units a caller supplies, which are the ones the docstring documents. _predict_percept converts them to SI once before its loop; see the conversion block there.

build(**build_params)[source]

Build the model

Performs expensive one-time calculations, such as building the spatial grid used to predict a percept. predict_percept calls it for you when the model is not built.

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 a FreezeError. Example: model.build(param1=val)

extra_stimulus_units = ()

Additional stimulus units accepted by this model

property is_built

A read-only flag indicating whether the model has been built

predict_percept(source, t_percept=None)[source]

Predict the spatiotemporal response

Changed in version 0.11.0: Takes the stimulus source rather than an implant; the implant is the one this model is bound to.

Parameters:
  • source (Stimulus source type) – What is presented to the device; see prepare_stim().

  • t_percept (float or list of floats, optional) – The time points at which to output a percept (ms). This model’s numerical contract is fixed to milliseconds. If None, the prepared stimulus’ own time points are used. May be given as a unitful quantity (e.g. [0, 20] * ms); see pulse2percept.units.

Returns:

percept – A Percept object whose data container has dimensions Y x X x T. Will return None if source is None or empty.

Return type:

Percept

set_params(**params)[source]

Set the parameters of this object

space_unit = um[source]

The unit spatial coordinates are expressed in

stimulus_unit = uA[source]

The unit stimulus values are expressed in

time_unit = ms[source]

The unit time is expressed in

plot(use_dva=False, style=None, autoscale=True, ax=None, figsize=None, fc=None, show_implant=False)[source]

Plot the model

Parameters:
  • use_dva (bool, optional) – Plot points in visual field. If false, simulated points will be plotted in cortex

  • 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

  • show_implant (bool, optional) –

    Draw the implant at its model-side placement. Requires use_dva=False.

    Added in version 0.11.0.

Returns:

ax – Returns the axis object of the plot

Return type:

matplotlib.axes.Axes