示例#1
0
 def __init__(self):
     """Constructor"""
     data = nrnUtils.readParamsCSV(paramsCSV)
     super(hoc_evaluator, self).__init__()
     self.orig_params = orig_params
     self.opt_ind = params_opt_ind
     data = np.array([data[i] for i in self.opt_ind])
     self.orig_params = orig_params
     self.pmin = np.array((data[:, 1]), dtype=np.float64)
     self.pmax = np.array((data[:, 2]), dtype=np.float64)
     self.pmax = np.delete(
         self.pmax, 1, 0
     )  # need to delete second parameter because it is negative and BPOP cannot take negative params, we will add it back to every set of params in eval_list before allParams
     self.pmin = np.delete(self.pmin, 1, 0)
     #self.ptarget = self.orig_params
     params = []
     for i in range(len(self.pmin)):
         params.append(
             bpop.parameters.Parameter(data[i][0],
                                       bounds=(self.pmin[i], self.pmax[i])))
     self.params = params
     self.weights = opt_weight_list
     self.opt_stim_list = [e.decode('ascii') for e in opt_stim_name_list]
     self.target_volts_list = np.array(
         [target_volts_hdf5[s][:] for s in self.opt_stim_list])
     self.objectives = [
         bpop.objectives.Objective('Weighted score functions')
     ]
     # AP tune stuff not currently being used
     self.ap_tune_stim_name = ap_tune_stim_name
     self.ap_tune_weight = ap_tune_weight
     self.ap_tune_target = target_volts_hdf5[self.ap_tune_stim_name][:]
     self.dts = []
 def __init__(self):
     """Constructor"""
     params_ = nrnUtils.readParamsCSV(paramsCSV)
     super(hoc_evaluator, self).__init__()
     self.orig_params = orig_params
     
     # code below more specific to neuroGPU
     data = np.genfromtxt(params_table,delimiter=',',names=True)
     self.pmin = data[0]
     print(self.pmin, "PMIN")
     self.pmax = data[1]
     self.ptarget = data[2]
     params = []
     for i in range(len(self.pmin)):
         params.append(bpop.parameters.Parameter('p' + str(i), bounds=(self.pmin[i],self.pmax[i])))
     self.params = params
     
     #print("Params to optimize:", [(name, minval, maxval) for name, minval, maxval in params_])
     self.weights = opt_weight_list
     self.opt_stim_list = [e.decode('ascii') for e in opt_stim_name_list]
     
     
     #self.objectives = [bpop.objectives.Objective('Weighted score functions')]
     
     self.objectives = np.repeat(bpop.objectives.Objective('Weighted score \
     functions'),4) #for 16 stims
