def self_evaluate(self,tests=None):    
        from neuronunit.optimisation import optimization_management as om_
        if tests is not None:
            self.tests = tests

        OM = self.dtc_to_opt_man()
        self = om_.dtc_to_rheo(self)
        d = OM.format_test(self)
        model = self.dtc_to_model()
        scores_ = []
        for t in self.tests:
            if hasattr(t,'allen'): 
                continue
            if 'RheobaseTest' in t.name: t.score_type = sciunit.scores.ZScore
            if 'RheobaseTestP' in t.name: t.score_type = sciunit.scores.ZScore
            try:
                score_gene = t.judge(model)
            except:
                score_gene = None
                lns = 100


            if score_gene is not None:
                if not isinstance(type(score_gene),sciunit.scores.InsufficientDataScore):
                    if not isinstance(type(score_gene.log_norm_score),type(None)):
                        try:

                            lns = np.abs(score_gene.log_norm_score)
                        except:
                            if score_gene.raw is not None:
                                lns = np.abs(float(score_gene.raw))
                            else:
                                lns = 100.0
                    else:
                        try:
                            lns = np.abs(float(score_gene.raw))
                        except:
                            lns = 100
                else:
                    try:
                        lns = np.abs(float(score_gene.raw))
                    except:
                        lns = 100

            if lns==np.inf or lns==-np.inf:
                lns = np.abs(float(score_gene.raw))
            scores_.append(lns)
        for i,s in enumerate(scores_):
            if s==np.inf or s==-np.inf:
                scores_[i] = 100 #np.abs(float(score_gene.raw))
        #self.SA = ScoreArray(self.tests, scores_)
        self.scores_ = scores_

        temp = [ t for t in self.tests if not hasattr(t,'allen')  ]
        self.SA = ScoreArray(temp, self.scores_)

        #self = OM.get_agreement(self)
        return self
Exemple #2
0
    def iap(self, tests=None):
        '''
        Inject and plot to terminal with ascii
        This is useful for debugging new backends, in bash big/fast command line orientated optimization routines.
        '''
        from neuronunit.optimisation import optimization_management as om_
        if tests is not None:
            self.tests = tests

        OM = self.dtc_to_opt_man()
        self = om_.dtc_to_rheo(self)

        model = self.dtc_to_model()
        pms = uset_t.params
        pms['injected_square_current']['amplitude'] = self.rheobase
        model.inject_square_current(pms['injected_square_current'])
        nspike = model.get_spike_train()
        self.nspike = nspike
        vm = model.get_membrane_potential()
        return vm
Exemple #3
0
objectives = cell_evaluator.evaluate_with_dicts(best_ind_dict)

model = cell_evaluator.cell_model
cell_evaluator.param_dict(best_ind)
model.attrs = {
    str(k): float(v)
    for k, v in cell_evaluator.param_dict(best_ind).items()
}

opt = model.model_to_dtc()
opt.attrs = {
    str(k): float(v)
    for k, v in cell_evaluator.param_dict(best_ind).items()
}
from neuronunit.optimisation.optimization_management import dtc_to_rheo, inject_and_plot_model30, check_bin_vm30, check_bin_vm15
opt = dtc_to_rheo(opt)
opt.rheobase
opt.attrs
vm301, vm151, _, _, target = inject_and_plot_model30(target)
vm302, vm152, _, _, opt = inject_and_plot_model30(opt)

# +
from neuronunit.optimisation.optimization_management import dtc_to_rheo, inject_and_plot_model30, check_bin_vm30, check_bin_vm15
check_bin_vm30(target, opt)
check_bin_vm15(target, opt)

# -


def basic_expVar(trace1, trace2):
    # https://github.com/AllenInstitute/GLIF_Teeter_et_al_2018/blob/master/query_biophys/query_biophys_expVar.py