Esempio n. 1
0
def get_neuron_criteria(cell_id,file_name=None,observation=None):
    from neuronunit import tests as nu_tests, neuroelectro
    from neuronunit.tests import passive, waveform, fi

    if observation == None:
        observation = fi.RheobaseTest.neuroelectro_summary_observation(cell_id)

        #observation =  neuroelectro.neuroelectro_summary_observation(cell_id)
    #
    obs_list = list(observation.values())
    tests = []
    #tests += [fi.RheobaseTestP(observation=observation)]
    test_class_params = [(fi.RheobaseTestP,None),
                     (passive.InputResistanceTest,None),
                     (passive.TimeConstantTest,None),
                     (passive.CapacitanceTest,None),
                     (passive.RestingPotentialTest,None),
                     (waveform.InjectedCurrentAPWidthTest,None),
                     (waveform.InjectedCurrentAPAmplitudeTest,None),
                     (waveform.InjectedCurrentAPThresholdTest,None)]#,
    observations = []
    for index, unpack in enumerate(test_class_params):
        cls, params = unpack
        #observations.append(cls.neuroelectro_summary_observation(cell_id))
        tests += [cls(obs_list[index])]

    hooks = {tests[0]:{'f':update_amplitude}} #This is a trick to dynamically insert the method
    #update amplitude at the location in sciunit thats its passed to, without any loss of generality.
    suite = sciunit.TestSuite("vm_suite",tests)#
    if file_name is not None:
        file_name = file_name +'.p'
        with open(file_name, 'wb') as f:
            pickle.dump(tests, f)
    return tests,observations
Esempio n. 2
0
def get_neuron_criteria(cell_id, file_name=None):  #,observation = None):
    # Use neuroelectro experimental obsevations to find test
    # criterion that will be used to inform scientific unit testing.
    # some times observations are not sourced from neuroelectro,
    # but they are imputated or borrowed from other TestSuite
    # if that happens make test objections using observations external
    # to this method, and provided as a method argument.
    tests = []
    observations = None
    test_classes = None
    test_classes = [
        fi.RheobaseTest, passive.InputResistanceTest, passive.TimeConstantTest,
        passive.CapacitanceTest, passive.RestingPotentialTest,
        waveform.InjectedCurrentAPWidthTest,
        waveform.InjectedCurrentAPAmplitudeTest,
        waveform.InjectedCurrentAPThresholdTest
    ]  #,
    observations = {}
    for index, t in enumerate(test_classes):
        obs = t.neuroelectro_summary_observation(cell_id)
        if obs is not None:
            if 'mean' in obs.keys():
                tests.append(t(obs))
                observations[t.ephysprop_name] = obs

    #hooks = {tests[0]:{'f':update_amplitude}} #This is a trick to dynamically insert the method
    #update amplitude at the location in sciunit thats its passed to, without any loss of generality.
    suite = sciunit.TestSuite(tests, name="vm_suite")

    if file_name is not None:
        file_name = file_name + '.p'
        with open(file_name, 'wb') as f:
            pickle.dump(tests, f)

    return tests, observations
Esempio n. 3
0
def get_tests():
    # get neuronunit tests
    # and select out Rheobase test and input resistance test
    # and less about electrophysiology of the membrane.
    # We are more interested in phenomonogical properties.
    electro_path = str(os.getcwd()) + '/pipe_tests.p'
    assert os.path.isfile(electro_path) == True
    with open(electro_path, 'rb') as f:
        electro_tests = pickle.load(f)
    electro_tests = replace_zero_std(electro_tests)
    electro_tests = substitute_parallel_for_serial(electro_tests)
    test, observation = electro_tests[0]
    tests = copy.copy(electro_tests[0][0])
    suite = sciunit.TestSuite(tests)
    #tests_ = tests[0:2]
    return tests, test, observation, suite
Esempio n. 4
0
        observation = cls.neuroelectro_summary_observation(neuron)
        tests += [cls(observation)]

#with open(ne_pickle, 'wb') as f:
#    pickle.dump(tests, f)


def update_amplitude(test, tests, score):
    rheoXbase = score.prediction['value']  #first find a value for rheobase
    #then proceed with other optimizing other parameters.
    #for i in

    for i in [4, 5, 6]:
        # Set current injection to just suprathreshold

        tests[i].params['injected_square_current'][
            'amplitude'] = rheobase * 1.01
        #tests[i].proceed=tests[i].sanity_check(rh_value=rheobase*1.01)
        #pdb.set_trace()


#Don't do the rheobase test. This is a serial bottle neck that must occur before any parallel optomization.
#Its because the optimization routine must have apriori knowledge of what suprathreshold current injection values are for each model.
hooks = {
    tests[0]: {
        'f': update_amplitude
    }
}  #This is a trick to dynamically insert the method
#update amplitude at the location in sciunit thats its passed to, without any loss of generality.
suite = sciunit.TestSuite("vm_suite", tests)  #,hooks=hooks)
Esempio n. 5
0
brain_area = 'cerebellum'
neuron_type = 'cerebellar_granule_cell'
path = os.path.join(OSB_MODELS,brain_area,neuron_type)
neurolex_id = 'nifext_128' # Cerebellar Granule Cell
# Specify reference data for this test.  
reference_data = neuroelectro.NeuroElectroSummary(
    neuron = {'nlex_id':neurolex_id}, # Neuron type.  
    ephysprop = {'name':'Resting Membrane Potential'}) # Electrophysiological property name. 
# Get and verify summary data for the combination above from neuroelectro.org. 
if reference_data.get_values() is None:
    raise ValueError("Unable to get the reference data from NeuroElectro.org.")
    
test = tests.RestingPotentialTest(
    observation = {'mean':reference_data.mean,
                      'std':reference_data.std})
suite = sciunit.TestSuite('Resting Potential',test)

if not os.path.isdir(path):
    raise IOError('No such path: %s' % path)
model_names = os.listdir(path)
models = []
for model_name in model_names:
    print(model_name)
    if model_name in ['GranCellRothmanIf']:
        continue
    model_info = (brain_area,neuron_type,model_name)
    model = nc_models.OSBModel(*model_info)
    models.append(model)

# (1) Check capabilities,
# (2) take the test,