How to use the pulse2percept.implants.electrode_arrays.ElectrodeGrid 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 / pulse2percept / implants / prima.py View on Github external
def __init__(self, x=0, y=0, z=-100, rot=0, eye='RE', stim=None):
        # 85 um pixels with 15 um trenches, 28 um active electrode:
        self.trench = 15  # um
        self.spacing = 100  # um
        elec_radius = 14  # um
        # Roughly a 19x22 grid, but edges are trimmed off:
        self.shape = (19, 22)
        self.eye = eye

        # The user might provide a list of z values for each of the
        # 378 resulting electrodes, not for the 22x19 initial ones.
        # In this case, don't pass it to ElectrodeGrid, but overwrite
        # the z values later:
        overwrite_z = isinstance(z, (list, np.ndarray))
        zarr = -100 if overwrite_z else z
        self.earray = ElectrodeGrid(self.shape, self.spacing, x=x, y=y,
                                    z=zarr, rot=rot, type='hex',
                                    orientation='vertical',
                                    etype=PhotovoltaicPixel, r=elec_radius,
                                    a=(self.spacing - self.trench) / 2)

        # Remove extra electrodes to fit the actual implant:
        extra_elecs = ['A1', 'A2', 'A3', 'A4', 'A14', 'A16', 'A17',
                       'A18', 'A19', 'A20', 'A21', 'A22', 'B1',
                       'B2', 'B18', 'B19', 'B20', 'B21', 'B22',
                       'C1', 'C20', 'C21', 'C22', 'D22', 'E22', 'P1',
                       'Q1', 'Q22', 'R1', 'R2', 'R21', 'R22', 'S1',
                       'S2', 'S3', 'S5', 'S19', 'S20', 'S21', 'S22']
        for elec in extra_elecs:
            self.earray.remove_electrode(elec)

        # Adjust the z values:
github pulse2percept / pulse2percept / pulse2percept / implants / prima.py View on Github external
def __init__(self, x=0, y=0, z=-100, rot=0, eye='RE', stim=None):
        # 70 um pixels with 5 um trenches, 20 um active electrode:
        self.spacing = 75  # um
        self.trench = 5  # um
        elec_radius = 10  # um
        # Roughly a 12x15 grid, but edges are trimmed off:
        self.shape = (12, 15)
        self.eye = eye

        # The user might provide a list of z values for each of the
        # 378 resulting electrodes, not for the 22x19 initial ones.
        # In this case, don't pass it to ElectrodeGrid, but overwrite
        # the z values later:
        overwrite_z = isinstance(z, (list, np.ndarray))
        zarr = -100 if overwrite_z else z
        self.earray = ElectrodeGrid(self.shape, self.spacing, x=x, y=y,
                                    z=zarr, rot=rot, type='hex',
                                    orientation='vertical',
                                    etype=PhotovoltaicPixel, r=elec_radius,
                                    a=(self.spacing - self.trench) / 2)

        # Remove extra electrodes to fit the actual implant:
        extra_elecs = ['A1', 'B1', 'C1', 'D1', 'E1', 'I1', 'J1', 'K1', 'L1',
                       'A2', 'B2', 'C2', 'D2', 'K2', 'L2',
                       'A3', 'B3', 'L3',
                       'A4',
                       'A12',
                       'A13', 'K13', 'L13',
                       'A14', 'B14', 'C14', 'J14', 'K14', 'L14',
                       'A15', 'B15', 'C15', 'D15', 'H15', 'I15', 'J15', 'K15',
                       'L15']
        for elec in extra_elecs:
github pulse2percept / pulse2percept / pulse2percept / implants / alpha.py View on Github external
def __init__(self, x=0, y=0, z=0, rot=0, eye='RE', stim=None):
        self.eye = eye
        self.shape = (40, 40)
        elec_radius = 15.0
        e_spacing = 70.0  # um

        self.earray = ElectrodeGrid(self.shape, e_spacing, x=x, y=y, z=z,
                                    rot=rot, etype=DiskElectrode,
                                    r=elec_radius)

        # Beware of race condition: Stim must be set last, because it requires
        # indexing into self.electrodes:
        self.stim = stim

        # Set left/right eye:
        # Unfortunately, in the left eye the labeling of columns is reversed...
        if eye == 'LE':
            # FIXME: Would be better to have more flexibility in the naming
            # convention. This is a quick-and-dirty fix:
            names = list(self.earray.keys())
            objects = list(self.earray.values())
            names = np.array(names).reshape(self.earray.shape)
            # Reverse column names:
