How to use the pulse2percept.electrode2currentmap.ElectrodeArray function in pulse2percept

To help you get started, we’ve selected a few pulse2percept examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pulse2percept / pulse2percept / scripts / Find_INL_NFL_weighting.py View on Github external
xlist=[]
ylist=[]
rlist=[] #electrode radius, microns
hlist=[] # lift of electrode from retinal surface, microns
e_spacing=525 # spacing in microns
for x in np.arange(-1, 1, e_spacing):  
    for y in np.arange(-1, 1, e_spacing):
        xlist.append(x)
        ylist.append(y)
        rlist.append(100) # electrode radiues
        hlist.append(0); #179.6) # electrode lift from retinal surface,      
        # epiretinal array - distance to the ganglion layer
        # subretinal array - distance to the bipolar layer
        # in Argus 1 179.6 is a good approx of height in a better patient
        
e_all = e2cm.ElectrodeArray(rlist,xlist,ylist,hlist, ptype='epiretinal') 
                
# create retina, input variables include the sampling and how much of the retina is simulated, in microns   
# (0,0 represents the fovea) 
retinaname='SmallL80S75WL500'
r = e2cm.Retina(axon_map=None,sampling=75, ylo=-500, yhi=500, xlo=-500, xhi=500, axon_lambda=8)     

# the effective current spread that incorporates axonal stimulation    
    
myout=[]
d=.1
fps=30
pt=[]
inl_out=[]
nfl_out=[]

modelver='Krishnan'
github pulse2percept / pulse2percept / scripts / SingleElectrode.py View on Github external
# only simulating the NFL
xlist=[]
ylist=[]
rlist=[] #electrode radius, microns
hlist=[] # lift of electrode from retinal surface, microns
e_spacing=525 # spacing in microns
for x in np.arange(-252, 500, e_spacing):  
    for y in np.arange(-252, 500, e_spacing):
        xlist.append(x)
        ylist.append(y)
        rlist.append(100) # electrode radiues
        hlist.append(0); #179.6) # electrode lift from retinal surface,      
        # epiretinal array - distance to the ganglion layer
        # subretinal array - distance to the bipolar layer
        # in Argus 1 179.6 is a good approx of height in a better patient
e_all = e2cm.ElectrodeArray(rlist,xlist,ylist,hlist, ptype='epiretinal') 

                
# create retina, input variables include the sampling and how much of the retina is simulated, in microns   
# (0,0 represents the fovea) 
retinaname='SmallL80S75WL500'
r = e2cm.Retina(axon_map=None,sampling=75, ylo=-500, yhi=500, xlo=-500, xhi=500, axon_lambda=8)     

# the effective current spread that incorporates axonal stimulation    
    
myout=[]
d=.1
fps=30
pt=[]
inl_out=[]
nfl_out=[]
github pulse2percept / pulse2percept / scripts / CalculateChronaxies.py View on Github external
xlist=[]
ylist=[]
rlist=[] #electrode radius, microns
hlist=[] # lift of electrode from retinal surface, microns
e_spacing=525 # spacing in microns
for x in np.arange(-1, 1, e_spacing):  
    for y in np.arange(-1, 1, e_spacing):
        xlist.append(x)
        ylist.append(y)
        rlist.append(100) # electrode radiues
        hlist.append(0); #179.6) # electrode lift from retinal surface,      
        # epiretinal array - distance to the ganglion layer
        # subretinal array - distance to the bipolar layer
        # in Argus 1 179.6 is a good approx of height in a better patient
        
e_all = e2cm.ElectrodeArray(rlist,xlist,ylist,hlist, ptype='epiretinal') 
                
# create retina, input variables include the sampling and how much of the retina is simulated, in microns   
# (0,0 represents the fovea) 
retinaname='SmallL80S75WL500'
r = e2cm.Retina(axon_map=None,sampling=75, ylo=-500, yhi=500, xlo=-500, xhi=500, axon_lambda=8)     

