pulse2percept.implants.cortex.icvp

ICVP

Classes

ICVP([preprocess, safe_mode, hemisphere])

Create an ICVP array

class pulse2percept.implants.cortex.icvp.ICVP(preprocess=False, safe_mode=False, hemisphere=None)[source]

Create an ICVP array

Electrode coordinates are device-local, with the base centered at (0, 0).

ICVP (Intracortical Visual Prosthesis Project) is an electrode array containing 16 Parylene-insulated (and 2 uninsulated reference and counter) iridium shaft electrodes in a 4 column array with 400 um spacing [Troyk2003]. The electrodes have a diameter of 15 um at the laser cut. They are inserted either 650 um or 850 um into the cortex.

Note

Implant the array with the model’s implant_position, e.g. implant_position=(20, -5) * mm for the right hemisphere.

Parameters:
  • preprocess (bool or callable, optional) – Either True/False to indicate whether to execute the implant’s default preprocessing method whenever a stimulus is prepared, or a custom function (callable).

  • safe_mode (bool, optional) – If safe mode is enabled, only charge-balanced stimuli are allowed.

  • hemisphere ('left', 'right' or None, optional) – Which hemisphere the device is implanted in. Metadata: it does not move the array, which the model’s implant_position places.

Examples

Create an ICVP array in its own coordinate frame:

>>> from pulse2percept.implants.cortex import Orion
>>> ICVP()
ICVP(electrode_array=ElectrodeGrid, preprocess=False,
     safe_mode=False, shape=(5, 4))

Get access to electrode ‘11’:

>>> icvp = ICVP()
>>> icvp['11']
DiskElectrode(activated=True, name='11', radius=50.0,
              x=173.2050807568877, y=100.0, z=-650.0)
placement = 'intracortical'

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.

property hemisphere

Implanted hemisphere

‘left’, ‘right’, or None if unspecified. Metadata: cortical models place the array from its coordinates and their own implant_position, not from this attribute.

property electrode_array

Electrode array

check_stim(stim)[source]

Quality-check the stimulus

This method is executed every time a stimulus is prepared (see prepare_stim()).

If safe_mode is set to True, this function will only allow stimuli that are charge-balanced. If max_current is 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 DimensionMismatchError on one. In the ordinary flow this cannot happen: prepare_stim() has already checked the stimulus against stimulus_unit. check_stim is public, though, and may be handed anything.

The user can define their own checks in implants that inherit from Implant.

Parameters:

stim (Stimulus source type) – A valid source type for the Stimulus object (e.g., scalar, NumPy array, pulse train).

Raises:
  • DimensionMismatchError – If an electrical check was requested and stim is 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_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'] or implant[0], and ask how many there are with len(implant).

property encoder

Stimulus encoder used for image or video input.

Must be an ImplantEncoder. Model-aware encoders such as TraceEncoder are 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.

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 (Stimulus source type, optional) –

    What is presented to the device. Prepared through prepare_stim(), so the colors show what the electrodes actually deliver. Required by stim_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 stim property.

Parameters:

source (Stimulus source type) – Any source accepted by Stimulus, 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:

Stimulus or 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 Stimulus object with the correct number of electrodes for the implant.

Parameters:

stim (Stimulus source type) – A valid source type for the Stimulus object (e.g., scalar, NumPy array, pulse train).

Returns:

stim_out

Return type:

Stimulus object

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 to None restores that default.

Added in version 0.11.0.

stimulus_unit = uA[source]

Unit used by prepared stimuli. Defaults to electrical current.

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.