def basicRxD3D(): from neuron import h, rxd s = h.Section(name='s') s.L = s.diam = 1 cyt = rxd.Region([s]) ca = rxd.Species(cyt) rxd.set_solve_type(dimension=3) h.finitialize(-65) h.fadvance() return 1
def neuron_instance(neuron_import): """Sets/Resets the rxd test environment. Provides 'data', a dictionary used to store voltages and rxd node values for comparisons with the 'correct_data'. """ h, rxd, save_path = neuron_import data = {'record_count': 0, 'data': []} h.load_file('stdrun.hoc') h.nrnunit_use_legacy(True) # pytest fixtures at the function scope that require neuron_instance will go # out of scope after neuron_instance. So species, sections, etc. will go # out of scope after neuron_instance is torn down. # Here we assert that no section left alive. If the assertion fails it is # due to a problem with the previous test, not the test which failed. gc.collect() for sec in h.allsec(): assert (False) cvode = h.CVode() cvode.active(False) cvode.atol(1e-3) h.dt = 0.025 h.stoprun = False def gather(): return collect_data(h, rxd, data, save_path) cvode.extra_scatter_gather(0, gather) yield (h, rxd, data) for r in rxd.rxd._all_reactions[:]: if r(): rxd.rxd._unregister_reaction(r) for s in rxd.species._all_species: if s(): s().__del__() rxd.region._all_regions = [] rxd.region._region_count = 0 rxd.region._c_region_lookup = None rxd.species._species_counts = 0 rxd.section1d._purge_cptrs() rxd.initializer.has_initialized = False rxd.rxd.free_conc_ptrs() rxd.rxd.free_curr_ptrs() rxd.rxd.rxd_include_node_flux1D(0, None, None, None) rxd.species._has_1d = False rxd.species._has_3d = False rxd.rxd._zero_volume_indices = numpy.ndarray(0, dtype=numpy.int_) rxd.set_solve_type(dimension=1) cvode.extra_scatter_gather_remove(gather)
def neuron_instance(neuron_import): """Sets/Resets the rxd test environment. Provides 'data', a dictionary used to store voltages and rxd node values for comparisons with the 'correct_data'. """ h, rxd = neuron_import data = {'record_count': 0, 'data': []} h.load_file('stdrun.hoc') cvode = h.CVode() cvode.active(False) cvode.atol(1e-3) h.dt = 0.025 h.stoprun = False def gather(): return collect_data(h, rxd, data) cvode.extra_scatter_gather(0, gather) yield (h, rxd, data) rxd.region._all_regions = [] rxd.region._region_count = 0 rxd.region._c_region_lookup = None for r in rxd.rxd._all_reactions[:]: if r(): rxd.rxd._unregister_reaction(r) for s in rxd.species._all_species: if s(): s().__del__() rxd.species._species_counts = 0 rxd.section1d._rxd_sec_lookup = {} rxd.section1d._purge_cptrs() rxd.initializer.has_initialized = False rxd.rxd.free_conc_ptrs() rxd.rxd.free_curr_ptrs() rxd.rxd.rxd_include_node_flux1D(0, None, None, None) for sec in h.allsec(): h.disconnect(sec=sec) sref = h.SectionRef(sec=sec) sref.rename('delete') h.delete_section(sec=sec) rxd.species._has_1d = False rxd.species._has_3d = False rxd.rxd._memb_cur_ptrs = [] rxd.rxd._rxd_induced_currents = None rxd.rxd._curr_indices = None rxd.rxd._zero_volume_indices = numpy.ndarray(0, dtype=numpy.int_) rxd.set_solve_type(dimension=1) cvode.extra_scatter_gather_remove(gather)
def neuron_nosave_instance(neuron_import): """Sets/Resets the rxd test environment.""" h, rxd, save_path = neuron_import h.load_file("stdrun.hoc") h.load_file("import3d.hoc") h.nrnunit_use_legacy(True) # pytest fixtures at the function scope that require neuron_instance will go # out of scope after neuron_instance. So species, sections, etc. will go # out of scope after neuron_instance is torn down. # Here we assert that no section left alive. If the assertion fails it is # due to a problem with the previous test, not the test which failed. gc.collect() for sec in h.allsec(): assert False cvode = h.CVode() cvode.active(False) cvode.atol(1e-3) h.dt = 0.025 h.stoprun = False yield (h, rxd, save_path) for r in rxd.rxd._all_reactions[:]: if r(): rxd.rxd._unregister_reaction(r) for s in rxd.species._all_species: if s(): s().__del__() rxd.region._all_regions = [] rxd.region._region_count = 0 rxd.region._c_region_lookup = None rxd.species._species_counts = 0 rxd.section1d._purge_cptrs() rxd.initializer.has_initialized = False rxd.rxd.free_conc_ptrs() rxd.rxd.free_curr_ptrs() rxd.rxd.rxd_include_node_flux1D(0, None, None, None) rxd.species._has_1d = False rxd.species._has_3d = False rxd.rxd._zero_volume_indices = numpy.ndarray(0, dtype=numpy.int_) rxd.set_solve_type(dimension=1)
def setnsubseg(): global mGLURRWM if nsubseg > 0: print 'setting rxd nsubseg to ', dconf['nsubseg'] rxd.set_solve_type(nsubseg=dconf['nsubseg']) mGLURRWM /= float(nsubseg) print 'adjusted mGLURRWM to ', mGLURRWM elif subsegum > 0.0: for sec in cell.all_sec: ns = int(sec.L / subsegum) if ns > 1: if ns % 2 == 0: ns += 1 print 'L = ', sec.L, ' subseg = ', ns rxd.set_solve_type(sec, nsubseg=ns) if sec == cell.Adend3: mGLURRWM /= float(ns) print 'adjusted mGLURRWM to ', mGLURRWM else: print 'L = ', sec.L, ' not using subseg' rxd.options.subseg_interpolation = 1 rxd.options.subseg_averaging = 1
from neuron import h, rxd h.load_file("stdrun.hoc") sec = h.Section(name="sec") sec.L = 10 sec.nseg = 11 sec.diam = 5 rxd.set_solve_type(dimension=3) cyt = rxd.Region(h.allsec(), name="cyt", nrn_region="i") ip3 = rxd.Species(cyt, name="ip3", initial=lambda nd: 1000 if nd.segment == sec(0.3) else 0) def callbackfun(): return 1000 for nd in ip3.nodes(sec(0.1)): nd.include_flux(1000) for nd in ip3.nodes(sec(0.5)): nd.include_flux(callbackfun) for nd in ip3.nodes(sec(0.9)): nd.include_flux(sec(0.3)._ref_ip3i) h.finitialize(-70) h.continuerun(10) import numpy