def run_test(self, pre, post): # Make sure no objects are left over from previous tests reset(raiseError=False) # seed random generator using the name of this test seed = "%s_%s" % (pre, post) pre_cell = make_cell(pre) post_cell = make_cell(post) n_term = convergence.get(pre, {}).get(post, None) if n_term is None: n_term = 1 st = SynapseTest() st.run(pre_cell.soma, post_cell.soma, n_term, seed=seed) if self.audit: st.show_result() info = dict( rel_events=st.release_events(), rel_timings=st.release_timings(), open_prob=st.open_probability(), event_analysis=st.analyze_events(), ) self.st = st #import weakref #global last_syn #last_syn = weakref.ref(st.synapses[0].terminal.relsi) return info
def test_max_open_probability(): reset( raiseError=False ) # reset() fails as unable to remove all neuron objects, unless we ignore the error sec = h.Section() # Create AMPA and NMDA mechanisms # AMPA uses mode=0; no rectification apsd = h.AMPATRUSSELL(0.5, sec=sec) # For NMDA we will hold the cell at +40 mV npsd = h.NMDA_Kampa(0.5, sec=sec) # And a presynaptic terminal to provide XMTR input term = h.MultiSiteSynapse(0.5, sec=sec) term.nZones = 1 term.setpointer(term._ref_XMTR[0], 'XMTR', apsd) term.setpointer(term._ref_XMTR[0], 'XMTR', npsd) h.celsius = 34.0 h.finitialize() op = [[], []] for i in range(100): # force very high transmitter concentration for every timestep term.XMTR[0] = 10000 sec.v = 40.0 h.fadvance() op[0].append(apsd.Open) op[1].append(npsd.Open) assert np.allclose(max(op[0]), apsd.MaxOpen) assert np.allclose(max(op[1]), npsd.MaxOpen)
def sgc_psd_test(cell_class, seed, plot=False, tstop=5.0, n_syn=20): """ Tests a multisite synapse from the SGC to a target cell. The values returned from an actual set of runs of the synapse are compared to the expected values in the synapses.py table. This is needed because the maximal open probability of the receptor models is not 1, so the maximal conductance per receptor needs to be adjusted empirically. If the measured current does not match the expected current, then we print a message with the expected value, and fail with an assert statment in the test. The measurement itself is made in measure_gmax(). Parameters ---------- cell_class : an instance of the cell class seed : int random number seed for the call plot : boolean (default False) plot request, passed to measure_gmax tstop : float (default 5.0 ms) duration of run for measurement of gmax. Needs to be long enough to find the maximum of the EPSC/IPSC. n_syn : int (default 20) number of synapses to instantiate for testing (to get an average value) """ celltyp = cell_class.__name__.lower() random_seed.set_seed(seed) reset(raiseError=False) # avoid failure because we cannot release NEURON objects completely. tsc = cell_class.create(ttx=True) (ampa_gmax, nmda_gmax, epsc_cv) = measure_gmax(tsc, n_syn=n_syn, tstop=tstop, plot=plot) exp_ampa_gmax = data.get('sgc_synapse', species='mouse', post_type=celltyp, field='AMPA_gmax')[0] exp_nmda_gmax = data.get('sgc_synapse', species='mouse', post_type=celltyp, field='NMDA_gmax')[0] exp_epsc_cv = data.get('sgc_synapse', species='mouse', post_type=celltyp, field='EPSC_cv') ampa_correct = np.allclose(exp_ampa_gmax, ampa_gmax) if not ampa_correct: AMPAR_gmax = data.get('sgc_synapse', species='mouse', post_type=celltyp, field='AMPAR_gmax') ratio = exp_ampa_gmax/ampa_gmax print('AMPA Receptor conductance in model should be %.16f (table is %.16f)' % (AMPAR_gmax * ratio, AMPAR_gmax)) nmda_correct = np.allclose(exp_nmda_gmax, nmda_gmax) if not nmda_correct: NMDAR_gmax = data.get('sgc_synapse', species='mouse', post_type=celltyp, field='NMDAR_gmax') ratio = exp_nmda_gmax/nmda_gmax print('NMDA Receptor conductance in model should be %.16f (table is %.16f)' % (NMDAR_gmax * ratio, NMDAR_gmax)) cv_correct = (abs(exp_epsc_cv / epsc_cv - 1.0) < 0.1) print 'cv_correct: ', cv_correct if not cv_correct: ratio = exp_epsc_cv/epsc_cv print('CV Receptor in synapses.py model should be %.6f (measured = %.6f; table = %.6f)' % (epsc_cv * ratio, epsc_cv, exp_epsc_cv)) print ((abs(exp_epsc_cv / (epsc_cv * ratio) - 1.0) < 0.1)) assert cv_correct assert ampa_correct and nmda_correct
def test_sgc_basal_middle(): reset(raiseError=False) cell = cells.SGC.create(species='mouse', modelType='bm') CellTester('SGC_rat_bm', cell)
def test_sgc_apical(): reset(raiseError=False) cell = cells.SGC.create(species='mouse', modelType='a') CellTester('SGC_rat_a', cell)
def test_tuberculoventral(): reset(raiseError=False) cell = cells.Tuberculoventral.create(species='mouse', modelType='TVmouse') CellTester('tuberculoventral_mouse_I', cell)
def test_cartwheel(): reset(raiseError=False) cell = cells.Cartwheel.create(species='mouse', modelType='I') CellTester('cartwheel_rat_I', cell)
def test_octopus(): reset(raiseError=False) cell = cells.Octopus.create(species='guineapig', modelType='II-o') CellTester('octopus_guineapig-typeII-o', cell)
def test_pyramidal(): reset(raiseError=False) cell = cells.Pyramidal.create(species='rat', modelType='I') CellTester('pyramidal_rat_I', cell)
def test_dstellate_mouse(): reset(raiseError=False) cell = cells.DStellate.create(species='mouse', modelType='I-II') CellTester('dstellate_mouse-typeI-II', cell)
def test_dstellate(): reset(raiseError=False) cell = cells.DStellate.create(species='guineapig', modelType='I-II') CellTester('dstellate_guineapig-typeI-II', cell)
def test_tstellatet(): reset(raiseError=False) cell = cells.TStellate.create(species='guineapig', modelType='I-t') CellTester('tstellate_guineapig-typeI-t', cell)
def test_bushy_mouse(): reset(raiseError=False) cell = cells.Bushy.create(species='mouse', modelType='II') CellTester('bushy-mouse-typeII', cell)
def test_bushy21(): reset(raiseError=False) cell = cells.Bushy.create(species='guineapig', modelType='II-I') CellTester('bushy_guineapig-typeII-I', cell)