phys2bids icon indicating copy to clipboard operation
phys2bids copied to clipboard

IndexError when slicing last run

Open sangfrois opened this issue 2 years ago • 2 comments

Issue

Workflow crashes when the last recorded run doesn't have enough signal at the end. This is caused by the padding added at the end of the run.

A simple fix for that error was to deal with the exception.

Like this :

try:
    run_end = int(np.where(phys_in.timeseries[0] > end_sec)[0][0] + padding)
except IndexError:
    run_end = phys_in.timeseries[0].shape[0]

The end of the run becomes the last index of the timeserie.

Proposed Changes

  • slice4phys.py now contains a try: ... except IndexError statement.

Change Type

  • [x] bugfix (+0.0.1)
  • [ ] minor (+0.1.0)
  • [ ] major (+1.0.0)
  • [ ] refactoring (no version update)
  • [ ] test (no version update)
  • [ ] infrastructure (no version update)
  • [ ] documentation (no version update)
  • [ ] other

Checklist before review

  • [x] I added everything I wanted to add to this PR.
  • [ ] [Code or tests only] I wrote/updated the necessary docstrings.
  • [ ] [Code or tests only] I ran and passed tests locally.
  • [ ] [Documentation only] I built the docs locally.
  • [x] My contribution is harmonious with the rest of the code: I'm not introducing repetitions.
  • [x] My code respects the adopted style, especially linting conventions.
  • [x] The title of this PR is explanatory on its own, enough to be understood as part of a changelog.
  • [x] I added or indicated the right labels.
  • [ ] I added information regarding the timeline of completion for this PR.
  • [ ] Please, comment on my PR while it's a draft and give me feedback on the development!

sangfrois avatar Nov 18 '21 18:11 sangfrois

Codecov Report

Merging #415 (fe78e5e) into master (7369827) will decrease coverage by 0.32%. The diff coverage is 40.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #415      +/-   ##
==========================================
- Coverage   94.81%   94.49%   -0.33%     
==========================================
  Files           8        8              
  Lines         868      872       +4     
==========================================
+ Hits          823      824       +1     
- Misses         45       48       +3     
Impacted Files Coverage Δ
phys2bids/slice4phys.py 89.74% <40.00%> (-7.40%) :arrow_down:

codecov[bot] avatar Nov 22 '21 10:11 codecov[bot]

@sangfrois do you have a file that we can use to test this particular situation?

smoia avatar Nov 22 '21 11:11 smoia