Exemple #1
0
def Li_recov_40_sum_stats(data):
    output = []
    sub_loop = 0

    d_split = data.split_periodic(tperiod_recov_40, adjust=True)

    for d in d_split[:
                     -1]:  # for no reason the last split contains no information

        dcond = d.trim(tpreMeasuringList1_recov_40[sub_loop],
                       tpreMeasuringList1_recov_40[sub_loop] +
                       tMeasuring1_recov_40,
                       adjust=True)
        dtest = d.trim_left(tpreMeasuring2_recov_40, adjust=True)

        current_cond = dcond['i_caL.i_Ca_L'][:-1]
        current_test = dtest['i_caL.i_Ca_L'][:-1]

        index_cond = np.argmax(np.abs(current_cond))
        index_test = np.argmax(np.abs(current_test))
        try:
            output = output + [
                current_test[index_test] / current_cond[index_cond]
            ]  # should I still normalize ?
            sub_loop += 1
        except:
            output = output + [float('inf')]
            sub_loop += 1

    return output
Exemple #2
0
def Li_iv_80_sum_stats(data):
    output = []
    for d in data.split_periodic(tperiod_iv_Li, adjust=True):
        d = d.trim_left(tpreMeasuring_iv_Li, adjust=True)
        current = d['i_caL.i_Ca_L'][:-1]  # the last value is sometimes a nan
        # (because V =0 at the end of the simulation and that I in nygren model is not defined for V = 0)
        output = output + [max(current, key=abs) - current[-1]]
    return output
Exemple #3
0
def Li_inact_kin_80_sum_stats(data):
    def double_exp(t, tauh, taus, Ah, As):
        return Ah * np.exp(-t / tauh) + As * np.exp(-t / taus)

    output = []
    ss_list = []

    for d in data.split_periodic(tperiod_kin_80_Li, adjust=True):

        d = d.trim_left(tpreMeasuring_kin_80_Li, adjust=True)
        #d = d.trim(tpreMeasuring_kin_80_Li,tpreMeasuring_kin_80_Li+2, adjust = True)

        current = d[
            'i_caL.i_Ca_L'][:
                            -1]  # sometimes, the last value is nan and crashes the following,
        # so getting rid of the last value is perhaps the solution
        time = d['environment.time'][:-1]
        index = np.argmax(np.abs(current))

        # Set time zero to peak current
        current = current[index:]
        time = time[index:]
        t0 = time[0]
        time = [t - t0 for t in time]

        with warnings.catch_warnings():
            warnings.simplefilter('error', OptimizeWarning)
            warnings.simplefilter('error', RuntimeWarning)
            try:
                imax = max(current, key=abs)
                current = [c_ / imax for c_ in current]

                if len(time) <= 1 or len(current) <= 1:
                    raise Exception('Failed simulation')
                popt, _ = so.curve_fit(double_exp,
                                       time,
                                       current,
                                       p0=[5, 1, 1, 1],
                                       bounds=([0.01, 0.01, 0.01,
                                                0.01], [100.0, 10, 10, 10]))

                tauh = min(popt[0], popt[1])
                taus = max(popt[0], popt[1])
                output = output + [tauh]
                ss_list = ss_list + [taus]

                #debug
#                plt.plot(time,current,time,double_exp(np.asarray(time), popt[0], popt[1], popt[2], popt[3]))
#                plt.show()
            except:
                output = output + [float('inf')]
                ss_list = ss_list + [float('inf')]

    output = output + ss_list
    return output
Exemple #4
0
def Li_inact_150_sum_stats(data):
    output = []
    for d in data.split_periodic(tperiod_inact_Li_150, adjust=True):
        d = d.trim_left(tpreMeasuring_inact_Li_150, adjust=True)
        inact_gate = d['i_caL.G_Na_norm']
        index = np.argmax(np.abs(inact_gate))
        output = output + [np.abs(inact_gate[index])]
    Norm = output[0]
    for i in range(len(output)):
        output[i] /= Norm
    return output