示例#1
0
 def datatypes(self, genotype):
     """Dict of Numpy data types for each Table in the HDF file."""
     li = self.li # save some typing
     ftype = dict(genotype=self.genotype.dtype, parameter=li.dtype.p, 
         convergence=[("period", np.int16), ("intervals", np.int16)], 
         steady=self.li.dtype.y, quiescent=self.li.dtype.y, 
         # Hacked by stepping through self.task(0), see comment there
         clamppheno=[(k, float) for k in 
             "i_Na_tau_m40 i_Na_tau_m20 i_Na_tau_0 i_Na_tau_20 i_Na_tau_40 "
             "i_CaL_tau_m40 i_CaL_tau_m20 i_CaL_tau_0 i_CaL_tau_20 "
             "i_CaL_tau_40 i_CaL_vg_max_m90 i_CaL_vg_thalf_m90 "
             "i_CaL_vg_max_m80 i_CaL_vg_thalf_m80 i_CaL_vg_max_m70 "
             "i_CaL_vg_thalf_m70".split()],
         timing=[(k, float) for k in 
             "waiting started finished error seconds attempts".split()])
     ftype["raw"] = [(k, float, self.raw_nap * self.raw_nthin) 
         for k in ("t",) + li.dtype.y.names + li.dtype.a.names]
     
     # Ion-current phenotypes: a few phenotypes for many variables.
     # Make one array per phenotype, with one column per variable.
     
     # Get field names for current phenotypes
     with li.autorestore():
         t, y, stats = li.ap_plain()
     curph = current_phenotypes_array(t, y.V)
     for k in curph.dtype.names:
         ftype[k] = [(i, float) for i in li.dtype.y.names + li.dtype.a.names]
     ap_stats = ap_cvode.ap_stats_array(stats)
     # Action potential and calcium transient statistics, including time 
     # to recovery.
     ftype["ap_stats"] = [(k, typ, self.raw_nap) for k, typ in eval(str(ap_stats.dtype))]
     return ftype
示例#2
0
 def thin_aps(self, aps, nthin, par):
     """Thin action potentials to "nthin" points."""
     t = np.concatenate([ti[thin(len(ti), nthin)] for ti, yi, si in aps])
     t = t - t[0]
     y = np.concatenate([yi[thin(len(ti), nthin)] for ti, yi, si in aps])
     rates, a = self.li.rates_and_algebraic(t, y, par)
     ap_stats = np.zeros(1, dtype=self.ftype["ap_stats"])
     stats = np.concatenate([ap_cvode.ap_stats_array(si) for ti, yi, si in aps])
     for k in stats.dtype.names:
         ap_stats[k] = stats[k].squeeze()
     raw = np.zeros(1, dtype=self.ftype["raw"])
     raw["t"] = t
     for k in y.dtype.names:
         raw[k] = y[k].squeeze()
     for k in a.dtype.names:
         raw[k] = a[k].squeeze()
     return raw, ap_stats