Ejemplo n.º 1
0
def loss(x):
    tau_facil, tau_rec, u0 = x
    # taus and u0 are collected for each iteration of loss func
    taus.append(x)
    output1hz = simulate(x[0], x[1], 1, x[2])[0]
    Hz1 = peaks[0]
    output10hz = simulate(x[0], x[1], 10, x[2])[0]
    Hz10 = peaks[1]
    output30hz = simulate(x[0], x[1], 30, x[2])[0]
    Hz30 = peaks[2]
    output50hz = simulate(x[0], x[1], 50, x[2])[0]
    Hz50 = peaks[3]

    mse1 = (np.square(output1hz - Hz1)).mean(axis=None)
    mse10 = (np.square(output10hz - Hz10)).mean(axis=None)
    mse30 = (np.square(output30hz - Hz30)).mean(axis=None)
    mse50 = (np.square(output50hz - Hz50)).mean(axis=None)
    mse = (mse1 + mse10 + mse30 + mse50) / 4

    return mse
Ejemplo n.º 2
0
def loss(x):
    tau_facil, tau_rec = x
    taus.append(x)
    u0 = 7.78641198e-02
    sampling = 0.5
    output1hz = simulate(x[0], x[1], 1, u0, sampling)[0]
    Hz1 = peaks[0]
    output10hz = simulate(x[0], x[1], 10, u0, sampling)[0]
    Hz10 = peaks[1]
    output30hz = simulate(x[0], x[1], 30, u0, sampling)[0]
    Hz30 = peaks[2]
    output50hz = simulate(x[0], x[1], 50, u0, sampling)[0]
    Hz50 = peaks[3]

    mse1 = (np.square(output1hz - Hz1)).mean(axis=None)
    mse10 = (np.square(output10hz - Hz10)).mean(axis=None)
    mse30 = (np.square(output30hz - Hz30)).mean(axis=None)
    mse50 = (np.square(output50hz - Hz50)).mean(axis=None)
    mse = (mse1 + mse10 + mse30 + mse50) / 4

    return mse
Ejemplo n.º 3
0
gcin_sem_10Hz = gcin_sem[1]
gcin_sem_30Hz = gcin_sem[2]
gcin_sem_50Hz = gcin_sem[3]

# Optimized values for tau facilitation, tau recovery and u0 respectively
x1 = np.array([4.11189527e+03, 8.78187450e-03, 8.05591091e-02])  # gc to in opt
x3 = np.array([3.82825788e+03, 3.23943913e+01, 7.80077153e-02])  # gc to mc opt
x0 = np.array([500, 0, 0.1])  # initial hand-tuned

'Plotting'

plt.rcParams.update({'errorbar.capsize': 2})
fig, axes = plt.subplots(2, 4, sharey=True)
a = np.arange(1, 11)

pre_1 = simulate(x0[0], x0[1], 1, x0[2])[0]
opt_1 = simulate(x1[0], x1[1], 1, x1[2])[0]
axes[0, 0].plot(a, pre_1, color='#1b9e77', marker='o', markersize=3)
axes[0, 0].plot(a, opt_1, color='#d95f02', marker='o', markersize=3)
axes[0, 0].errorbar(a,
                    gcmc_1Hz,
                    gcmc_sem_1Hz,
                    color='#7570b3',
                    marker='o',
                    markersize=3)
axes[0, 0].legend(("Initial", "Optimized ", "Data 1Hz"))

pre_10 = simulate(x0[0], x0[1], 10, x0[2])[0]
opt_10 = simulate(x1[0], x1[1], 10, x1[2])[0]
axes[0, 1].plot(a, pre_10, color='#1b9e77', marker='o', markersize=3)
axes[0, 1].plot(a, opt_10, color='#d95f02', marker='o', markersize=3)
Ejemplo n.º 4
0
gcmc_50Hz = np.convolve(gcmc_peaks[3], filt)

gcin_1Hz = np.convolve(gcin_peaks[0], filt)
gcin_10Hz = np.convolve(gcin_peaks[1], filt)
gcin_30Hz = np.convolve(gcin_peaks[2], filt)
gcin_50Hz = np.convolve(gcin_peaks[3], filt)

'Plotting'

# set_xlim was used to cut the interval we want
# HEX color codes were obtained from colorbrewer2.org website
# codes selected are quantiative and colorblindsafe

fig, axes = plt.subplots(2, 4, sharey=True)

pre_1 = simulate(x0[0], x0[1], 1, x0[2], 0.04975)[1]
opt_1 = simulate(x1[0], x1[1], 1, x1[2], 0.04975)[1]
axes[0, 0].plot(pre_1, color='#1b9e77', linewidth=1)
axes[0, 0].plot(opt_1, color='#d95f02', linewidth=1)
axes[0, 0].plot(gcmc_1Hz, color='#7570b3', linewidth=1)
axes[0, 0].legend(("Initial", "Optimized ", "Data 1Hz"))
axes[0, 0].set_xlim(0, 200000)

pre_10 = simulate(x0[0], x0[1], 10, x0[2], 0.05)[1]
opt_10 = simulate(x1[0], x1[1], 10, x1[2], 0.05)[1]
axes[0, 1].plot(pre_10, color='#1b9e77', linewidth=1)
axes[0, 1].plot(opt_10, color='#d95f02', linewidth=1)
axes[0, 1].plot(gcmc_10Hz, color='#7570b3', linewidth=1)
axes[0, 1].legend(("Initial", "Optimized ", "Data 10Hz"))
axes[0, 1].set_xlim(9000, 30000)