github pulse2percept / pulse2percept / pulse2percept / implants / argus.py View on Github external
def __init__(self, x=0, y=0, z=0, rot=0, eye='RE', stim=None,
                 use_legacy_names=False):
        self.eye = eye
        self.shape = (4, 4)
        r_arr = np.array([250, 500, 250, 500]) / 2.0
        r_arr = np.concatenate((r_arr, r_arr[::-1], r_arr, r_arr[::-1]),
                               axis=0)
        spacing = 800.0

        # In older papers, Argus I electrodes go by L and M:
        old_names = names = ['L6', 'L2', 'M8', 'M4',
                             'L5', 'L1', 'M7', 'M3',
                             'L8', 'L4', 'M6', 'M2',
                             'L7', 'L3', 'M5', 'M1']
        names = old_names if use_legacy_names else ('1', 'A')
        self.earray = ElectrodeGrid(self.shape, spacing, x=x, y=y, z=z,
                                    rot=rot, etype=DiskElectrode, r=r_arr,
                                    names=names)

        # Beware of race condition: Stim must be set last, because it requires
        # indexing into self.electrodes:
        self.stim = stim

        # Set left/right eye:
        if not isinstance(eye, str):
            raise TypeError("'eye' must be a string, either 'LE' or 'RE'.")
        if eye != 'LE' and eye != 'RE':
            raise ValueError("'eye' must be either 'LE' or 'RE'.")
        self.eye = eye
        # Unfortunately, in the left eye the labeling of columns is reversed...
        if eye == 'LE':
            # FIXME: Would be better to have more flexibility in the naming
github pulse2percept / pulse2percept / pulse2percept / implants / alpha.py View on Github external
def __init__(self, x=0, y=0, z=-100, rot=0, eye='RE', stim=None):
        self.eye = eye
        self.shape = (39, 39)
        elec_width = 50.0  # um
        e_spacing = 72.0  # um

        # The user might provide a list of z values for each of the
        # 378 resulting electrodes, not for the 22x19 initial ones.
        # In this case, don't pass it to ElectrodeGrid, but overwrite
        # the z values later:
        overwrite_z = isinstance(z, (list, np.ndarray))
        zarr = -100.0 if overwrite_z else z
        self.earray = ElectrodeGrid(self.shape, e_spacing, x=x, y=y, z=zarr,
                                    rot=rot, etype=SquareElectrode,
                                    a=elec_width)

        # Unfortunately, in the left eye the labeling of columns is reversed...
        if eye == 'LE':
            # FIXME: Would be better to have more flexibility in the naming
            # convention. This is a quick-and-dirty fix:
            names = list(self.earray.keys())
            objects = list(self.earray.values())
            names = np.array(names).reshape(self.earray.shape)
            # Reverse column names:
            for row in range(self.earray.shape[0]):
                names[row] = names[row][::-1]
            # Build a new ordered dict:
            electrodes = OrderedDict([])
            for name, obj in zip(names.ravel(), objects):
