phys2bids
phys2bids copied to clipboard
IndexError when slicing last run
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 atry: ... 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!
Codecov Report
Merging #415 (fe78e5e) into master (7369827) will decrease coverage by
0.32%
. The diff coverage is40.00%
.
@@ 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: |
@sangfrois do you have a file that we can use to test this particular situation?