pulse2percept

First steps

  • Overview
  • Installation
  • Example Gallery

Basic concepts

  • Visual Prostheses
  • Cortical Visual Prostheses
  • Electrical Stimuli
  • Computational Models
  • Datasets

User Guide

  • API Reference
    • pulse2percept.implants
      • pulse2percept.implants.cortex
        • pulse2percept.implants.cortex.orion
        • pulse2percept.implants.cortex.cortivis
        • pulse2percept.implants.cortex.icvp
        • pulse2percept.implants.cortex.neuralink
        • Orion
        • Cortivis
        • ICVP
        • EllipsoidElectrode
        • NeuralinkThread
        • LinearEdgeThread
        • Neuralink
      • pulse2percept.implants.base
      • pulse2percept.implants.electrodes
      • pulse2percept.implants.electrode_arrays
      • pulse2percept.implants.argus
      • pulse2percept.implants.alpha
      • pulse2percept.implants.bvt
      • pulse2percept.implants.imie
      • pulse2percept.implants.prima
      • pulse2percept.implants.ensemble
      • AlphaAMS
      • AlphaIMS
      • ArgusI
      • ArgusII
      • BVT24
      • BVT44
      • DiskElectrode
      • Electrode
      • ElectrodeArray
      • ElectrodeGrid
      • EnsembleImplant
      • HexElectrode
      • PhotovoltaicPixel
      • PointSource
      • PRIMA
      • PRIMA75
      • PRIMA55
      • PRIMA40
      • ProsthesisSystem
      • RectangleImplant
      • SquareElectrode
      • IMIE
    • pulse2percept.stimuli
    • pulse2percept.models
    • pulse2percept.percepts
    • pulse2percept.datasets
    • pulse2percept.viz
    • pulse2percept.utils
    • pulse2percept.topography
  • Frequently Asked Questions
  • In the News
  • Release Notes
  • References

Developer Guide

  • Contributing to pulse2percept
  • Coding Style Guide
  • Preparing a New Release
pulse2percept
  • API Reference
  • pulse2percept.implants
  • pulse2percept.implants.cortex
  • pulse2percept.implants.cortex.neuralink
  • View page source

pulse2percept.implants.cortex.neuralink

EllipsoidElectrode, LinearEdgeThread, NeuralinkThread

Classes

EllipsoidElectrode([x, y, z, rx, ry, rz, ...])

LinearEdgeThread([x, y, z, orient, ...])

Neuralink(threads[, stim, preprocess, safe_mode])

NeuralinkThread(earray[, stim, eye, ...])

Base class for Neuralink threads

class pulse2percept.implants.cortex.neuralink.EllipsoidElectrode(x=0, y=0, z=0, rx=7, ry=7, rz=12, orient=array([0, 0, 1]), orient_mode='direction', name=None, activated=True)[source]
plot3D(ax=None, **kwargs)[source]

Plot the electrode in 3D space

Parameters:

ax (matplotlib.axes.Axes) – Axes to plot on. If None, a new figure and axes will be created.

plot(autoscale=False, ax=None)[source]

Plot

Parameters:
  • autoscale (bool, optional) – Whether to adjust the x,y limits of the plot

  • ax (matplotlib.axes._subplots.AxesSubplot, optional) – A Matplotlib axes object. If None given, a new one will be created.

Returns:

ax – Returns the axis object of the plot

Return type:

matplotlib.axes.Axes

class pulse2percept.implants.cortex.neuralink.NeuralinkThread(earray, stim=None, eye='RE', preprocess=False, safe_mode=False)[source]

Base class for Neuralink threads

check_stim(stim)[source]

Quality-check the stimulus

This method is executed every time a new value is assigned to stim.

If safe_mode is set to True, this function will only allow stimuli that are charge-balanced.

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

Parameters:

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

property earray

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 prosthesis system object, e.g. implant['A1'] or implant[0].

property eye

Implanted eye

A ProsthesisSystem can be implanted either in a left eye (‘LE’) or right eye (‘RE’). Models such as AxonMapModel will 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 import ArgusII
>>> implant = ArgusII(eye='LE')
property n_electrodes

Number of electrodes in the array

This is equivalent to calling earray.n_electrodes.

plot(annotate=False, autoscale=True, ax=None, stim_cmap=False)[source]

Plot

Parameters:
  • annotate (bool, optional) – Whether to scale the axes view to the data

  • 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_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

preprocess_stim(stim)[source]

Preprocess the stimulus

This methods is executed every time a new value is assigned to stim.

No preprocessing is performed by default, but the user can define their own method in implants that inherit from return stim ProsthesisSystem.

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 stim

