pulse2percept.implants.cortex.orion
Classes
|
Create a Orion array |
- class pulse2percept.implants.cortex.orion.Orion(preprocess=False, safe_mode=False, hemisphere=None)[source]
Create a Orion array
Electrode coordinates are device-local, with the base centered at
(0, 0).Orion contains 60 electrodes in a hex shaped grid inspired by Argus II.
Note
Implant the array with the model’s
implant_position, e.g.implant_position=(20, -5) * mmfor 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_positionplaces.
Examples
Create an Orion array in its own coordinate frame:
>>> from pulse2percept.implants.cortex import Orion >>> Orion() Orion(electrode_array=ElectrodeGrid, preprocess=False, safe_mode=False, shape=(10, 7))
Get access to electrode ‘96’:
>>> orion = Orion() >>> orion['96'] DiskElectrode(activated=True, name='96', radius=1000.0, x=-11550.0, y=-9640.928378532848, z=0.0)
- placement = 'epicortical'
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_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_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.
- 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.