Esempio n. 1
0
                              index=data.index,
                              dtype=float)
data['img_y_dva'] = pd.Series([(-22.5, 22.5)] * len(data),
                              index=data.index,
                              dtype=float)

###############################################################################
# Passing both ``data`` and ``argus`` to
# :py:func:`~pulse2percept.viz.plot_argus_phosphenes` will then allow the
# function to overlay the phosphene drawings over a schematic of the implant.
# Here, phosphene drawings from different trials are averaged, and aligned with
# the center of the electrode that was used to obtain the drawing:

from pulse2percept.viz import plot_argus_phosphenes

plot_argus_phosphenes(data, argus)

###############################################################################
# Great! We have just reproduced a panel from Figure 2 in [Beyeler2019]_.
#
# As [Beyeler2019]_ went on to show, the orientation of these phosphenes is
# well aligned with the map of nerve fiber bundles (NFBs) in each subject's
# eye.
#
# To see how the phosphene drawings line up with the NFBs, we can also pass an
# :py:class:`~pulse2percept.models.AxonMapModel` to the function.
# Of course, we need to make sure that we use the correct dimensions. Subject
# S2 had their optic disc center located 14 deg nasally, 2.4 deg superior from
# the fovea:

from pulse2percept.models import AxonMapModel
Esempio n. 2
0
argus = ArgusII(x=-1331, y=-850, rot=-28.4, eye='RE')

###############################################################################
# For now, let's focus on the data from Subject 2:

data = fetch_beyeler2019(subjects='S2')

###############################################################################
# Passing both ``data`` and ``argus`` to
# :py:func:`~pulse2percept.viz.plot_argus_phosphenes` will then allow the
# function to overlay the phosphene drawings over a schematic of the implant.
# Here, phosphene drawings from different trials are averaged, and aligned with
# the center of the electrode that was used to obtain the drawing:

from pulse2percept.viz import plot_argus_phosphenes
plot_argus_phosphenes(data, argus)

###############################################################################
# Great! We have just reproduced a panel from Figure 2 in [Beyeler2019]_.
#
# As [Beyeler2019]_ went on to show, the orientation of these phosphenes is
# well aligned with the map of nerve fiber bundles (NFBs) in each subject's
# eye.
#
# To see how the phosphene drawings line up with the NFBs, we can also pass an
# :py:class:`~pulse2percept.models.AxonMapModel` to the function.
# Of course, we need to make sure that we use the correct dimensions. Subject
# S2 had their optic disc center located 16.2 deg nasally, 1.38 deg superior
# from the fovea:

from pulse2percept.models import AxonMapModel
Esempio n. 3
0
def test_plot_argus_phosphenes():
    df = pd.DataFrame([
        {
            'subject': 'S1',
            'electrode': 'A1',
            'image': np.random.rand(10, 10),
            'img_x_dva': (-10, 10),
            'img_y_dva': (-10, 10)
        },
        {
            'subject': 'S1',
            'electrode': 'B2',
            'image': np.random.rand(10, 10),
            'img_x_dva': (-10, 10),
            'img_y_dva': (-10, 10)
        },
    ])
    _, ax = plt.subplots()
    plot_argus_phosphenes(df, ArgusI(), ax=ax)
    plot_argus_phosphenes(df, ArgusII(), ax=ax)

    # Add axon map:
    _, ax = plt.subplots()
    plot_argus_phosphenes(df, ArgusI(), ax=ax, axon_map=AxonMapModel())

    # Data must be a DataFrame:
    with pytest.raises(TypeError):
        plot_argus_phosphenes(np.ones(10), ArgusI())
    # DataFrame must have the required columns:
    with pytest.raises(ValueError):
        plot_argus_phosphenes(pd.DataFrame(), ArgusI())
    # Subjects must all be the same:
    with pytest.raises(ValueError):
        dff = pd.DataFrame([{'subject': 'S1'}, {'subject': 'S2'}])
        plot_argus_phosphenes(dff, ArgusI())
    # Works only for Argus:
    with pytest.raises(TypeError):
        plot_argus_phosphenes(df, AlphaAMS())
Esempio n. 4
0
def test_plot_argus_phosphenes():
    df = pd.DataFrame([
        {
            'subject': 'S1',
            'electrode': 'A1',
            'image': np.random.rand(10, 10),
            'xrange': (-10, 10),
            'yrange': (-10, 10)
        },
        {
            'subject': 'S1',
            'electrode': 'B2',
            'image': np.random.rand(10, 10),
            'xrange': (-10, 10),
            'yrange': (-10, 10)
        },
    ])
    _, ax = plt.subplots()
    plot_argus_phosphenes(df, ArgusI(), ax=ax)
    plot_argus_phosphenes(df, ArgusII(), ax=ax)

    # Add axon map:
    _, ax = plt.subplots()
    plot_argus_phosphenes(df, ArgusI(), ax=ax, axon_map=AxonMapModel())

    # Data must be a DataFrame:
    with pytest.raises(TypeError):
        plot_argus_phosphenes(np.ones(10), ArgusI())
    # DataFrame must have the required columns:
    with pytest.raises(ValueError):
        plot_argus_phosphenes(pd.DataFrame(), ArgusI())
    # Subjects must all be the same:
    with pytest.raises(ValueError):
        dff = pd.DataFrame([{'subject': 'S1'}, {'subject': 'S2'}])
        plot_argus_phosphenes(dff, ArgusI())
    # Works only for Argus:
    with pytest.raises(TypeError):
        plot_argus_phosphenes(df, AlphaAMS())
    # Works only for axon maps:
    with pytest.raises(TypeError):
        plot_argus_phosphenes(df, ArgusI(), ax=ax, axon_map=ScoreboardModel())
    # Manual subject selection
    plot_argus_phosphenes(df[df.electrode == 'B2'], ArgusI(), ax=ax)
    # If no implant given, dataframe must have additional columns:
    with pytest.raises(ValueError):
        plot_argus_phosphenes(df, ax=ax)
    df['implant_type_str'] = 'ArgusII'
    df['implant_x'] = 0
    df['implant_y'] = 0
    df['implant_rot'] = 0
    plot_argus_phosphenes(df, ax=ax)