def run_WN(photoreceptor, I): Z_dictionary = {} V_dictionary = {} Vl_dictionary = {} I_dictionary = {} for i, V in enumerate(Vr): DepolarisePhotoreceptor.WithLight(photoreceptor, V) ## Filtering signal print("Processing V=", V, " mV") ## Run HH print("Running HH...") Vm, g = Experiment.inject_current(photoreceptor, I, dt) Vl = Linearise.inject_current(photoreceptor, I, dt) print("Variance of voltage is ", var(Vm), "mV2") ## Calculate impedance Vmm = (Vm - mean(Vm)) #without DC CPSD = zeros(round(len(time) / 2 + 1), dtype=complex_) PSD = zeros(round(len(time) / 2 + 1)) window = hamming(len(time)) print("len(window)", len(window)) for ii in range(repetitions): I_cut = I[ii * len(time):(ii + 1) * len(time)] V_cut = Vmm[ii * len(time):(ii + 1) * len(time)] PSD += power(absolute(rfft(I_cut * window)), 2) CPSD += rfft(V_cut * window) * rfft(I_cut * window).conjugate() Z = CPSD / PSD #MOhm Z_dictionary[V] = Z I_dictionary[V] = I[sample * len(time):(sample + 1) * len(time)] V_dictionary[V] = Vm[sample * len(time):(sample + 1) * len(time)] Vl_dictionary[V] = Vl[sample * len(time):(sample + 1) * len(time)] return (Z_dictionary, V_dictionary, Vl_dictionary, I_dictionary)
photoreceptor = Drone.Vallet92() DepolarisePhotoreceptor.WithLight(photoreceptor, V=V_membrane) fig1.text(0.06, 0.5, 'Membrane potential deflection (mV)', ha='center', va='center', rotation='vertical') for ii in range(5): for i, t in enumerate(time_array): if 10 <= t <= 110: I[i] = 1e-3 * (-0.02 + 0.01 * ii) # nA->uA DepolarisePhotoreceptor.WithLight(photoreceptor, V=V_membrane) V_array, g_Ch = Experiment.inject_current(photoreceptor, I, dt) ax_curr.plot(time_array, I, 'k') ax.plot(time_array, V_array - V_membrane, color='black') #mV ax.set_xticklabels([]) V_array = Linearise.inject_current(photoreceptor, I, dt) ax.plot(time_array, V_array, 'k--') #mV ax.set_xticklabels([]) V_membrane = -38 #mV photoreceptor = Drone.Vallet92(k_h=1) DepolarisePhotoreceptor.WithLight(photoreceptor, V=V_membrane) for ii in range(5): for i, t in enumerate(time_array): if 10 <= t <= 110: I[i] = 1e-3 * (-0.02 + 0.01 * ii) # nA->uA
V_membrane_ = [-68,-59,-41] #mV plot_window = array([-.5,3.5]) drosophila = FlyFactory.DrosophilaR16() fig1 = figure(1) T=200 #ms dt=0.5 #ms time_array = arange(0,T+dt,dt) I = zeros_like(time_array) for ii,V_membrane in enumerate(V_membrane_) : for i, t in enumerate(time_array): if 10 <= t <= 160: I[i] = 1e-3*(0.01) # nA->uA DepolarisePhotoreceptor.WithLight(drosophila, V = V_membrane) V_array, g_Ch = Experiment.inject_current(drosophila,I,dt) ax = fig1.add_subplot(3,1,ii+1) ax.plot(time_array, V_array,color='black') #mV #Experiment.unfreeze_conductances(drosophila) DepolarisePhotoreceptor.WithLight(drosophila, V = V_membrane) #To make sure that all channels are back at rest Experiment.freeze_inactivations(drosophila) V_array, g_Ch = Experiment.inject_current(drosophila,I,dt) Experiment.unfreeze_inactivations(drosophila) ax.plot(time_array, V_array,'k:') #mV DepolarisePhotoreceptor.WithLight(drosophila, V = V_membrane) #To make sure that all channels are back at rest Experiment.freeze_conductances(drosophila)