github pulse2percept / pulse2percept / pulse2percept / implants / prima.py View on Github external
def __init__(self, x=0, y=0, z=-100, rot=0, eye='RE', stim=None):
        # 50 um pixels with 5 um trenches, 16 um active electrode:
        self.spacing = 55  # um
        self.trench = 5
        elec_radius = 8  # um
        # Roughly a 18x21 grid, but edges are trimmed off:
        self.shape = (18, 21)
        self.eye = eye

        # The user might provide a list of z values for each of the
        # 378 resulting electrodes, not for the 22x19 initial ones.
        # In this case, don't pass it to ElectrodeGrid, but overwrite
        # the z values later:
        overwrite_z = isinstance(z, (list, np.ndarray))
        zarr = -100 if overwrite_z else z
        self.earray = ElectrodeGrid(self.shape, self.spacing, x=x, y=y,
                                    z=zarr, rot=rot, type='hex',
                                    orientation='vertical',
                                    etype=PhotovoltaicPixel, r=elec_radius,
                                    a=(self.spacing - self.trench) / 2)

        # Note that the exact shape of this implant is not known. We remove
        # all electrodes that don't fit on a circular 1mm x 1mm substrate:
        extra_elec = ['A1', 'A2', 'A3', 'A4', 'A5', 'A6', 'A7', 'A8', 'A9',
                      'A10', 'A12', 'A14', 'A15', 'A16', 'A17', 'A18', 'A19',
                      'A20', 'A21', 'B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B16',
                      'B17', 'B18', 'B19', 'B20', 'B21', 'C1', 'C2', 'C3',
                      'C4', 'C18', 'C19', 'C20', 'C21', 'D1', 'D2', 'D3', 'D4',
                      'D20', 'D21', 'E1', 'E2', 'E20', 'E21', 'F1', 'F2',
                      'F21', 'G1', 'G2', 'G21', 'H1', 'I1', 'J1', 'K1', 'L1',
                      'L21', 'M1', 'M2', 'M21', 'N1', 'N2', 'N21', 'O1', 'O2',
                      'O3', 'O20', 'O21', 'P1', 'P2', 'P3', 'P4', 'P19', 'P20',
github pulse2percept / pulse2percept / pulse2percept / implants / prima.py View on Github external
def __init__(self, x=0, y=0, z=-100, rot=0, eye='RE', stim=None):
        # 35 um pixels with 5 um trenches, 16 um active electrode:
        self.spacing = 40  # um
        self.trench = 5  # um
        elec_radius = 8  # um
        # Roughly a 25x28 grid, but edges are trimmed off:
        self.shape = (25, 28)
        self.eye = eye

        # The user might provide a list of z values for each of the
        # 378 resulting electrodes, not for the 22x19 initial ones.
        # In this case, don't pass it to ElectrodeGrid, but overwrite
        # the z values later:
        overwrite_z = isinstance(z, (list, np.ndarray))
        zarr = -100 if overwrite_z else z
        self.earray = ElectrodeGrid(self.shape, self.spacing, x=x, y=y,
                                    z=zarr, rot=rot, type='hex',
                                    orientation='vertical',
                                    etype=PhotovoltaicPixel, r=elec_radius,
                                    a=(self.spacing - self.trench) / 2)

        # Note that the exact shape of this implant is not known. We remove
        # all electrodes that don't fit on a circular 1mm x 1mm substrate:
        extra_elec = ['A1', 'A2', 'A3', 'A4', 'A5', 'A6', 'A7', 'A8', 'A9',
                      'A10', 'A11', 'A12', 'A14', 'A16', 'A17', 'A18', 'A19',
                      'A20', 'A21', 'A22', 'A23', 'A24', 'A25', 'A26', 'A27',
                      'A28', 'B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B8',
                      'B10', 'B20', 'B21', 'B22', 'B23', 'B24', 'B25', 'B26',
                      'B27', 'B28', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C22',
                      'C23', 'C24', 'C25', 'C26', 'C27', 'C28', 'D1', 'D2',
                      'D3', 'D4', 'D5', 'D24', 'D25', 'D26', 'D27', 'D28',
                      'E1', 'E2', 'E3', 'E4', 'E25', 'E26', 'E27', 'E28', 'F1',
github pulse2percept / pulse2percept / pulse2percept / implants / argus.py View on Github external
def __init__(self, x=0, y=0, z=0, rot=0, eye='RE', stim=None):
        self.shape = (6, 10)
        r = 225.0 / 2.0
        spacing = 575.0
        names = ('A', '1')
        self.earray = ElectrodeGrid(self.shape, spacing, x=x, y=y, z=z, r=r,
                                    rot=rot, names=names, etype=DiskElectrode)

        # Beware of race condition: Stim must be set last, because it requires
        # indexing into self.electrodes:
        self.stim = stim

        # Set left/right eye:
        if not isinstance(eye, str):
            raise TypeError("'eye' must be a string, either 'LE' or 'RE'.")
        if eye != 'LE' and eye != 'RE':
            raise ValueError("'eye' must be either 'LE' or 'RE'.")
        self.eye = eye
        # Unfortunately, in the left eye the labeling of columns is reversed...
        if eye == 'LE':
            # TODO: Would be better to have more flexibility in the naming
            # convention. This is a quick-and-dirty fix: