Note
Click here to download the full example code
Thompson et al. (2003): Circular phosphenesΒΆ
This example shows how to use the
Thompson2003Model
.
The model introduced in [Thompson2003] assumes that electrical stimulation leads to circular percepts with discrete gray levels. The model also allows for a fraction of phosphenes to be omitted at random (dropout rate).
The model can be loaded as follows (using 10% dropout rate):
import matplotlib.pyplot as plt
import numpy as np
import pulse2percept as p2p
model = p2p.models.Thompson2003Model(xystep=0.2, dropout=0.1)
model.build()
Thompson2003Model(dropout=0.1, engine=None,
grid_type='rectangular', n_gray=None,
n_jobs=1, n_threads=2, noise=None,
radius=None, retinotopy=Curcio1990Map,
scheduler='threading',
spatial=Thompson2003Spatial,
temporal=None, thresh_percept=0,
verbose=True, xrange=(-15, 15),
xystep=0.2, yrange=(-15, 15))
After building the model, we are ready to predict percepts.
Here we will use an ArgusII
implant.
One way to assign a stimulus is to pass a NumPy array with the same number of
elements as there are electrodes in the array (i.e., 60).
Choosing values from np.arange(60)
will assign a different number to
every electrode. We should thus expect to see 60 circular phosphenes that get
gradually brighter from one electrode to the next:
implant = p2p.implants.ArgusII(stim=np.arange(60))
percept = model.predict_percept(implant)
percept.plot()

<AxesSubplot:xlabel='x (degrees of visual angle)', ylabel='y (degrees of visual angle)'>
Setting a nonzero dropout rate will randomly choose a fraction of phosphenes to disappear:
fig, axes = plt.subplots(ncols=4, figsize=(15, 6))
for ax, drop in zip(axes, [0, 0.25, 0.5, 0.75]):
model.build(dropout=drop)
model.predict_percept(implant).plot(ax=ax)
ax.set_title(f"{100*drop}% dropout")
fig.tight_layout()

Finally, the model can also be applied to
VideoStimulus
objects, where every frame
of the video will be encoded with circular phosphenes and a given dropout
rate:
implant.stim = p2p.stimuli.BostonTrain()
model.build(dropout=0.2)
model.predict_percept(implant).play()
/home/docs/checkouts/readthedocs.org/user_builds/pulse2percept/envs/latest/lib/python3.7/site-packages/pulse2percept/stimuli/base.py:828: UserWarning: Time points must be strictly monotonically increasing: [233.5669, 200.2002, 166.8335, 133.4668, 300.3003, 266.9336, 100.1001, 467.1338, 400.4004, 433.7671, 367.0337, 333.667, 500.5005, 0.0, 33.3667, 66.7334, 3103.103, 3069.7363, 3036.3696, 3003.003, 2969.6362, 2936.2695, 2902.9028, 2869.5361, 2836.1694, 2802.8027, 2135.4688, 2769.436, 2669.336, 2235.5688, 2736.0693, 2702.7026, 2202.2021, 2635.9692, 2602.6025, 2569.2358, 2535.8691, 2502.5024, 2302.3022, 2268.9355, 2469.1357, 2435.769, 2335.669, 2402.4023, 567.2339, 533.8672, 600.6006, 2369.0356, 1634.9683, 1668.335, 1735.0684, 1701.7017, 2102.102, 1768.435, 1801.8018, 1835.1685, 1868.5352, 1601.6016, 1568.2349, 1534.8682, 1501.5015, 1468.1348, 1434.7681, 1401.4014, 1368.0347, 1334.668, 1267.9346, 1301.3013, 1234.5679, 1067.7344, 1201.2012, 1167.8345, 1101.1011, 1134.4678, 1001.001, 1034.3677, 967.6343, 1901.9019, 2068.7354, 633.9673, 934.2676, 2002.002, 2035.3687, 1968.6353, 1935.2686, 667.334, 900.9009, 700.7007, 734.0674, 834.1675, 867.5342, 767.4341, 800.8008]
warnings.warn(msg)