Stimulus

A stimulus can be created from many source types, such as scalars, NumPy arrays, and dictionaries (see Stimulus for a complete list).

A stimulus can be assigned either in the ProsthesisSystem constructor or later by assigning a value to stim.

Note

Unless when using dictionary notation, the number of stimuli must equal the number of electrodes in earray.

Examples

Send a biphasic pulse (30uA, 0.45ms phase duration) to an implant made from a single DiskElectrode:

>>> from pulse2percept.implants import DiskElectrode, ProsthesisSystem
>>> from pulse2percept.stimuli import BiphasicPulse
>>> implant = ProsthesisSystem(DiskElectrode(0, 0, 0, 100))
>>> implant.stim = BiphasicPulse(30, 0.45)

Stimulate Electrode B7 in Argus II with 13 uA:

>>> from pulse2percept.implants import ArgusII
>>> implant = ArgusII(stim={'B7': 13})
class pulse2percept.implants.cortex.neuralink.LinearEdgeThread(x=0, y=0, z=0, orient=array([0, 0, 1]), orient_mode='direction', r=5, n_elecs=32, spacing=50, insertion_depth=0, electrode=<class 'pulse2percept.implants.cortex.neuralink.EllipsoidElectrode'>, stim=None, preprocess=False, safe_mode=False)[source]
property earray

Electrode array

property stim

Stimulus

A stimulus can be created from many source types, such as scalars, NumPy arrays, and dictionaries (see Stimulus for a complete list).

A stimulus can be assigned either in the ProsthesisSystem constructor or later by assigning a value to stim.

Note

Unless when using dictionary notation, the number of stimuli must equal the number of electrodes in earray.

Examples

Send a biphasic pulse (30uA, 0.45ms phase duration) to an implant made from a single DiskElectrode:

>>> from pulse2percept.implants import DiskElectrode, ProsthesisSystem
>>> from pulse2percept.stimuli import BiphasicPulse
>>> implant = ProsthesisSystem(DiskElectrode(0, 0, 0, 100))
>>> implant.stim = BiphasicPulse(30, 0.45)

Stimulate Electrode B7 in Argus II with 13 uA:

>>> from pulse2percept.implants import ArgusII
>>> implant = ArgusII(stim={'B7': 13})
plot3D(ax=None, **kwargs)[source]

Plot the thread in 3D space

Parameters:

ax (matplotlib.axes.Axes) – Axes to plot on. If None, a new figure and axes will be created.

check_stim(stim)[source]

Quality-check the stimulus

This method is executed every time a new value is assigned to stim.

If safe_mode is set to True, this function will only allow stimuli that are charge-balanced.

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

Parameters:

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

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 prosthesis system object, e.g. implant['A1'] or implant[0].

property eye

Implanted eye

A ProsthesisSystem can be implanted either in a left eye (‘LE’) or right eye (‘RE’). Models such as AxonMapModel will 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 import ArgusII
>>> implant = ArgusII(eye='LE')
property n_electrodes

Number of electrodes in the array

This is equivalent to calling earray.n_electrodes.

plot(annotate=False, autoscale=True, ax=None, stim_cmap=False)[source]

Plot

Parameters:
  • annotate (bool, optional) – Whether to scale the axes view to the data

  • 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_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

preprocess_stim(stim)[source]

Preprocess the stimulus

This methods is executed every time a new value is assigned to stim.

No preprocessing is performed by default, but the user can define their own method in implants that inherit from return stim ProsthesisSystem.

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

class pulse2percept.implants.cortex.neuralink.Neuralink(threads, stim=None, preprocess=False, safe_mode=False)[source]
classmethod from_neuropythy(vfmap, locs=None, xrange=None, yrange=None, xystep=None, rand_insertion_angle=None, region='v1', Thread=<class 'pulse2percept.implants.cortex.neuralink.LinearEdgeThread'>)[source]

Create a Neuralink implant [Musk2019] from a neuropythy visual field map.

The implant will be created by creating a NeuralinkThread for each visual field location specified either by locs or by xrange, yrange, and xystep. Each thread will be inserted perpendicular to the cortical surface at the corresponding location in cortex, with up to rand_insertion_angle degrees of azimuthal rotation.