示例#3
0
    def __init__(self):
        """Constructor"""
        data = nrnUtils.readParamsCSV(paramsCSV)
        super(hoc_evaluator, self).__init__()
        self.orig_params = orig_params
        self.opt_ind = np.array(params_opt_ind)
        data = np.array([data[i] for i in self.opt_ind])
        self.orig_params = orig_params
        self.pmin = np.array((data[:,2]), dtype=np.float64)
        self.pmax = np.array((data[:,3]), dtype=np.float64)
        # make this a function
        self.fixed = {}
        self.params = []
        for param_idx in range(len(self.orig_params)):
            if param_idx in self.opt_ind:
                idx = np.where(self.opt_ind == param_idx)
                if np.isclose(self.orig_params[param_idx],self.pmin[idx],rtol=.000001) and np.isclose(self.pmin[idx],self.pmax[idx],rtol=.000001):
                    #self.fixed[param_idx] = self.orig_params[param_idx]
                    self.params.append(bpop.parameters.Parameter(self.orig_params[param_idx], bounds=(self.pmin[idx][0]*.999999,self.pmax[idx][0]*1.00001)))
                    print(" opt but fixed idx : ", (self.orig_params[param_idx], self.pmin[idx][0]*.999999,self.pmax[idx][0]*1.00001))

                else:
                    print("USING: ", self.opt_ind[idx[0]],self.orig_params[param_idx], (self.pmin[idx],self.pmax[idx]))
                    counter +=1
                    self.params.append(bpop.parameters.Parameter(self.orig_params[param_idx], bounds=(self.pmin[idx][0],self.pmax[idx][0]))) # this indexing is annoying... pmax and pmin weird shape because they are numpy arrays, see idx assignment on line 125... how can this be more clear
            else:
                print("FIXED: ", self.orig_params[param_idx], " idx : ", param_idx)
                self.fixed[param_idx] = self.orig_params[param_idx]
                    self.params.append(bpop.parameters.Parameter(self.orig_params[param_idx], bounds=(self.pmin[idx][0],self.pmax[idx][0]))) # this indexing is annoying... pmax and pmin weird shape because they are numpy arrays, see idx assignment on line 125... how can this be more clear
            else:
                print(self.orig_params[param_idx], " idx : ", param_idx)
                self.fixed[param_idx] = self.orig_params[param_idx]
    def __init__(self):
        """Constructor"""
        data = nrnUtils.readParamsCSV(paramsCSV)
        super(hoc_evaluator, self).__init__()
        self.orig_params = orig_params
        self.opt_ind = params_opt_ind
        data = np.array([data[i] for i in self.opt_ind])
        #print(orig_params, "orig params")
        self.orig_params = orig_params
        #print(1/0)
        self.pmin = np.array((data[:,1]), dtype=np.float64)
        # THIS IS A SHORT TERM FIX, need to fix it in evaluate with lists
        self.pmax = np.array((data[:,2]), dtype=np.float64) 
        #testing
        #self.pmin = self.orig_params - .000000001
        #self.pmax = self.orig_params + .000001
        self.pmax = np.delete(self.pmax, 1, 0)
        self.pmin = np.delete(self.pmin, 1, 0)
        
        #old
        #self.pmax[1] = self.pmax[1] + .000001 # need to remove it from optimization and add it back in for mapping
        #self.pmin[1] = self.pmin[1] - .000001 #TODO, there are some issues with this param 
        
        self.ptarget = self.orig_params
        params = [] 
        for i in range(len(self.pmin)):
#              params.append(bpop.parameters.Parameter(data[i][0], bounds=(np.abs(self.ptarget[i])-.000000000001,np.abs(self.ptarget[i])+.0000000000001)))
            #testing
            params.append(bpop.parameters.Parameter(data[i][0], bounds=(self.pmin[i],self.pmax[i])))
        self.params = params
        
        
        #to reset mapping 
           #old 
        
#         data = np.genfromtxt(params_table,delimiter=',',names=True)
#         self.pmin = data[0]
#         print(self.pmin, "PMIN")
#         self.pmax = data[1]
#         self.ptarget = data[2]
#         params = []
#         for i in range(len(self.pmin)):
#             params.append(bpop.parameters.Parameter('p' + str(i), bounds=(self.pmin[i],self.pmax[i])))
#         self.params = params
        
        
        
        self.weights = opt_weight_list
        self.opt_stim_list = [e.decode('ascii') for e in opt_stim_name_list]
        print("Init target volts")
        self.target_volts_list = np.abs([target_volts_hdf5[s][:] for s in self.opt_stim_list])
        #print("Params to optimize:", params[1])
        self.objectives = [bpop.objectives.Objective('Weighted score functions')]
        self.ap_tune_stim_name = ap_tune_stim_name
        self.ap_tune_weight = ap_tune_weight
        self.ap_tune_target = target_volts_hdf5[self.ap_tune_stim_name][:]
        self.dts = []
