pulse2percept.models.cortex
Phosphene models for cortical implants
- class pulse2percept.models.cortex.CortexSpatial(implant, *, regions=None, visual_field_map=None, **params)[source]
Abstract base class for cortical models
This is an abstract class that cortical models can subclass to get cortical implementation of the following features.
Updated default parameters for cortex
Handling of multiple visual regions via regions property
Plotting, including multiple visual regions, legends, vertical divide at longitudinal fissure, etc.
Parameters:
- implant
Implant The implant whose stimulation this model predicts.
Added in version 0.11.0.
- regionslist of str, optional
The regions to simulate. Options are any combination of ‘v1’, ‘v2’, ‘v3’. Default: [‘v1’].
- rhodouble, optional
Exponential decay constant describing current spread size (microns).
- min_current_spreadfloat, optional
An electrode is skipped at grid points where its Gaussian current spread has decayed below this fraction of its peak. The default (1e-8, about 6.1
rhoaway) drops the Gaussian times the stimulus amplitude, summed over the skipped electrodes, so the error at a point is bounded bymin_current_spreadtimes the summed amplitude across electrodes.- xrange(x_min, x_max), optional
A tuple indicating the range of x values to simulate (in degrees of visual angle). Negative x values lie left of fixation, positive x values right of it.
- yrangetuple, (y_min, y_max), optional
A tuple indicating the range of y values to simulate (in degrees of visual angle). Negative y values lie below fixation, positive y values above it.
- stepint, 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)andstep=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
VisualFieldMapobject that provides retinotopic mappings. By default,Polimeni2006Mapis used.- n_grayint, 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_graybins. 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_rotationfloat or Quantity, optional
In-plane rotation (deg), positive counter-clockwise.
Added in version 0.11.0.
- implant_depthfloat or Quantity, optional
Signed offset (um) along the normal of a 2D tissue map.
Added in version 0.11.0.
- location_noisefloat or None, optional
Standard deviation of fixed electrode-specific phosphene offsets, in dva. Requires an invertible 2D
visual_field_map.Noneor 0 disables it. Location-dependent models may also change phosphene shape or size.Added in version 0.11.0.
- n_threadsint, optional
Number of CPU threads to use during parallelization using OpenMP. Defaults to max number of user CPU cores.
- n_jobsint, optional
Alias for
n_threads;Noneor-1uses every core.
Important
Changing a model parameter outside the constructor (e.g., by directly setting
model.xrange = (-10, 10)) invalidates the build, and the nextpredict_perceptbuilds it again.- build(**build_params)[source]
Build the spatial model.
Applies any supplied parameters, validates the implant, visual-field map and implant placement, builds the sampling grid, then runs
_build.- Parameters:
**build_params (keyword arguments) – Declared model parameters to set before building.
- Return type:
self
- extra_stimulus_units = ()
Additional stimulus units accepted by this model
- property implant
The prosthesis system whose geometry this model uses.
Rebinding invalidates the spatial build.
Added in version 0.11.0.
- property is_built
A read-only flag indicating whether the model has been built
- property n_jobs
both names read and write the same value.
- Type:
Number of OpenMP threads to use during parallelization. An alias for
n_threads
- predict_percept(source, t_percept=None)[source]
Predict the spatial response.
- Parameters:
source (stimulus source) – Anything accepted by
prepare_stim().t_percept (float or array-like, optional) – Output times in
time_unit. If omitted, use the source time points. Unitful times are accepted.
- Returns:
percept – Percept with shape Y x X x T, or
Nonefor an empty source.- Return type:
Perceptor None
Notes
For an encoded image or video, a spatial-only model uses frame-level modulation rather than the delivered pulse train. In a composite
Modelwith a temporal stage, the spatial stage receives the delivered train so the temporal model can integrate it.Changed in version 0.11.0: Takes the stimulus source rather than an implant carrying a stimulus.
- plot(use_dva=False, style=None, autoscale=True, ax=None, figsize=None, fc=None, show_implant=False, **kwargs)[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
fc (matplotlib color, optional) – Face color for the grid cells. If None, will use the default matplotlib color cycle.
show_implant (bool, optional) –
Draw the implant at its model-side placement. Requires
use_dva=False.Added in version 0.11.0.
kwargs (dict, optional) – Additional keyword arguments are passed on to Grid2D.plot()
- Returns:
ax – Returns the axis object of the plot
- Return type:
matplotlib.axes.Axes
- class pulse2percept.models.cortex.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)andstep=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 aVisualFieldMapobject that provides visual field mappings. By default,Polimeni2006Mapis 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_graybins. 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.Noneor 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 nextpredict_perceptbuilds 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_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_perceptconverts 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_perceptcalls 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 aFreezeError. 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 (
Stimulussource type) – What is presented to the device; seeprepare_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); seepulse2percept.units.
- Returns:
percept – A Percept object whose
datacontainer has dimensions Y x X x T. Will return None ifsourceis None or empty.- Return type:
Percept
- 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
- class pulse2percept.models.cortex.ScoreboardModel(implant, *, rho=200, regions=None, meridian_blend=0.1, xrange=(-5, 5), yrange=(-5, 5), step=0.1, grid_type='rect', thresh_percept=0, min_current_spread=1e-08, visual_field_map=None, n_gray=None, implant_position=(0, 0), implant_rotation=0, implant_depth=0, location_noise=None, verbose=True, ndim=None, n_threads=None, n_jobs=None)[source]
Cortical adaptation of scoreboard model from [Beyeler2019] (standalone model)
Implements the scoreboard model described in [Beyeler2019], where percepts from each electrode are Gaussian blobs. The percepts resulting from different cortical regions (e.g. v1/v2/v3) are added linearly. The rho parameter modulates phosphene size.
Note
Use
ScoreboardSpatialto combine the spatial model with a temporal model.Note
For this spatial-only model, dimensionless image and video values are treated as relative electrode amplitudes, so an implant encoder is not required. Physical or pulse-dependent models still require encoded stimulation.
Warning
rhois fixed: this model does not predict pulse-dependent phosphene size. Doubling amplitude doubles brightness and leaves the phosphene exactly as wide. UseDynaphosModelfor a cortical model whose phosphene size follows the stimulus current.- Parameters:
implant (
Implant) –The implant whose stimulation this model predicts.
Added in version 0.11.0.
rho (double, optional) – Exponential decay constant describing phosphene size (microns).
min_current_spread (float, optional) – An electrode is skipped at grid points where its Gaussian current spread has decayed below this fraction of its peak. The default (1e-8, about 6.1
rhoaway) drops the Gaussian times the stimulus amplitude, summed over the skipped electrodes, so the error at a point is bounded bymin_current_spreadtimes the summed amplitude across electrodes.regions (list of str, optional) – The regions to simulate. Options are ‘v1’, ‘v2’, or ‘v3’. Default: [‘v1’]
xrange ((x_min, x_max), optional) – A tuple indicating the range of x values to simulate (in degrees of visual angle). Negative x values lie left of fixation, positive x values right of it.
yrange (tuple, (y_min, y_max), optional) – A tuple indicating the range of y values to simulate (in degrees of visual angle). Negative y values lie below fixation, positive y values above it.
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)andstep=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
meridian_blend (float, optional) –
Gaussian standard deviation (dva) for smoothing across the vertical meridian. Default: 0.1. Set to 0 to disable.
Added in version 0.10.0.
visual_field_map (
VisualFieldMap, optional) – An instance of aVisualFieldMapobject that provides retinotopic mappings. By default,Polimeni2006Mapis 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_graybins. 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.Noneor 0 disables it. Location-dependent models may also change phosphene shape or size.Added in version 0.11.0.
n_threads (int, optional) – Number of CPU threads to use during parallelization using OpenMP. Defaults to max number of user CPU cores.
n_jobs (int, optional) – Alias for
n_threads;Noneor-1uses every core.:: (.. important) – Changing a model parameter outside the constructor (e.g., by directly setting
model.xrange = (-10, 10)) invalidates the build, and the nextpredict_perceptbuilds it again.
- build()[source]
Build all model components.
Unlike prediction-time auto-building, this rebuilds every component. To set parameters while building, call the component’s
buildmethod, e.g.model.spatial.build(rho=250).- Return type:
self
- property extra_stimulus_units
Additional stimulus units accepted by the active component
- property has_space
Returns True if the model has a spatial component
- property has_time
Returns True if the model has a temporal component
- property implant
The implant the spatial model is bound to.
Returns
Nonefor temporal-only models. Assignment forwards tomodel.spatial.implantand invalidates the spatial build.Added in version 0.11.0.
- property is_built
Returns True if the
buildmodel has been called
- plot(*args, **kwargs)[source]
Plot the spatial model.
Parameters and return value are those of
plot().
- predict_percept(source, t_percept=None, gaze=None)[source]
Predict a percept.
- Parameters:
source (stimulus source or
Scene) – What is presented to the device: anything accepted byprepare_stim(), or a visual scene.t_percept (float or array-like, optional) – Output times in
time_unit. Unitful times are accepted.gaze ((x, y), (n_frames, 2), or
Gaze, optional) – Scene location falling on the fovea, in degrees of visual angle, so thatscene = eye-centered visual field + gaze. Requiressourceto be a scene. AGazeis resolved against the scene’s frame times, not againstt_percept. Gaze decides which part of the scene reaches the electrodes unless the implant’sscene_input_frameis'head'; the percept itself stays on the model’s eye-centered grid either way.
- Returns:
percept (
Perceptor None) – Perceived brightness on the model’s spatial grid, for a scene as for any other source. A scene’s scotoma describes residual native vision and does not enter the model response; draw the two together withplot()orrender()... versionchanged:: 0.11.0 –
sourceis now the presented stimulus or scene rather than an implant carrying a stimulus. Scene prediction returns the model percept;vminandvmaxmoved toScene.plotandScene.render.
- property space_unit
The unit spatial coordinates are expressed in
The temporal model never sees a coordinate.
- property stimulus_unit
The unit stimulus values are expressed in
The stimulus goes to the spatial model if there is one, and straight to the temporal model otherwise.
- property time_unit
Time unit used by the final model stage.
t_perceptand the returned percept use the temporal model’s unit when present, otherwise the spatial model’s unit.
- class pulse2percept.models.cortex.ScoreboardSpatial(implant, *, rho=200, regions=None, meridian_blend=0.1, xrange=(-5, 5), yrange=(-5, 5), step=0.1, grid_type='rect', thresh_percept=0, min_current_spread=1e-08, visual_field_map=None, n_gray=None, implant_position=(0, 0), implant_rotation=0, implant_depth=0, location_noise=None, verbose=True, ndim=None, n_threads=None, n_jobs=None)[source]
Cortical adaptation of scoreboard model from [Beyeler2019]
Implements the scoreboard model described in [Beyeler2019], where percepts from each electrode are Gaussian blobs. The percepts resulting from different cortical regions (e.g. v1/v2/v3) are added linearly. The rho parameter modulates phosphene size.
Note
Use this class if you want to combine the spatial model with a temporal model. Use
ScoreboardModelif you want a a standalone model.Warning
rhois fixed: this model does not predict pulse-dependent phosphene size. Doubling amplitude doubles brightness and leaves the phosphene exactly as wide. UseDynaphosModelfor a cortical model whose phosphene size follows the stimulus current.- Parameters:
implant (
Implant) –The implant whose stimulation this model predicts.
Added in version 0.11.0.
rho (double, optional) – Exponential decay constant describing phosphene size (microns).
min_current_spread (float, optional) – An electrode is skipped at grid points where its Gaussian current spread has decayed below this fraction of its peak. The default (1e-8, about 6.1
rhoaway) drops the Gaussian times the stimulus amplitude, summed over the skipped electrodes, so the error at a point is bounded bymin_current_spreadtimes the summed amplitude across electrodes.regions (list of str, optional) – The regions to simulate. Options are ‘v1’, ‘v2’, or ‘v3’. Default: [‘v1’]
xrange ((x_min, x_max), optional) – A tuple indicating the range of x values to simulate (in degrees of visual angle). Negative x values lie left of fixation, positive x values right of it.
yrange (tuple, (y_min, y_max), optional) – A tuple indicating the range of y values to simulate (in degrees of visual angle). Negative y values lie below fixation, positive y values above it.
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)andstep=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
meridian_blend (float, optional) –
Gaussian standard deviation (dva) for smoothing across the vertical meridian. Default: 0.1. Set to 0 to disable.
Added in version 0.10.0.
visual_field_map (
VisualFieldMap, optional) – An instance of aVisualFieldMapobject that provides retinotopic mappings. By default,Polimeni2006Mapis 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_graybins. 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.Noneor 0 disables it. Location-dependent models may also change phosphene shape or size.Added in version 0.11.0.
n_threads (int, optional) – Number of CPU threads to use during parallelization using OpenMP. Defaults to max number of user CPU cores.
n_jobs (int, optional) – Alias for
n_threads;Noneor-1uses every core.:: (.. important) – Changing a model parameter outside the constructor (e.g., by directly setting
model.xrange = (-10, 10)) invalidates the build, and the nextpredict_perceptbuilds it again.
- build(**build_params)[source]
Build the spatial model.
Applies any supplied parameters, validates the implant, visual-field map and implant placement, builds the sampling grid, then runs
_build.- Parameters:
**build_params (keyword arguments) – Declared model parameters to set before building.
- Return type:
self
- extra_stimulus_units = ()
Additional stimulus units accepted by this model
- property implant
The prosthesis system whose geometry this model uses.
Rebinding invalidates the spatial build.
Added in version 0.11.0.
- property is_built
A read-only flag indicating whether the model has been built
- property n_jobs
both names read and write the same value.
- Type:
Number of OpenMP threads to use during parallelization. An alias for
n_threads
- plot(use_dva=False, style=None, autoscale=True, ax=None, figsize=None, fc=None, show_implant=False, **kwargs)[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
fc (matplotlib color, optional) – Face color for the grid cells. If None, will use the default matplotlib color cycle.
show_implant (bool, optional) –
Draw the implant at its model-side placement. Requires
use_dva=False.Added in version 0.11.0.
kwargs (dict, optional) – Additional keyword arguments are passed on to Grid2D.plot()
- Returns:
ax – Returns the axis object of the plot
- Return type:
matplotlib.axes.Axes
- predict_percept(source, t_percept=None)[source]
Predict the spatial response.
- Parameters:
source (stimulus source) – Anything accepted by
prepare_stim().t_percept (float or array-like, optional) – Output times in
time_unit. If omitted, use the source time points. Unitful times are accepted.
- Returns:
percept – Percept with shape Y x X x T, or
Nonefor an empty source.- Return type:
Perceptor None
Notes
For an encoded image or video, a spatial-only model uses frame-level modulation rather than the delivered pulse train. In a composite
Modelwith a temporal stage, the spatial stage receives the delivered train so the temporal model can integrate it.Changed in version 0.11.0: Takes the stimulus source rather than an implant carrying a stimulus.