Parameters:
  • vfmap (p2p.topography.NeuropythyMap) – Visual field map to create implant from.

  • locs (np.ndarray with shape (n, 2), optional) – Array of visual field locations to create threads at. Not needed if using xrange, yrange, and xystep.

  • xrange (tuple of floats, optional) – Range of x and y coordinates to create threads at.

  • yrange (tuple of floats, optional) – Range of x and y coordinates to create threads at.

  • xystep (float, optional) – Spacing between threads.

  • rand_insertion_angle (float, optional) – If not none, insert threads at a random offset from perpendicular, with a maximum azimuthal rotation of rand_insertion_angle degrees.

  • region (str, optional) – Region of cortex to create implant in.

  • Thread (NeuralinkThread, optional) – Thread class to use for the implant. Must accept x, y, z, and orient parameters.

Returns:

Neuralink – Neuralink ensemble implant created from the visual field map.

Return type:

p2p.implants.Neuralink

classmethod from_cortical_map(implant_type, vfmap, locs=None, xrange=None, yrange=None, xystep=None, region='v1')[source]

Override of parent class from cortical map method. Uses from_neuropythy instead of from_cortical_map if the provided vfmap is a NeuropythyMap.

Parameters:
  • implant_type (p2p.implants.ProsthesisSystem) – Type of implant to create. Currently only NeuralinkThread is supported.

  • vfmap (p2p.topography.CorticalMap) – Cortical map to create implant from.

  • locs (np.ndarray with shape (n, 2), optional) – Array of visual field locations to create threads at. Not needed if using xrange, yrange, and xystep.

  • xrange (tuple of floats, optional) – Range of x and y coordinates to create threads at.

  • yrange (tuple of floats, optional) – Range of x and y coordinates to create threads at.

  • xystep (float, optional) – Spacing between threads.

  • region (str, optional) – Region of cortex to create implant in.

Returns:

Neuralink – Neuralink ensemble implant created from the visual field map.

Return type:

p2p.implants.Neuralink

plot3D(ax=None, **kwargs)[source]

Plot the implant in 3D space

Parameters:

ax (matplotlib.axes.Axes) – Axes to plot on. If None, a new figure and axes will be created.

check_stim(stim)[source]

Quality-check the stimulus

This method is executed every time a new value is assigned to stim.

If safe_mode is set to True, this function will only allow stimuli that are charge-balanced.

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

Parameters:

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

property earray

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 prosthesis system object, e.g. implant['A1'] or implant[0].

property eye

Implanted eye

A ProsthesisSystem can be implanted either in a left eye (‘LE’) or right eye (‘RE’). Models such as AxonMapModel will 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 import ArgusII
>>> implant = ArgusII(eye='LE')
classmethod from_coords(implant_type, locs=None, xrange=None, yrange=None, xystep=None)[source]

Create an ensemble implant using physical (cortical or retinal) coordinates.

Parameters:
  • implant_type (type) – The type of implant to create for the ensemble.

  • locs (np.ndarray with shape (n, 2), optional) – Array of physical locations (um) to create implants at. Not needed if using xrange, yrange, and xystep.

  • xrange (tuple of floats, optional) – Range of x and y coordinates to create implants at.

  • yrange (tuple of floats, optional) – Range of x and y coordinates to create implants at.

  • xystep (float, optional) – Spacing between implant centers.

property implants

Dict of implants

merge_stimuli()[source]

Constructs the combined stimulus for all implants in self._implants

property n_electrodes

Number of electrodes in the array

This is equivalent to calling earray.n_electrodes.

plot(annotate=False, autoscale=True, ax=None, stim_cmap=False)[source]

Plot

Parameters:
  • annotate (bool, optional) – Whether to scale the axes view to the data

  • 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_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

preprocess_stim(stim)[source]

Preprocess the stimulus

This methods is executed every time a new value is assigned to stim.

No preprocessing is performed by default, but the user can define their own method in implants that inherit from return stim ProsthesisSystem.

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 stim

Stimulus

A stimulus can be created from many source types, such as scalars, NumPy arrays, and dictionaries (see Stimulus for a complete list).

A stimulus can be assigned either in the ProsthesisSystem constructor or later by assigning a value to stim.

Note

Unless when using dictionary notation, the number of stimuli must equal the number of electrodes in earray.

Examples

Send a biphasic pulse (30uA, 0.45ms phase duration) to an implant made from a single DiskElectrode:

>>> from pulse2percept.implants import DiskElectrode, ProsthesisSystem
>>> from pulse2percept.stimuli import BiphasicPulse
>>> implant = ProsthesisSystem(DiskElectrode(0, 0, 0, 100))
>>> implant.stim = BiphasicPulse(30, 0.45)

Stimulate Electrode B7 in Argus II with 13 uA:

>>> from pulse2percept.implants import ArgusII
>>> implant = ArgusII(stim={'B7': 13})
Previous Next

© Copyright 2016 - 2025, pulse2percept developers.

Built with Sphinx using a theme provided by Read the Docs.