Example #1
0
def nunit_evaluation(tuple_object):  #,backend=None):
    # Inputs single data transport container modules, and neuroelectro observations that
    # inform test error error_criterion
    # Outputs Neuron Unit evaluation scores over error criterion
    dtc, tests = tuple_object
    dtc = copy.copy(dtc)
    dtc.model_path = path_params['model_path']
    LEMS_MODEL_PATH = path_params['model_path']
    assert dtc.rheobase is not None
    backend = dtc.backend
    if backend == 'glif':

        model = glif.GC(
        )  #ReducedModel(LEMS_MODEL_PATH,name=str('vanilla'),backend=('NEURON',{'DTC':dtc}))
        tests[0].prediction = dtc.rheobase
        model.rheobase = dtc.rheobase['value']
    else:
        model = ReducedModel(LEMS_MODEL_PATH,
                             name=str('vanilla'),
                             backend=('NEURON', {
                                 'DTC': dtc
                             }))
        model.set_attrs(dtc.attrs)
        tests[0].prediction = dtc.rheobase
        model.rheobase = dtc.rheobase['value']

    for k, t in enumerate(tests[1:-1]):
        t.params = dtc.vtest[k]
        score = None
        score = t.judge(model, stop_on_error=False, deep_error=False)
        dtc.score[str(t)] = {}
        dtc.score[str(t)]['value'] = copy.copy(score.sort_key)

        if hasattr(score, 'prediction'):

            if type(score.prediction) is not type(None):

                dtc.score[str(t)][str('prediction')] = score.prediction
                dtc.score[str(t)][str('observation')] = score.observation

                if 'mean' in score.observation.keys(
                ) and 'mean' in score.prediction.keys():
                    print(score.observation.keys())
                    dtc.score[str(t)][str('agreement')] = np.abs(
                        score.observation['mean'] - score.prediction['mean'])
        else:
            print(score, type(score))
        if score.sort_key is not None:
            ##
            # This probably does something different to what I thought.
            ##
            #dtc.scores.get(str(t), 1.0 - score.sort_key)

            dtc.scores[str(t)] = 1.0 - score.sort_key
        else:
            dtc.scores[str(t)] = 1.0
    return dtc
Example #2
0
def nunit_evaluation(tuple_object):#,backend=None):
    # Inputs single data transport container modules, and neuroelectro observations that
    # inform test error error_criterion
    # Outputs Neuron Unit evaluation scores over error criterion
    dtc,tests = tuple_object
    dtc.model_path = path_params['model_path']
    LEMS_MODEL_PATH = path_params['model_path']
    assert dtc.rheobase is not None
    backend = dtc.backend
    if backend == 'glif':

        model = glif.GC()#ReducedModel(LEMS_MODEL_PATH,name=str('vanilla'),backend=('NEURON',{'DTC':dtc}))
        tests[0].prediction = dtc.rheobase
        model.rheobase = dtc.rheobase['value']
    else:
        model = ReducedModel(LEMS_MODEL_PATH,name = str('vanilla'),backend = ('NEURON',{'DTC':dtc}))
        model.set_attrs(dtc.attrs)
        tests[0].prediction = dtc.rheobase
        model.rheobase = dtc.rheobase['value']


    for k,t in enumerate(tests[1:-1]):
        t.params = dtc.vtest[k]
        score = t.judge(model,stop_on_error = False, deep_error = False)
        dtc.score.get(str(t), score)
        dtc.score[str(t)][str('prediction')] = score.prediction
        dtc.score[str(t)][str('observation')] = score.observation

        if score.sort_key is not None:
            if not hasattr(dtc,'score'):
                dtc.score = score
                print(dtc.score.prediction)
                print(dtc.score.observation)

            dtc.scores.get(str(t), 1.0 - score.sort_key)
        else:
            dtc.scores[str(t)] = 1.0
    return dtc
Example #3
0
import os
import sys
import matplotlib
matplotlib.use('Agg')

import matplotlib.pyplot as plt

from neuronunit.models.interfaces import glif
gc = glif.GC()
from neuronunit.optimization import get_neab  #import get_neuron_criteria, impute_criteria
from neuronunit.optimization.model_parameters import model_params

import os
import pickle
electro_path = 'pipe_tests.p'

assert os.path.isfile(electro_path) == True
with open(electro_path, 'rb') as f:
    electro_tests = pickle.load(f)

MU = 6
NGEN = 6
CXPB = 0.9
USE_CACHED_GA = False

#provided_keys = list(model_params.keys())
USE_CACHED_GS = False
from bluepyopt.deapext.optimisations import DEAPOptimisation
npoints = 2
nparams = 10