Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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'
#for d in [.1, .2, .45, .75, 1., 2., 4., 8., 16., 32.]:
tm = ec2b.TemporalModel()
rsample=int(np.round((1/tm.tsample) / 60 )) # resampling of the output to fps
# at 0 off the retinal surface a 0.45 pulse in the nfl gives a response of 1
[ecs, cs] = r.electrode_ecs(e_all)
inl_amp = []
nfl_amp = []
for pd in [.01, .02, .04, .08, .16, .32, .64, 1.28, 2.56, 5.12, 10.24, 20.48]:
xamp=120
dolayer='INL'
tmp=minimize(findampval, xamp, args=(ecs, r, rsample, 'INL', ))
inl_amp.append(tmp.x)
print(pd)
print('minimized inl layer')
print(tmp.x)
dolayer='NFL'
def comparenflinl(ll, ecs, retina, pt_inl, pt_nfl, rsample, dolayer, engine='joblib', dojit=True, n_jobs=-1, tol=.05):
tm = ec2b.TemporalModel(lweight=ll)
inl_r = ec2b.pulse2percept(tm, ecs,r, pt_inl, rsample=rsample, dolayer='INL', dojit=False, engine='serial')
nfl_r = ec2b.pulse2percept(tm, ecs, r, pt_nfl, rsample=rsample, dolayer='NFL', dojit=False, engine='serial')
print(ll)
print(np.max(inl_r.data))
print(np.max(nfl_r.data))
return (np.max(10*inl_r.data)-np.max(10*nfl_r.data)) ** 2
>>> 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)
cspread = 500 # expected current spread (microns)
xs = [a.x_center for a in implant]
ys = [a.y_center for a in implant]
xlo = np.floor((np.min(xs) - cspread) / round_to) * round_to
xhi = np.ceil((np.max(xs) + cspread) / round_to) * round_to
ylo = np.floor((np.min(ys) - cspread) / round_to) * round_to
yhi = np.ceil((np.max(ys) + cspread) / round_to) * round_to
retina = e2cm.Retina(xlo=xlo, xhi=xhi, ylo=ylo, yhi=yhi,
save_data=False)
elif not isinstance(retina, e2cm.Retina):
# (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'
tm = ec2b.TemporalModel(lweight= (1 / (3.16 * (10 ** 6))))
#for d in [.1, .2, .45, .75, 1., 2., 4., 8., 16., 32.]:
scFac = 2.41 * (10**3)
# at 0 off the retinal surface a 0.45 pulse in the nfl gives a response of 1
for d in [.1, .45, 1. ,2. ,4., 8., 16.]:
[ecs, cs] = r.electrode_ecs(e_all)
rsample=int(np.round((1/tm.tsample) / 30 )) # resampling of the output to fps
pt=e2cm.Psycho2Pulsetrain(tsample=tm.tsample, current_amplitude=100, dur=.6, pulse_dur=d/1000.,interphase_dur=.45/1000, freq=2)
if modelver=='Krishnan':
ca = tm.tsample * np.cumsum(np.maximum(0, pt.data))
pt.data = pt.data - ca
inl_r = ec2b.pulse2percept(temporal_model=tm, ecs=ecs, retina=r,
ptrain=[pt], rsample=rsample, dolayer='INL', dojit=False, engine='serial')
inl_out.append(np.max(inl_r.data) * scFac)
nfl_r = ec2b.pulse2percept(temporal_model=tm, ecs=ecs, retina=r,
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'
#for d in [.1, .2, .45, .75, 1., 2., 4., 8., 16., 32.]:
tm = ec2b.TemporalModel()
rsample=int(np.round((1/tm.tsample) / 60 )) # resampling of the output to fps
# at 0 off the retinal surface a 0.45 pulse in the nfl gives a response of 1
[ecs, cs] = r.electrode_ecs(e_all)
pt_01=e2cm.Psycho2Pulsetrain(tsample=tm.tsample, current_amplitude=120,dur=.6, delay=10/1000, pulse_dur=.1/1000.,interphase_dur=10/1000, freq=2)
pt_2=e2cm.Psycho2Pulsetrain(tsample=tm.tsample, current_amplitude=120, dur=.6, delay=10/1000, pulse_dur=2/1000.,interphase_dur=10/1000, freq=2)
#def pulse2percept(tm, ecs, retina, ptrain, rsample, dolayer,
# engine='joblib', dojit=True, n_jobs=-1, tol=.05):
#inl_r = ec2b.pulse2percept(tm, ecs, r, [pt_2], rsample=rsample, dolayer='INL', dojit=False, engine='serial')
#
comparenflinl(.636, ecs, r, [pt_2], [pt_01], rsample, False, 'serial')
#myout=minimize(comparenflinl, x0, args=(ecs, r, [pt_2], [pt_01], rsample, False, 'serial', ))
>>> 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)
cspread = 500 # expected current spread (microns)
xs = [a.x_center for a in implant]
ys = [a.y_center for a in implant]
xlo = np.floor((np.min(xs) - cspread) / round_to) * round_to
xhi = np.ceil((np.max(xs) + cspread) / round_to) * round_to
ylo = np.floor((np.min(ys) - cspread) / round_to) * round_to
yhi = np.ceil((np.max(ys) + cspread) / round_to) * round_to
retina = e2cm.Retina(xlo=xlo, xhi=xhi, ylo=ylo, yhi=yhi,
save_data=False)