def main(args=None): """Main""" vs = [(v - 100) * 0.001 for v in range(200)] for f in ['IM.channel.nml', 'Kd.channel.nml']: nml_doc = pynml.read_neuroml2_file(f) for ct in nml_doc.ComponentType: ys = [] for v in vs: req_variables = {'v': '%sV' % v, 'vShift': '10mV'} vals = pynml.evaluate_component(ct, req_variables=req_variables) print(vals) if 'x' in vals: ys.append(vals['x']) if 't' in vals: ys.append(vals['t']) if 'r' in vals: ys.append(vals['r']) ax = pynml.generate_plot([vs], [ys], "Some traces from %s in %s" % (ct.name, f), show_plot_already=False) print(vals) plt.show()
def main(args=None): """Main""" vs = [(v-100)*0.001 for v in range(200)] for f in ['IM.channel.nml','Kd.channel.nml']: nml_doc = pynml.read_neuroml2_file(f) for ct in nml_doc.ComponentType: ys = [] for v in vs: req_variables = {'v':'%sV'%v,'vShift':'10mV'} vals = pynml.evaluate_component(ct,req_variables=req_variables) print vals if 'x' in vals: ys.append(vals['x']) if 't' in vals: ys.append(vals['t']) if 'r' in vals: ys.append(vals['r']) ax = pynml.generate_plot([vs],[ys], "Some traces from %s in %s"%(ct.name,f), show_plot_already=False ) print vals plt.show()
def calculateRateFn(self, ratefn, vmin, vmax, tablen=3000, vShift='0mV'): """Returns A / B table from ngate.""" tab = np.linspace(vmin, vmax, tablen) if self._is_standard_nml_rate(ratefn): midpoint, rate, scale = map( SI, (ratefn.midpoint, ratefn.rate, ratefn.scale)) return self.rate_fn_map[ratefn.type](tab, rate, scale, midpoint) else: for ct in self.doc.ComponentType: if ratefn.type == ct.name: mu.info("Using %s to evaluate rate" % ct.name) rate = [] for v in tab: vals = pynml.evaluate_component( ct, req_variables={ 'v': '%sV' % v, 'vShift': vShift, 'temperature': self._getTemperature() }) '''mu.info vals''' if 'x' in vals: rate.append(vals['x']) if 't' in vals: rate.append(vals['t']) if 'r' in vals: rate.append(vals['r']) return np.array(rate)
def calculateRateFn(self, ratefn, vmin, vmax, tablen=3000, vShift='0mV'): """Returns A / B table from ngate.""" from . import hhfit rate_fn_map = { 'HHExpRate': hhfit.exponential2, 'HHSigmoidRate': hhfit.sigmoid2, 'HHSigmoidVariable': hhfit.sigmoid2, 'HHExpLinearRate': hhfit.linoid2 } tab = np.linspace(vmin, vmax, tablen) if self._is_standard_nml_rate(ratefn): midpoint, rate, scale = map( SI, (ratefn.midpoint, ratefn.rate, ratefn.scale)) return rate_fn_map[ratefn.type](tab, rate, scale, midpoint) for ct in self.doc.ComponentType: if ratefn.type != ct.name: continue logger_.info("Using %s to evaluate rate" % ct.name) rate = [] for v in tab: # Note: MOOSE HHGate are either voltage of concentration # dependant. Here we figure out if nml description of gate is # concentration dependant or note. if _isConcDep(ct): # Concentration dependant. Concentration can't be negative. # Find a suitable CaConc from the /library. Currently on Ca # dependant channels are allowed. caConcName = _findCaConcVariableName() req_vars = { caConcName: '%g' % max(0, v), 'vShift': vShift, 'temperature': self._getTemperature() } else: req_vars = { 'v': '%sV' % v, 'vShift': vShift, 'temperature': self._getTemperature() } req_vars.update(self._variables) vals = pynml.evaluate_component(ct, req_variables=req_vars) v = vals.get('x', vals.get('t', vals.get('r', None))) if v is not None: rate.append(v) return np.array(rate) print("[WARN ] Could not determine rate: %s %s %s" % (ratefn.type, vmin, vmax)) return np.array([])
def calculateRateFn(self, ratefn, vmin, vmax, tablen=3000, vShift='0mV'): """Returns A / B table from ngate.""" tab = np.linspace(vmin, vmax, tablen) if self._is_standard_nml_rate(ratefn): midpoint, rate, scale = map(SI, (ratefn.midpoint, ratefn.rate, ratefn.scale)) return self.rate_fn_map[ratefn.type](tab, rate, scale, midpoint) else: for ct in self.doc.ComponentType: if ratefn.type == ct.name: print("Using %s to evaluate rate"%ct.name) rate = [] for v in tab: vals = pynml.evaluate_component(ct,req_variables={'v':'%sV'%v,'vShift':vShift,'temperature':self._getTemperature()}) '''print vals''' if 'x' in vals: rate.append(vals['x']) if 't' in vals: rate.append(vals['t']) if 'r' in vals: rate.append(vals['r']) return np.array(rate)