Electrical Stimuli¶
The Stimulus object defines a common
interface for all electrical stimuli.
It provides a 2-D data array with labeled axes, where rows denote electrodes
and columns denote points in time.
Stimuli can be assigned to electrodes of a
ProsthesisSystem object, who will deliver
them to the retina.
A stimulus can be created from a variety of source types, such as the following:
- Scalar value: interpreted as the current amplitude delivered to a single electrode (no time component).
- NumPy array:
- Nx1 array: interpreted as N current amplitudes delivered to N electrodes (no time component).
- NxM array: interpreted as N electrodes each receiving M current amplitudes in time.
TimeSeries: interpreted as the stimulus in time for a single electrode (e.g.,PulseTrain).
In addition, you can also pass a collection of source types (e.g., list, dictionary).
See the Stimulus API documentation for a
full list.
Note
Depending on the source type, a stimulus might have a time component or not.
Single-electrode stimuli¶
The easiest way to create a stimulus is to specify the current amplitude (uA) to be delivered to an electrode:
In [1]: from pulse2percept.stimuli import Stimulus
# Stimulate an unnamed electrode with -14uA:
In [2]: Stimulus(-14)
Out[2]:
Stimulus(data=[[-14.]], electrodes=[0], metadata=None,
shape=(1, 1), time=None)
You can also specify the name of the electrode to be stimulated:
# Stimulate Electrode 'B7' with -14uA:
In [3]: Stimulus(-14, electrodes='B7')
Out[3]:
Stimulus(data=[[-14.]], electrodes=['B7'], metadata=None,
shape=(1, 1), time=None)
By default, this stimulus will not have a time component
(stim.time is None).
Some models, such as
ScoreboardModel, cannot handle stimuli in
time.
To create stimuli in time, you can pass a
TimeSeries object, such as a
BiphasicPulse or a
PulseTrain:
# Stimulate Electrode 'A001' with a cathodic-first 20Hz pulse train
# with 10uA amplitude, lasting for 0.5s, sampled at 0.1ms:
In [4]: from pulse2percept.stimuli import PulseTrain
In [5]: pt = PulseTrain(0.0001, freq=20, amp=10, dur=0.5)
In [6]: stim = Stimulus(pt)
In [7]: stim
Out[7]:
Stimulus(data=[[-10. -10. ... 0. 0.]], electrodes=[0],
metadata=None, shape=(1, 5000),
time=[0.e+00 1.e-04 ... 5.e-01 5.e-01])
# This stimulus has a time component:
In [8]: stim.time