# the effective current spread that incorporates axonal stimulation    
    
myout=[]
d=.1
fps=30
pt=[]
inl_out=[]
nfl_out=[]

modelver='Krishnan'
github pulse2percept / pulse2percept / pulse2percept / electrode2currentmap.py View on Github external
xy = np.matmul(R, xy)
        x_arr = xy[0, :]
        y_arr = xy[1, :]

        # Apply offset
        x_arr += x_center
        y_arr += y_center

        self.etype = 'epiretinal'
        self.num_electrodes = len(names)
        self.electrodes = []
        for r, x, y, h, n in zip(r_arr, x_arr, y_arr, h_arr, names):
            self.electrodes.append(Electrode(self.etype, r, x, y, h, n))


class ArgusII(ElectrodeArray):

    def __init__(self, x_center=0, y_center=0, h=0, rot=0 * np.pi / 180):
        """Create an ArgusII array on the retina

        This function creates an ArgusII array and places it on the retina
        such that the center of the array is located at
        [`x_center`, `y_center`] (microns) and the array is rotated by
        rotation angle `rot` (radians).

        The array is oriented upright in the visual field, such that an
        array with center (0,0) has the top three rows lie in the lower
        retina (upper visual field), as shown below:

        .. raw:: html

          <pre></pre>
github pulse2percept / pulse2percept / pulse2percept / electrode2currentmap.py View on Github external
Returns
        -------
        A valid electrode index or None.
        """
        # Is `name` a valid electrode name?
        # Iterate through electrodes to find a matching name. Shuffle list
        # to reduce time complexity of average lookup.
        for idx, el in utils.traverse_randomly(enumerate(self.electrodes)):
            if el.name == name:
                return idx

        # Worst case O(n): name could not be found.
        return None


class ArgusI(ElectrodeArray):

    def __init__(self, x_center=0, y_center=0, h=0, rot=0 * np.pi / 180,
                 use_legacy_names=False):
        """Create an ArgusI array on the retina

        This function creates an ArgusI array and places it on the retina
        such that the center of the array is located at
        [`x_center`, `y_center`] (microns) and the array is rotated by
        rotation angle `rot` (radians).

        The array is oriented in the visual field as shown in Fig. 1 of
        Horsager et al. (2009); that is, if placed in (0,0), the top two
        rows will lie in the lower retina (upper visual field):

        .. raw:: html
github pulse2percept / pulse2percept / pulse2percept / effectivecurrent2brightness.py View on Github external
--------
    Stimulate a single-electrode array:

    >>> implant = e2cm.ElectrodeArray('subretinal', 0, 0, 0, 0)
    >>> stim = e2cm.Psycho2Pulsetrain(tsample=5e-6, freq=50, amp=20)
    >>> resp = pulse2percept(stim, implant)  # doctest: +SKIP

    Stimulate a single electrode ('C3') of an Argus I array centered on the
    fovea:

    >>> implant = e2cm.ArgusI()
    >>> stim = {'C3': e2cm.Psycho2Pulsetrain(tsample=5e-6, freq=50, amp=20)}
    >>> resp = pulse2percept(stim, implant)  # doctest: +SKIP
    """
    # Check type to avoid backwards compatibility issues
    if not isinstance(implant, e2cm.ElectrodeArray):
        raise TypeError("`implant` must be of type ec2b.ElectrodeArray")

    # Parse `stim` (either single pulse train or a list/dict of pulse trains),
    # and generate a list of pulse trains, one for each electrode
    pt_list = parse_pulse_trains(stim, implant)

    # Generate a standard temporal model if necessary
    if tm is None:
        tm = TemporalModel(pt_list[0].tsample)
    elif not isinstance(tm, TemporalModel):
        raise TypeError("`tm` must be of type ec2b.TemporalModel")

    # Generate a retina if necessary
    if retina is None:
        # Make sure implant fits on retina
        round_to = 500  # round to nearest (microns)