Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix AHP_slow_time and min_AHP_values #394

Merged
merged 7 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions efel/cppcore/SpikeShape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ int SpikeShape::min_AHP_indices(mapStr2intVec& IntFeatureData,
int SpikeShape::min_AHP_values(mapStr2intVec& IntFeatureData,
mapStr2doubleVec& DoubleFeatureData,
mapStr2Str& StringData) {
return -1;
return 1;
}

// Difference with SpikeShape is that this function doesn't return -1 if there are no
Expand Down Expand Up @@ -550,7 +550,7 @@ int SpikeShape::AHP_depth_abs_slow(mapStr2intVec& IntFeatureData,
int SpikeShape::AHP_slow_time(mapStr2intVec& IntFeatureData,
mapStr2doubleVec& DoubleFeatureData,
mapStr2Str& StringData) {
return -1;
return 1;
}

// *** AHP_depth_slow ***
Expand Down
5 changes: 4 additions & 1 deletion efel/cppcore/cfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,10 @@ int cFeature::getFeature(string strName, vector<T>& vec) {
return -1;
}
vec = getMapData<T>(strName, *dataMap);
if (vec.empty()) GErrorStr += "Feature [" + strName + "] data is missing\n";
if (vec.empty()) {
GErrorStr += "Feature [" + strName + "] data is missing\n";
return -1;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will turn empty lists into None

}

logger << "Calculated feature " << strName << ":" << vec << endl;
return vec.size();
Expand Down
4 changes: 2 additions & 2 deletions efel/pyfeatures/pyfeatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def spikes_per_burst():
burst_begin_indices = get_cpp_feature("burst_begin_indices")
burst_end_indices = get_cpp_feature("burst_end_indices")

if burst_begin_indices is None:
if burst_begin_indices is None or len(burst_begin_indices) < 1:
return None

ap_per_bursts = []
Expand All @@ -304,7 +304,7 @@ def spikes_per_burst():
def spikes_per_burst_diff():
"""Calculate the diff between the spikes in each burst and the next one"""
spikes_per_burst_values = spikes_per_burst()
if spikes_per_burst_values is None:
if spikes_per_burst_values is None or len(spikes_per_burst_values) < 2:
return None

return spikes_per_burst_values[:-1] - spikes_per_burst_values[1:]
Expand Down
16 changes: 8 additions & 8 deletions tests/testdata/allfeatures/expectedresults.json
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,8 @@
"interburst_60percent_indices": null,
"interburst_60percent_values": null,
"interburst_duration": null,
"interburst_min_indices": [],
"interburst_min_values": [],
"interburst_min_indices": null,
"interburst_min_values": null,
"interburst_voltage": [
-38.820613862535545
],
Expand Down Expand Up @@ -624,7 +624,7 @@
"strict_burst_number": [
1
],
"strict_interburst_voltage": [],
"strict_interburst_voltage": null,
"time": [
0.0,
0.1,
Expand Down Expand Up @@ -30632,7 +30632,7 @@
"time_to_first_spike": [
8.000000000092427
],
"time_to_interburst_min": [],
"time_to_interburst_min": null,
"time_to_last_spike": [
1937.7999999986964
],
Expand Down Expand Up @@ -60680,7 +60680,7 @@
"spikes_per_burst": [
2
],
"spikes_per_burst_diff": [],
"spikes_per_burst_diff": null,
"spikes_in_burst1_burst2_diff": null,
"spikes_in_burst1_burstlast_diff": null,
"depol_block": null,
Expand Down Expand Up @@ -60723,7 +60723,7 @@
"strict_burst_mean_freq": [
7.99041151
],
"strict_interburst_voltage": [],
"strict_interburst_voltage": null,
"ADP_peak_amplitude": [
0.0,
2.6873666528663236,
Expand All @@ -60748,8 +60748,8 @@
-41.12299346923828,
-38.12341871769886
],
"interburst_min_indices": [],
"interburst_min_values": [],
"interburst_min_indices": null,
"interburst_min_values": null,
"postburst_min_indices": [
26465
],
Expand Down