Skip to content

Commit e6570ab

Browse files
authored
Merge pull request #95 from sasaray/master
Updating feature optimization (ignoring some AP1 features, changing p…
2 parents 09429dc + 68f9d25 commit e6570ab

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

optimizer/fitnessFunctions.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -878,18 +878,19 @@ def FFun_for_Features(self, mod_t, features_data, feature, k, args={}):
878878
exp_mean = features_data[feature]["mean"][k]
879879
exp_std = features_data[feature]["std"][k]
880880
mod_result=traces_results[0][feature]
881-
#print feature
882881

883882
#print "exp mean", exp_mean
884883
#print "exp std", exp_std
885884
#print "model", mod_result
886885

887-
if mod_result is not None and mod_result.size > 1:
886+
if mod_result is not None and mod_result.size > 1 and (feature == 'AP_rise_time' or feature == 'AP_amplitude' or feature == 'AP_duration_half_width' or feature == 'AP_begin_voltage' or feature == 'AP_rise_rate'):
887+
mod_result = scipy.mean(mod_result[1:])
888+
elif mod_result is not None and mod_result.size > 1:
888889
mod_result = scipy.mean(mod_result) #for features (AHP_depth, AP_duration_half_width) that gives a list as a result, the mean of the results is used
889890
elif mod_result is not None and mod_result.size!=0: # mod_result is a numpy array with one element, 0 element for AP1_amp or APlast_amp if no AP generated by the model
890891
mod_result=mod_result[0]
891892

892-
if (mod_result == None or mod_result == 0 or mod_result.size==0) and (exp_mean != None and exp_std != None):
893+
if (mod_result == None or mod_result.size==0) and (exp_mean != None and exp_std != None):
893894
temp_fit=250
894895
elif exp_mean == None and exp_std == None :
895896
temp_fit=0
@@ -919,6 +920,7 @@ def combineFeatures(self, candidates, args={}):
919920
:return: the ``list`` of fitness values corresponding to the parameter sets
920921
921922
"""
923+
922924
self.fitnes = []
923925
features = self.option.feats
924926

@@ -979,6 +981,7 @@ def combineFeatures(self, candidates, args={}):
979981
print "current fitness: ",temp_fit
980982
temp_fit = 0
981983

984+
982985
return self.fitnes
983986

984987
def getErrorComponents(self, index_of_trace, model_output):

optimizer/graphic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1611,7 +1611,7 @@ def Next(self, e):
16111611
})
16121612
self.kwargs.update({"weights" : [float(w.GetValue()) for w in filter(lambda x: x.IsEnabled(), self.weights)]})
16131613
else:
1614-
#self.my_list=self.core.data_handler.features_data.keys()[3:]
1614+
#self.my_list=self.core.data_handler.features_data.keys()[3:-1]
16151615
self.kwargs.update({"feat":
16161616
[tmp_dict,
16171617
[self.my_list[fun[0]] for fun in filter(lambda x: x[1].IsEnabled(), enumerate(self.weights))]]

0 commit comments

Comments
 (0)