pulse2percept.implants.retina.base
Classes
|
Retinal prosthesis |
- class pulse2percept.implants.retina.base.RetinalImplant(electrode_array, eye='right', **kwargs)[source]
Retinal prosthesis
A retinal prosthesis is an
Implantthat stimulates the retina, and therefore sits in one eye. This is the base class for devices such asArgusIIandAlphaIMS, and can be used directly to give a custom electrode array an eye.Added in version 0.11.0.
- Parameters:
electrode_array (
ElectrodeArrayor) –ElectrodeThe electrode array used to deliver electrical stimuli to the retina.eye ('left' or 'right', optional) – A string indicating whether the system is implanted in the left or right eye. Case-insensitive on input; stored lowercase.
**kwargs – Keyword arguments accepted by
Implant, such aspreprocess,safe_mode,encoder,raster,max_current,thresholdsandscene_input_frame.
Examples
Give a custom grid of electrodes a left eye:
>>> from pulse2percept.implants import ElectrodeGrid >>> from pulse2percept.implants.retina import RetinalImplant >>> implant = RetinalImplant(ElectrodeGrid((4, 4), 400), eye='left') >>> implant.eye 'left'
- check_stim(stim)[source]
Quality-check the stimulus
This method is executed every time a stimulus is prepared (see
prepare_stim()).If
safe_modeis set to True, this function will only allow stimuli that are charge-balanced. Ifmax_currentis set, it will only allow stimuli whose total instantaneous current stays within it.Both are questions about electricity, and neither can be answered about a stimulus that is not a current, so each raises a
DimensionMismatchErroron one. In the ordinary flow this cannot happen:prepare_stim()has already checked the stimulus againststimulus_unit.check_stimis public, though, and may be handed anything.The user can define their own checks in implants that inherit from
Implant.- Parameters:
stim (
Stimulussource type) – A valid source type for theStimulusobject (e.g., scalar, NumPy array, pulse train).- Raises:
DimensionMismatchError – If an electrical check was requested and
stimis not measured in units of current... versionchanged: – 0.10.0: The electrical checks verify that the stimulus really is electrical, instead of reading whatever numbers it holds as microamps.
- property electrode_array
Electrode array
- property electrode_names
Return a list of all electrode names in the electrode array
- property electrode_objects
Return a list of all electrode objects in the array
- property electrodes
Return all electrode names and objects in the electrode array
Internally, electrodes are stored in an ordered dictionary. You can iterate over different electrodes in the array as follows:
for name, electrode in implant.electrodes.items(): print(name, electrode)
You can access an individual electrode by indexing directly into the implant, e.g.
implant['A1']orimplant[0], and ask how many there are withlen(implant).
- property encoder
Stimulus encoder used for image or video input.
Must be an
ImplantEncoder. Model-aware encoders such asTraceEncoderare called directly instead. If None, dimensionless image/video stimuli are not encoded automatically.Assigning an unbound encoder (
encoder.implant is None) binds it to this implant. An encoder bound to a different implant is rejected with a ValueError.
- family = None
Named device family, if applicable, e.g.
'PRIMA'. .. versionadded:: 0.11.0
- property max_current
Total instantaneous current (uA) the stimulator can source
- property n_electrodes
Number of electrodes in the array
This is equivalent to calling
electrode_array.n_electrodes.
- placement = None
Where the device sits relative to the tissue it stimulates, where the literature is unambiguous about it; None where it is not, or where the class describes a family rather than a device.
- plot(annotate=False, autoscale=True, ax=None, stim=None, stim_cmap=False)[source]
Plot the device in its local coordinate frame.
Use
model.plot(show_implant=True)to show model-side placement.- Parameters:
annotate (bool, optional) – Whether to label electrodes.
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.
stim (
Stimulussource type, optional) –What is presented to the device. Prepared through
prepare_stim(), so the colors show what the electrodes actually deliver. Required bystim_cmap.Added in version 0.11.0.
stim_cmap (bool, str, or matplotlib colormap, optional) – If not false, the fill color of the plotted electrodes will vary based on maximum stimulus amplitude on each electrode. The chosen colormap will be used if provided
- Returns:
ax – Returns the axis object of the plot
- Return type:
matplotlib.axes.Axes
- prepare_stim(source)[source]
Turn a source into stimulation the implant can deliver.
Preparation applies preprocessing, converts the source to a
Stimulus, encodes dimensionless visual input when an encoder is present, reshapes it to the electrode array, removes deactivated electrodes, applies threshold calibration, and runs safety checks. The input is not modified and the result is not stored.Prepared stimuli use the implant’s
stimulus_unit(electrical current for most devices; irradiance for PRIMA).Images and videos require an encoder unless preprocessing already converts them to the implant’s
stimulus_unit.Added in version 0.11.0: Replaces the stateful
stimproperty.- Parameters:
source (
Stimulussource type) – Any source accepted byStimulus, including electrical stimulation and image or video input for the implant encoder.- Returns:
stim – Stimulation delivered by the implant, or None for an empty source.
- Return type:
Stimulusor None
Examples
>>> from pulse2percept.implants import DiskElectrode, Implant >>> from pulse2percept.stimuli import BiphasicPulse >>> implant = Implant(DiskElectrode(0, 0, 0, 100)) >>> stim = implant.prepare_stim(BiphasicPulse(30, 0.45))
Stimulate Electrode B7 in Argus II with 13 uA:
>>> from pulse2percept.implants.retina import ArgusII >>> stim = ArgusII().prepare_stim({'B7': 13})
Argus II includes an encoder, so it can prepare an image directly:
>>> from pulse2percept.stimuli import samples >>> ArgusII().prepare_stim(samples.logo_bvl()).unit uA
- preprocess_stim(stim)[source]
Preprocess the stimulus
This method is executed every time a stimulus is prepared.
No preprocessing is performed by default, but the user can define their own method in implants that inherit from return stim
Implant.A custom method must return a
Stimulusobject with the correct number of electrodes for the implant.
- property raster
Raster pattern used to schedule stimulation across electrodes.
Assigning a raster binds it to this implant.
- property scene_input_frame
Coordinate frame used to register scene input.
'eye'means gaze changes which scene content reaches the implant;'head'means scene input is fixed relative to the head.Defaults to
default_scene_input_frame. Setting toNonerestores that default.Added in version 0.11.0.
- technology = None
Stimulation technology, e.g.
'photovoltaic'. .. versionadded:: 0.11.0
- property thresholds
Perceptual threshold current (uA) for each electrode.
Assign a single current for the whole array, a per-electrode dict, or None to clear the calibration. Threshold-relative pulse trains are calibrated against whatever is in force at the moment
prepare_stim()runs.Added in version 0.10.0.
Changed in version 0.11.0: Changing thresholds affects the next stimulus prepared, rather than rewriting one the implant was holding.
- property eye
Implanted eye
A
RetinalImplantcan be implanted either in a left eye (‘left’) or right eye (‘right’). Models such asAxonMapModelwill treat left and right eyes differently (for example, adjusting the location of the optic disc).Examples
Implant Argus II in a left eye:
>>> from pulse2percept.implants.retina import ArgusII >>> implant = ArgusII(eye='left')