コード例 #1
0
    def test_rheobase_single_value_parallel_and_serial_comparison(self):
        from neuronunit.tests.fi import RheobaseTest, RheobaseTestP
        from neuronunit.optimization import get_neab
        from neuronunit.models.reduced import ReducedModel
        from neuronunit import aibs
        import os
        dataset_id = 354190013  # Internal ID that AIBS uses for a particular Scnn1a-Tg2-Cre
        # Primary visual area, layer 5 neuron.
        observation = aibs.get_observation(dataset_id, 'rheobase')
        rt = RheobaseTest(observation=observation)
        rtp = RheobaseTestP(observation=observation)
        model = ReducedModel(get_neab.LEMS_MODEL_PATH, backend=('NEURON'))

        #model = ReducedModel(get_neab.LEMS_MODEL_PATH,name=str('vanilla'),backend='NEURON')
        self.score_p = rtp.judge(model, stop_on_error=False, deep_error=True)
        self.predictionp = self.score_p.prediction
        self.score_p = self.score_p.norm_score
        #model = ReducedModel(get_neab.LEMS_MODEL_PATH,name=str('vanilla'),backend='NEURON')

        serial_model = ReducedModel(get_neab.LEMS_MODEL_PATH,
                                    name=str('vanilla'),
                                    backend='NEURON')
        self.score_s = rt.judge(serial_model,
                                stop_on_error=False,
                                deep_error=True)
        self.predictions = self.score_s.prediction
        self.score_s = self.score_s.norm_score
        import numpy as np
        check_less_thresh = float(
            np.abs(self.predictionp['value'] - self.predictions['value']))
        self.assertLessEqual(check_less_thresh, 2.0)
コード例 #2
0
    def test_rheobase_single_value_parallel_and_serial_comparison(self):
        from neuronunit.tests.fi import RheobaseTest, RheobaseTestP
        from neuronunit.optimization import get_neab
        from neuronunit.models.reduced import ReducedModel
        from neuronunit import aibs
        import os
        dataset_id = 354190013  # Internal ID that AIBS uses for a particular Scnn1a-Tg2-Cre
                                # Primary visual area, layer 5 neuron.
        observation = aibs.get_observation(dataset_id,'rheobase')
        rt = RheobaseTest(observation = observation)
        rtp = RheobaseTestP(observation = observation)
        model = ReducedModel(get_neab.LEMS_MODEL_PATH, backend=('NEURON'))

        #model = ReducedModel(get_neab.LEMS_MODEL_PATH,name=str('vanilla'),backend='NEURON')
        self.score_p = rtp.judge(model,stop_on_error = False, deep_error = True)
        self.predictionp = self.score_p.prediction
        self.score_p = self.score_p.sort_key
        #model = ReducedModel(get_neab.LEMS_MODEL_PATH,name=str('vanilla'),backend='NEURON')

        serial_model = ReducedModel(get_neab.LEMS_MODEL_PATH,name=str('vanilla'),backend='NEURON')
        self.score_s = rt.judge(serial_model,stop_on_error = False, deep_error = True)
        self.predictions = self.score_s.prediction
        self.score_s = self.score_s.sort_key
        import numpy as np
        check_less_thresh = float(np.abs(self.predictionp['value'] - self.predictions['value']))
        self.assertLessEqual(check_less_thresh, 2.0)
コード例 #3
0
    def test_4rheobase_setup(self):
        from neuronunit.tests.fi import RheobaseTest, RheobaseTestP
        from neuronunit.optimization import get_neab
        from neuronunit.models import backends
        from neuronunit.models.reduced import ReducedModel
        import time
        from neuronunit import aibs
        import os
        dataset_id = 354190013  # Internal ID that AIBS uses for a particular Scnn1a-Tg2-Cre
                                # Primary visual area, layer 5 neuron.
        observation = aibs.get_observation(dataset_id,'rheobase')
        #os.system('ipcluster start -n 8 --profile=default & sleep 25;')

        rt = RheobaseTest(observation = observation)
        rtp = RheobaseTestP(observation = observation)

        get_neab.LEMS_MODEL_PATH = '/home/jovyan/neuronunit/neuronunit/optimization/NeuroML2/LEMS_2007One.xml'
        model = ReducedModel(get_neab.LEMS_MODEL_PATH,name=str('vanilla'),backend='NEURON')
        ticks = time.time()
        self.score_p = rtp.judge(model,stop_on_error = False, deep_error = True)
        self.predictionp = self.score_p.prediction

        self.score_p = self.score_p.sort_key
        tickp = time.time()
        self.timed_p = tickp - ticks
        self.score_s = rt.judge(model,stop_on_error = False, deep_error = True)
        self.predictions = self.score_s.prediction

        self.score_s = self.score_s.sort_key
        self.timed_s = time.time() - tickp


        print(' serial score {0} parallel score {1}'.format(self.score_s,self.score_p))
        print(' serial time {0} parallel time {1}'.format(self.timed_s,self.timed_p))
コード例 #4
0
 def test_10rheobase_setup(self):
     from neuronunit.tests.fi import RheobaseTest, RheobaseTestP
     from neuronunit.optimization import get_neab
     from neuronunit.models.reduced import ReducedModel
     from neuronunit import aibs
     import os
     dataset_id = 354190013  # Internal ID that AIBS uses for a particular Scnn1a-Tg2-Cre
     # Primary visual area, layer 5 neuron.
     observation = aibs.get_observation(dataset_id, 'rheobase')
     rt = RheobaseTest(observation=observation)
     rtp = RheobaseTestP(observation=observation)
     model = ReducedModel(get_neab.LEMS_MODEL_PATH,
                          name=str('vanilla'),
                          backend='NEURON')
     self.score_p = rtp.judge(model, stop_on_error=False, deep_error=True)
     self.predictionp = self.score_p.prediction
     self.score_p = self.score_p.sort_key
     self.score_s = rt.judge(model, stop_on_error=True, deep_error=True)
     self.predictions = self.score_s.prediction
     self.score_s = self.score_s.sort_key
     print(' serial score {0} parallel score {1}'.format(
         self.score_s, self.score_p))
     self.assertEqual(int(self.score_s * 1000), int(self.score_p * 1000))
     self.assertEqual(int(self.predictionp['value']),
                      int(self.predictions['value']))
コード例 #5
0
from neuronunit.tests import fi
from neuronunit.tests import passive
from neuronunit.tests import waveform

#print(RheobaseTestP)
#fi = tests.fi
#print(dir(fi))
#pr = fi.RheobaseTestP()
neuron = {'nlex_id': 'nifext_50'}  # Layer V pyramidal cell
tests = []

dataset_id = 354190013  # Internal ID that AIBS uses for a particular Scnn1a-Tg2-Cre
# Primary visual area, layer 5 neuron.

# this file writing operation needs to be threadlocked
observation = aibs.get_observation(dataset_id, 'rheobase')
ne_pickle = os.path.join(THIS_DIR, "neuroelectro.pickle")

if os.path.isfile(ne_pickle):
    print('attempting to recover from pickled file')
    with open(ne_pickle, 'rb') as f:
        tests = pickle.load(f)

else:

    #print('Checked path %s and no pickled file found. Commencing time intensive Download' % ne_pickle)
    tests += [fi.RheobaseTestP(observation=observation)]
    test_class_params = [(passive.InputResistanceTest, None),
                         (passive.TimeConstantTest, None),
                         (passive.CapacitanceTest, None),
                         (passive.RestingPotentialTest, None),