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
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, ptrain=[pt], rsample=rsample, dolayer='NFL', dojit=False, engine='serial') nfl_out.append(np.max(nfl_r.data) * scFac) #plt.plot(pt.data)
del M, img # create pulsetrain corresponding to the movie pt = [] for rf in e_rf: rflum = e2cm.retinalmovie2electrodtimeseries(rf, movie) ptrain = e2cm.Movie2Pulsetrain(rflum) # plt.plot(rflum) plt.plot(pt[ct].data) plt.plot(ptrain.data) pt.append(ptrain) del movie rsample = ( 1 / fps ) * pt[0].tsample # factor by which movies resampled for presentation boom brightness_movie = ec2b.pulse2percept(tm, ecs, r, pt, rsample) # FILTERING BY ON OFF CELLS # foveal vision is ~60 cpd. 293μm on the retina corresponds to 1 degree, so the smallest receptive field probably covers 293/60 ~=5μm, # we set the largest as being 10 times bigger than that numbers roughly based on # Field GD & Chichilnisky EJ (2007) Information processing in the primate retina: circuitry and coding. Annual Review of Neuroscience 30:1-30 # Chose 30 different sizes fairly randomly retinasizes = np.unique( np.ceil(np.array(np.linspace(5, 50, 15)) / r.sampling)) retinasizes = np.array([i for i in retinasizes if i >= 2]) [onmovie, offmovie] = ec2b.onoffFiltering(brightness_movie.data, retinasizes) [normalmovie, prostheticmovie] = ec2b.onoffRecombine(onmovie, offmovie) # save the various movies
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, ptrain=[pt], rsample=rsample, dolayer='NFL', dojit=False, engine='serial') nfl_out.append(np.max(nfl_r.data) * scFac) #plt.plot(pt.data) #myout.append(tmp)
def findampval(amp, ecs, retina, rsample, whichlayer): pt=e2cm.Psycho2Pulsetrain(tsample=tm.tsample, current_amplitude=amp,dur=.6, delay=10/1000, pulse_dur=pd / 1000,interphase_dur=10/1000, freq=2) resp = ec2b.pulse2percept(tm, ecs,r, [pt], rsample=rsample, dolayer=whichlayer, dojit=True, engine='serial') return (( (np.max(resp.data)*1000) - 67.89) ** 2)