def importChannelsToCell(self, nmlcell, moosecell, membrane_properties): sg_to_segments = self._cell_to_sg[nmlcell.id] for chdens in membrane_properties.channel_densities + membrane_properties.channel_density_v_shifts: segments = getSegments(nmlcell, chdens, sg_to_segments) condDensity = SI(chdens.cond_density) erev = SI(chdens.erev) try: ionChannel = self.id_to_ionChannel[chdens.ion_channel] except KeyError: logger_.info('No channel with id: %s' % chdens.ion_channel) continue if self.verbose: logger_.info( 'Setting density of channel %s in %s to %s; erev=%s (passive: %s)' % (chdens.id, segments, condDensity, erev, self.isPassiveChan(ionChannel))) if self.isPassiveChan(ionChannel): for seg in segments: # comp = self.nml_to_moose[seg] setRm(self.nml_to_moose[seg.id], condDensity) setEk(self.nml_to_moose[seg.id], erev) else: for seg in segments: self.copyChannel(chdens, self.nml_to_moose[seg.id], condDensity, erev) '''moose.le(self.nml_to_moose[seg])
def _getTemperature(self): if self.network is not None: if self.network.type == "networkWithTemperature": return SI(self.network.temperature) else: # Why not, if there's no temp dependence in nml..? return 0 return SI('25')
def importInputs(self, doc): epath = '%s/inputs' % (self.lib.path) if moose.exists(epath): minputs = moose.element(epath) else: minputs = moose.Neutral(epath) for pg_nml in doc.pulse_generators: epath = '%s/%s' % (minputs.path, pg_nml.id) pg = moose.element(epath) if moose.exists( epath) else moose.PulseGen(epath) pg.firstDelay = SI(pg_nml.delay) pg.firstWidth = SI(pg_nml.duration) pg.firstLevel = SI(pg_nml.amplitude) pg.secondDelay = 1e9
def importAxialResistance(self, nmlcell, intracellularProperties): sg_to_segments = self._cell_to_sg[nmlcell.id] for r in intracellularProperties.resistivities: segments = getSegments(nmlcell, r, sg_to_segments) for seg in segments: comp = self.nml_to_moose[seg.id] setRa(comp, SI(r.value))
def importInitMembPotential(self, nmlcell, moosecell, membraneProperties): sg_to_segments = self._cell_to_sg[nmlcell.id] for imp in membraneProperties.init_memb_potentials: initv = SI(imp.value) for seg in sg_to_segments[imp.segment_groups]: comp = self.nml_to_moose[seg.id] comp.initVm = initv
def importCapacitances(self, nmlcell, moosecell, specificCapacitances): sg_to_segments = self._cell_to_sg[nmlcell.id] for specific_cm in specificCapacitances: cm = SI(specific_cm.value) for seg in sg_to_segments[specific_cm.segment_groups]: comp = self.nml_to_moose[seg.id] comp.Cm = sarea(comp) * cm
def createDecayingPoolConcentrationModel(self, concModel): """Create prototype for concentration model""" if hasattr(concModel, 'name') and concModel.name is not None: name = concModel.name else: name = concModel.id ca = moose.CaConc('%s/%s' % (self.lib.path, name)) ca.CaBasal = SI(concModel.resting_conc) ca.tau = SI(concModel.decay_constant) ca.thick = SI(concModel.shell_thickness) ca.B = 5.2e-6 # B = 5.2e-6/(Ad) where A is the area of the # shell and d is thickness - must divide by # shell volume when copying self.proto_pools[concModel.id] = ca self.nml_to_moose[name] = ca self.moose_to_nml[ca] = concModel logger_.debug('Created moose element: %s for nml conc %s' % (ca.path, concModel.id))
def createHHChannel(self, chan, vmin=-150e-3, vmax=100e-3, vdivs=5000): mchan = moose.HHChannel('%s/%s' % (self.lib.path, chan.id)) mgates = [ moose.element(x) for x in [mchan.gateX, mchan.gateY, mchan.gateZ] ] assert len(chan.gate_hh_rates ) <= 3, "We handle only up to 3 gates in HHCHannel" if self.verbose: logger_.info('== Creating channel: %s (%s) -> %s (%s)' % (chan.id, chan.gate_hh_rates, mchan, mgates)) all_gates = chan.gates + chan.gate_hh_rates # Sort all_gates such that they come in x, y, z order. all_gates = _gates_sorted(all_gates) for ngate, mgate in zip(all_gates, mgates): if ngate is None: continue if mgate.name.endswith('X'): mchan.Xpower = ngate.instances elif mgate.name.endswith('Y'): mchan.Ypower = ngate.instances elif mgate.name.endswith('Z'): mchan.Zpower = ngate.instances mgate.min = vmin mgate.max = vmax mgate.divs = vdivs # I saw only examples of GateHHRates in # HH-channels, the meaning of forwardRate and # reverseRate and steadyState are not clear in the # classes GateHHRatesInf, GateHHRatesTau and in # FateHHTauInf the meaning of timeCourse and # steady state is not obvious. Is the last one # refering to tau_inf and m_inf?? fwd = ngate.forward_rate rev = ngate.reverse_rate self.paths_to_chan_elements[ '%s/%s' % (chan.id, ngate.id)] = '%s/%s' % (chan.id, mgate.name) q10_scale = 1 if ngate.q10_settings: if ngate.q10_settings.type == 'q10Fixed': q10_scale = float(ngate.q10_settings.fixed_q10) elif ngate.q10_settings.type == 'q10ExpTemp': q10_scale = math.pow( float(ngate.q10_settings.q10_factor), (self._getTemperature() - SI(ngate.q10_settings.experimental_temp)) / 10) else: raise Exception( 'Unknown Q10 scaling type %s: %s' % (ngate.q10_settings.type, ngate.q10_settings)) logger_.debug( '+ Gate: %s; %s; %s; %s; %s; scale=%s' % (ngate.id, mgate.path, mchan.Xpower, fwd, rev, q10_scale)) if (fwd is not None) and (rev is not None): alpha = self.calculateRateFn(fwd, vmin, vmax, vdivs) beta = self.calculateRateFn(rev, vmin, vmax, vdivs) mgate.tableA = q10_scale * (alpha) mgate.tableB = q10_scale * (alpha + beta) # Assuming the meaning of the elements in GateHHTauInf ... if hasattr(ngate,'time_course') and hasattr(ngate,'steady_state') \ and (ngate.time_course is not None) and (ngate.steady_state is not None): tau = ngate.time_course inf = ngate.steady_state tau = self.calculateRateFn(tau, vmin, vmax, vdivs) inf = self.calculateRateFn(inf, vmin, vmax, vdivs) mgate.tableA = q10_scale * (inf / tau) mgate.tableB = q10_scale * (1 / tau) if hasattr(ngate, 'steady_state') and ( ngate.time_course is None) and (ngate.steady_state is not None): inf = ngate.steady_state tau = 1 / (alpha + beta) if inf is not None: inf = self.calculateRateFn(inf, vmin, vmax, vdivs) if len(inf) > 0: mgate.tableA = q10_scale * (inf / tau) mgate.tableB = q10_scale * (1 / tau) logger_.info('%s: Created %s for %s' % (self.filename, mchan.path, chan.id)) return mchan