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 AP_begin_indices-dependent features #minor #353

Merged
merged 10 commits into from
Jan 11, 2024

Conversation

AurelienJaquier
Copy link
Collaborator

@AurelienJaquier AurelienJaquier commented Jan 10, 2024

Pull Request Template

Fixes a few of AP_begin_indices dependent feature to make them behave like AP_begin_indices, i.e. do not take into account spikes before stim_start, but take into account spikes after stim_end.

Features changed: AP_end_indices, AP_rise_time, AP_fall_time, AP_rise_rate, AP_fall_rate
Also fixes other features dependent on them, like AP_duration

Description

Please include a summary of the change.
By default the change will increment the patch version.
To increment major or minor changes add #major or #minor to the PR description.

Checklist:

  • Unit tests are added to cover the changes.
  • The changes are mentioned in the documentation.
  • CHANGELOG.md is updated (skip if the change is not important for the changelog).

@AurelienJaquier AurelienJaquier marked this pull request as ready for review January 10, 2024 14:39
…P-end-indices

Conflicts:
	efel/cppcore/LibV2.cpp
	efel/cppcore/LibV5.cpp
@codecov-commenter
Copy link

codecov-commenter commented Jan 10, 2024

Codecov Report

Attention: 27 lines in your changes are missing coverage. Please review.

Comparison is base (2bd34e6) 65.86% compared to head (cb35767) 65.95%.

Files Patch % Lines
efel/cppcore/LibV2.cpp 44.00% 0 Missing and 14 partials ⚠️
efel/cppcore/LibV5.cpp 35.71% 1 Missing and 8 partials ⚠️
efel/cppcore/Utils.cpp 71.42% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #353      +/-   ##
==========================================
+ Coverage   65.86%   65.95%   +0.09%     
==========================================
  Files          33       33              
  Lines        6380     6445      +65     
  Branches     2262     2284      +22     
==========================================
+ Hits         4202     4251      +49     
- Misses        262      265       +3     
- Partials     1916     1929      +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -26,6 +26,7 @@
#include <deque>
#include <functional>
#include <iterator>
#include <iostream>
Copy link
Contributor

Choose a reason for hiding this comment

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

Was iostream required while debugging?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oops, I made a few cout while debugging and forgot to remove it. I'll remove it just wait a few secs

Copy link
Contributor

Choose a reason for hiding this comment

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

I also do that often :))

Comment on lines 334 to 339
vector<int> newpeakindices;
for (size_t i=0; i < peakindices.size(); i++) {
if (t[peakindices[i]] > stimstart) {
newpeakindices.push_back(peakindices[i]);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This pattern occurs in multiple places. It can be reused now and also in the future. Can you put it into a function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Implemented in latest commit. Tell me if it looks good to you

Comment on lines 204 to 214
int peaks_after_stim_start(const double stimstart,
const vector<int>& peakindices,
const vector<double>& t,
vector<int>& newpeakindices){
for (size_t i=0; i < peakindices.size(); i++) {
if (t[peakindices[i]] > stimstart) {
newpeakindices.push_back(peakindices[i]);
}
}
return 1;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, since C++11 this can be shortened as follows. The compiler applies return value optimisation to avoid copy/move operations.

vector<int> peaks_after_stim_start(const double stimstart,
                                   const vector<int>& peakindices,
                                   const vector<double>& t) {
    vector<int> newpeakindices;
    for (size_t i = 0; i < peakindices.size(); i++) {
        if (t[peakindices[i]] > stimstart) {
            newpeakindices.push_back(peakindices[i]);
        }
    }
    return newpeakindices;
}

and the usage can be simplified like this

vector<int> newpeakindices = peaks_after_stim_start(stimstart, peakindices, t);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done in latest commit

Comment on lines 217 to 226
int peaks_after_stim_start(const double stimstartindex,
const vector<int>& peakindices,
vector<int>& newpeakindices){
for (size_t i=0; i < peakindices.size(); i++) {
if (peakindices[i] > stimstartindex) {
newpeakindices.push_back(peakindices[i]);
}
}
return 1;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of the above function can't this one be used if t[peakindices[i]] is sent as an argument (instead of both t and peakindices)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm sorry, I'm not sure I understand. We don't have i yet when we call the function. Also the type would not match. Or am I missing something?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah yes you're right. Ok then returning vector directly here also would be more than enough :).

vector<int> peaks_after_stim_start(const double stimstartindex,
                                   const vector<int>& peakindices){
  vector<int> newpeakindices;
  for (size_t i = 0; i < peakindices.size(); i++) {
    if (peakindices[i] > stimstartindex) {
      newpeakindices.push_back(peakindices[i]);
    }
  }
  return newpeakindices;
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done in latest commit

Copy link
Contributor

@anilbey anilbey left a comment

Choose a reason for hiding this comment

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

Thanks looks very good to me. Could you just add a test and a changelog entry please?

@AurelienJaquier AurelienJaquier changed the title Fix AP_begin_indices-dependent features Fix AP_begin_indices-dependent features #minor Jan 11, 2024
@AurelienJaquier
Copy link
Collaborator Author

changelog and tests done in latest commits

Copy link
Contributor

@anilbey anilbey left a comment

Choose a reason for hiding this comment

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

Brilliant! Thanks a lot

@AurelienJaquier AurelienJaquier merged commit 3ffb816 into BlueBrain:master Jan 11, 2024
8 checks passed
@AurelienJaquier AurelienJaquier deleted the fix-AP-end-indices branch January 11, 2024 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants