phys2bids icon indicating copy to clipboard operation
phys2bids copied to clipboard

IndexError when slicing last run

Open sangfrois opened this issue 4 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 (9073c65) into master (72ffc15) will not change coverage. The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #415   +/-   ##
=======================================
  Coverage   94.42%   94.42%           
=======================================
  Files           8        8           
  Lines         879      879           
=======================================
  Hits          830      830           
  Misses         49       49           
Impacted Files Coverage Δ
phys2bids/slice4phys.py 92.10% <ø> (ø)

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

Hey @sangfrois! Could you pull from master, resolve conflicts, and push?

smoia avatar Dec 12 '22 12:12 smoia

everything should be good to merge! Let me know if you need me to do anything more!

sangfrois avatar Dec 12 '22 20:12 sangfrois