Exemplo n.º 1
0
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)
Exemplo n.º 2
0
    ax.text(-0.12,
            1.02,
            label,
            transform=ax.transAxes,
            fontsize=14,
            va='top',
            ha='right')

ax_bw_gain, ax_cost_bw, ax_cost_gain = axes

## Only the values in Vr to plot fat circles

for i, V in enumerate(Vr):
    label_str = str(V) + ' mV'
    photoreceptor = FlyFactory.DrosophilaR16(shift="none")
    DepolarisePhotoreceptor.WithLight(photoreceptor, V=V)

    Z_cut = photoreceptor.body.impedance(
        f_from_medium
    )  #Only frequencies above f_medium, to calculate bandwidth
    gain_max_r[N, i] = max(
        abs(photoreceptor.body.voltage_contrast_gain(f_from_medium)))
    Bandwidth_r[N, i] = Calculate_Bandwidth(Z_cut, f_from_medium)
    Cost_r[N, i] = photoreceptor.energy_consumption() * delta_cost

    if gain_max_r[N, i] > epsilon:
        #ax_gain_vs_bw.plot(gain_max_r[N, i], Bandwidth_r[N, i], colour_graph[i] + '.', markersize=15)
        #ax_cost_vs_gbwp.plot(Cost_r[N, i], gain_max_r[N, i] * Bandwidth_r[N, i], colour_graph[i] + '.', markersize=15)
        ax_bw_gain.plot(gain_max_r[N, i],
                        Bandwidth_r[N, i],
                        colour_graph[i] + '.',
Exemplo n.º 3
0
colour_graph = ['y', 'b', 'g', 'r', 'c']
Bandwidth = zeros_like(Vr)
Bandwidth_fixed = zeros_like(Vr)
gain_max = zeros_like(Vr)
gain_max_fixed = zeros_like(Vr)

gain_bandwidth_product = zeros_like(Vr)
gain_bandwidth_product_fixed = zeros_like(Vr)

HH_RC = []

for i, V in enumerate(Vr):

    label_str = str(V) + ' mV'

    DepolarisePhotoreceptor.WithLight(HH, V)

    gain_max[i], Bandwidth[i] = Gain_Bandwidth(HH.body.voltage_contrast_gain,
                                               f_min=f_medium)
    gain = abs(HH.body.voltage_contrast_gain(f))
    gain_bandwidth_product[i] = gain_max[i] * Bandwidth[i]

    Experiment.freeze_conductances(HH)

    gain_max_fixed[i], Bandwidth_fixed[i] = Gain_Bandwidth(
        HH.body.voltage_contrast_gain, f_min=f_medium)
    gain_fixed = abs(HH.body.voltage_contrast_gain(f))
    gain_bandwidth_product_fixed[i] = gain_max_fixed[i] * Bandwidth_fixed[i]

    Experiment.unfreeze_conductances(HH)
Exemplo n.º 4
0
fig2 = figure(5, figsize=[9, 5])
ax_Z = fig2.add_subplot(1, 3, 1)
ax_bw = fig2.add_subplot(2, 3, 3)
ax_cost = fig2.add_subplot(2, 3, 6)
ax_Z_V_low = fig2.add_subplot(2, 3, 2)
ax_Z_V_medium = fig2.add_subplot(2, 3, 5)

###### CONTINUOUS ACROSS VOLTAGES
Vr = arange(-70.0, -30.0, 0.5)
Z_array = zeros(len(Vr))
Z_fixed_array = zeros(len(Vr))
total_resistance_array = zeros_like(Vr)
total_K_conductance = zeros_like(Vr)
for i, V in enumerate(Vr):  #Impedances at lowest frequency
    if depolarise_with_light:
        DepolarisePhotoreceptor.WithLight(HH, V)
    else:
        DepolarisePhotoreceptor.WithCurrent(HH, V)
    Z_array[i] = abs(HH.body.impedance(f_low))
    Experiment.freeze_conductances(HH)
    Z_fixed_array[i] = abs(HH.body.impedance(f_low))
    Experiment.unfreeze_conductances(HH)
    total_resistance_array[i] = HH.body.resistance()
    total_K_conductance[i] = HH.body.total_K_conductance()

ax_Z_V_low.plot(Vr,
                Z_array / 1000,
                'k',
                linewidth=2,
                label="Fixed conductances")
ax_Z_V_low.plot(Vr,
Exemplo n.º 5
0
T = 300  #ms
dt = 0.05  #ms
time_array = arange(0, T + dt, dt)
I = zeros_like(time_array)

fig1 = plt.figure(1)
ax = fig1.add_subplot(211)
ax_t = fig1.add_subplot(212)

fig2 = plt.figure(2)
ax_curr = fig2.add_subplot(211)

V_membrane = -38  #mV
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')
Exemplo n.º 6
0
option = 1 # 1:Compare with full conductance freeze, 2: Compare with inactivation freeze

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