示例#5
0
 def __init__(self):
     """Constructor"""
     params_ = nrnUtils.readParamsCSV(paramsCSV)
     super(hoc_evaluator, self).__init__()
     self.opt_ind = params_opt_ind
     params_ = [params_[i] for i in self.opt_ind]
     self.orig_params = orig_params
     self.params = [
         bpop.parameters.Parameter(name, bounds=(minval, maxval))
         for name, minval, maxval in params_
     ]
     print("Params to optimize:",
           [(name, minval, maxval) for name, minval, maxval in params_])
     print("Orig params:", self.orig_params)
     self.weights = opt_weight_list
     self.opt_stim_list = [e.decode('ascii') for e in opt_stim_name_list]
     self.objectives = [
         bpop.objectives.Objective('Weighted score functions')
     ]
     print("Init target volts")
     self.target_volts_list = run_model(orig_params, self.opt_stim_list)
    def __init__(self):
        """Constructor"""
        data = nrnUtils.readParamsCSV(paramsCSV)
        super(hoc_evaluator, self).__init__()
        self.orig_params = orig_params
        self.opt_ind = np.array(params_opt_ind)
        data = np.array([data[i] for i in self.opt_ind])
        realData = nrnUtils.readParamsCSV(
            "../../params/params_bbp_peeling_description.csv")
        realOrig = np.array((np.array(realData)[:, 1]), dtype=np.float64)
        self.orig_params = orig_params
        self.pmin = np.array((data[:, 2]), dtype=np.float64)
        self.pmax = np.array((data[:, 3]), dtype=np.float64)
        # make this a function
        self.fixed = {}
        self.params = []
        counter = 0
        for param_idx in range(len(self.orig_params)):
            if param_idx in self.opt_ind:
                idx = np.where(self.opt_ind == param_idx)
                if np.isclose(
                        self.orig_params[param_idx], self.pmin[idx],
                        rtol=.000001) and np.isclose(
                            self.pmin[idx], self.pmax[idx], rtol=.000001):
                    #self.fixed[param_idx] = self.orig_params[param_idx]
                    self.params.append(
                        bpop.parameters.Parameter(
                            self.orig_params[param_idx],
                            bounds=(self.pmin[idx][0] * .999999,
                                    self.pmax[idx][0] * 1.00001)))
                    print(" opt but fixed idx : ",
                          (self.orig_params[param_idx], self.pmin[idx][0] *
                           .999999, self.pmax[idx][0] * 1.00001))
                    counter += 1

                else:
                    print("USING: ", self.opt_ind[idx[0]],
                          self.orig_params[param_idx],
                          (self.pmin[idx], self.pmax[idx]))
                    print(param_idx, idx)

                    counter += 1
                    self.params.append(
                        bpop.parameters.Parameter(self.orig_params[param_idx],
                                                  bounds=(self.pmin[idx][0],
                                                          self.pmax[idx][0]))
                    )  # this indexing is annoying... pmax and pmin weird shape because they are numpy arrays, see idx assignment on line 125... how can this be more clear
            else:
                print("FIXED: ", self.orig_params[param_idx], " idx : ",
                      param_idx)
                self.fixed[param_idx] = self.orig_params[param_idx]
        print("NUM FREE PARAMS :", counter)

        self.weights = opt_weight_list
        self.opt_stim_list = [e.decode('ascii') for e in opt_stim_name_list]
        self.objectives = [
            bpop.objectives.Objective('Weighted score functions')
        ]
        self.target_volts_list = self.make_target_volts(
            realOrig, self.opt_stim_list)
        self.dts = []
示例#7
0
scores_path = '../scores/'
objectives_file = h5py.File('../objectives/multi_stim_bbp_full.hdf5', 'r')
opt_weight_list = objectives_file['opt_weight_list'][:]
opt_stim_name_list = objectives_file['opt_stim_name_list'][:]
score_function_ordered_list = objectives_file['ordered_score_function_list'][:]
stims_path = '../stims/stims_full.hdf5'
stim_file = h5py.File(stims_path, 'r')
#target_volts_path = './target_volts/allen_data_target_volts_10000.hdf5'
#target_volts_hdf5 = h5py.File(target_volts_path, 'r')
#params_opt_ind = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
params_opt_ind = np.arange(24)
model_dir = '..'
data_dir = model_dir + '/Data/'
run_dir = '../bin'
vs_fn = '/tmp/Data/VHotP'
data = nrnUtils.readParamsCSV(paramsCSV)
#self.opt_ind = params_opt_ind
data = np.array([data[i] for i in params_opt_ind])
pmin = np.array((data[:, 2]), dtype=np.float64)
pmax = np.array((data[:, 3]), dtype=np.float64)
# make this a function
fixed = {}
params = []
for param_idx in range(len(orig_params)):
    if np.isclose(orig_params[param_idx], pmin[param_idx],
                  rtol=.001) and np.isclose(
                      pmin[param_idx], pmax[param_idx], rtol=.001):
        print(orig_params[param_idx], " idx : ", param_idx)
        fixed[param_idx] = orig_params[param_idx]
    else:
        pass