Skip to content

Commit

Permalink
do not hardcode return value for features computes outside of their f…
Browse files Browse the repository at this point in the history
…unction
  • Loading branch information
Jaquier Aurélien Tristan committed May 21, 2024
1 parent 4aa06d6 commit e1f5966
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 10 deletions.
30 changes: 24 additions & 6 deletions efel/cppcore/SpikeEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,10 @@ int SpikeEvent::burst_begin_indices(mapStr2intVec& IntFeatureData,
int SpikeEvent::burst_end_indices(mapStr2intVec& IntFeatureData,
mapStr2doubleVec& DoubleFeatureData,
mapStr2Str& StringData) {
return 1;
const auto& intFeatures = getFeatures(IntFeatureData, {"burst_begin_indices"});
int retVal = intFeatures.at("burst_begin_indices").size();
if (retVal <= 0) return -1;
return retVal;
}

static int __strict_burst_mean_freq(const vector<double>& PVTime,
Expand Down Expand Up @@ -695,7 +698,10 @@ int SpikeEvent::interburst_min_indices(mapStr2intVec& IntFeatureData,
int SpikeEvent::interburst_min_values(mapStr2intVec& IntFeatureData,
mapStr2doubleVec& DoubleFeatureData,
mapStr2Str& StringData) {
return 1;
const auto& intFeatures = getFeatures(IntFeatureData, {"interburst_min_indices"});
int retVal = intFeatures.at("interburst_min_indices").size();
if (retVal <= 0) return -1;
return retVal;
}

static int __postburst_min_indices(const vector<double>& t,
Expand Down Expand Up @@ -767,7 +773,10 @@ int SpikeEvent::postburst_min_indices(mapStr2intVec& IntFeatureData,
int SpikeEvent::postburst_min_values(mapStr2intVec& IntFeatureData,
mapStr2doubleVec& DoubleFeatureData,
mapStr2Str& StringData) {
return 1;
const auto& intFeatures = getFeatures(IntFeatureData, {"postburst_min_indices"});
int retVal = intFeatures.at("postburst_min_indices").size();
if (retVal <= 0) return -1;
return retVal;
}

int SpikeEvent::time_to_interburst_min(mapStr2intVec& IntFeatureData,
Expand Down Expand Up @@ -897,7 +906,10 @@ int SpikeEvent::postburst_slow_ahp_indices(mapStr2intVec& IntFeatureData,
int SpikeEvent::postburst_slow_ahp_values(mapStr2intVec& IntFeatureData,
mapStr2doubleVec& DoubleFeatureData,
mapStr2Str& StringData) {
return 1;
const auto& intFeatures = getFeatures(IntFeatureData, {"postburst_slow_ahp_indices"});
int retVal = intFeatures.at("postburst_slow_ahp_indices").size();
if (retVal <= 0) return -1;
return retVal;
}

int SpikeEvent::time_to_postburst_slow_ahp(mapStr2intVec& IntFeatureData,
Expand Down Expand Up @@ -1010,7 +1022,10 @@ int SpikeEvent::postburst_fast_ahp_indices(mapStr2intVec& IntFeatureData,
int SpikeEvent::postburst_fast_ahp_values(mapStr2intVec& IntFeatureData,
mapStr2doubleVec& DoubleFeatureData,
mapStr2Str& StringData) {
return 1;
const auto& intFeatures = getFeatures(IntFeatureData, {"postburst_fast_ahp_indices"});
int retVal = intFeatures.at("postburst_fast_ahp_indices").size();
if (retVal <= 0) return -1;
return retVal;
}

static int __postburst_adp_peak_indices(const vector<double>& t, const vector<double>& v,
Expand Down Expand Up @@ -1077,7 +1092,10 @@ int SpikeEvent::postburst_adp_peak_indices(mapStr2intVec& IntFeatureData,
int SpikeEvent::postburst_adp_peak_values(mapStr2intVec& IntFeatureData,
mapStr2doubleVec& DoubleFeatureData,
mapStr2Str& StringData) {
return 1;
const auto& intFeatures = getFeatures(IntFeatureData, {"postburst_adp_peak_indices"});
int retVal = intFeatures.at("postburst_adp_peak_indices").size();
if (retVal <= 0) return -1;
return retVal;
}

int SpikeEvent::time_to_postburst_fast_ahp(mapStr2intVec& IntFeatureData,
Expand Down
20 changes: 16 additions & 4 deletions efel/cppcore/SpikeShape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,10 @@ int SpikeShape::min_AHP_indices(mapStr2intVec& IntFeatureData,
int SpikeShape::min_AHP_values(mapStr2intVec& IntFeatureData,
mapStr2doubleVec& DoubleFeatureData,
mapStr2Str& StringData) {
return 1;
const auto& intFeatures = getFeatures(IntFeatureData, {"min_AHP_indices"});
int retVal = intFeatures.at("min_AHP_indices").size();
if (retVal <= 0) return -1;
return retVal;
}

// Difference with SpikeShape is that this function doesn't return -1 if there are no
Expand Down Expand Up @@ -550,7 +553,10 @@ int SpikeShape::AHP_depth_abs_slow(mapStr2intVec& IntFeatureData,
int SpikeShape::AHP_slow_time(mapStr2intVec& IntFeatureData,
mapStr2doubleVec& DoubleFeatureData,
mapStr2Str& StringData) {
return 1;
const auto& doubleFeatures = getFeatures(DoubleFeatureData, {"AHP_depth_abs_slow"});
int retVal = doubleFeatures.at("AHP_depth_abs_slow").size();
if (retVal <= 0) return -1;
return retVal;
}

// *** AHP_depth_slow ***
Expand Down Expand Up @@ -818,7 +824,10 @@ int SpikeShape::ADP_peak_indices(mapStr2intVec& IntFeatureData,
int SpikeShape::ADP_peak_values(mapStr2intVec& IntFeatureData,
mapStr2doubleVec& DoubleFeatureData,
mapStr2Str& StringData) {
return 1;
const auto& intFeatures = getFeatures(IntFeatureData, {"ADP_peak_indices"});
int retVal = intFeatures.at("ADP_peak_indices").size();
if (retVal <= 0) return -1;
return retVal;
}

// strict_stiminterval should be True when using this feature
Expand Down Expand Up @@ -994,7 +1003,10 @@ int SpikeShape::min_between_peaks_indices(mapStr2intVec& IntFeatureData,
int SpikeShape::min_between_peaks_values(mapStr2intVec& IntFeatureData,
mapStr2doubleVec& DoubleFeatureData,
mapStr2Str& StringData) {
return 1;
const auto& intFeatures = getFeatures(IntFeatureData, {"min_between_peaks_indices"});
int retVal = intFeatures.at("min_between_peaks_indices").size();
if (retVal <= 0) return -1;
return retVal;
}

// *** AP_duration_half_width according to E8 and E16 ***
Expand Down

0 comments on commit e1f5966

Please sign in to comment.