Skip to content

[Fix] Calculate RSP phase durations from sample positions - #1201

Open
bipin-vishwakarma wants to merge 2 commits into
neuropsychology:devfrom
bipin-vishwakarma:fix-rsp-epoch-phase-duration
Open

[Fix] Calculate RSP phase durations from sample positions#1201
bipin-vishwakarma wants to merge 2 commits into
neuropsychology:devfrom
bipin-vishwakarma:fix-rsp-epoch-phase-duration

Conversation

@bipin-vishwakarma

Copy link
Copy Markdown

Summary

  • calculate respiratory phase durations from row/sample positions instead of DataFrame index labels
  • preserve existing behavior for continuous signals while fixing time-indexed epochs
  • add a regression test comparing continuous and epoched representations

Why

epochs_create() uses time values for the DataFrame index. Treating those labels as sample numbers and dividing by sampling_rate scales phase durations down a second time.

Fixes #1196.

Tests

  • pytest tests/tests_rsp.py -k "rsp_intervalrelated" -q -o addopts="" (2 passed)
  • complete tests/tests_rsp.py module: 25 passed across the regular run and the report test rerun with MPLBACKEND=Agg (local Python lacks Tk data)
  • ruff check neurokit2/rsp/rsp_intervalrelated.py tests/tests_rsp.py
  • ruff format --check neurokit2/rsp/rsp_intervalrelated.py tests/tests_rsp.py

@welcome

welcome Bot commented Aug 11, 2026

Copy link
Copy Markdown

Thanks for opening this pull request! We'll make sure it's perfect before merging 🤗 force
Make sure to read the contributing guide. Also, if you think that your contribution is worthy of it, you can consider adding yourself to the Contributors list (feel free to ask us if you have any doubts).

@codecov-commenter

codecov-commenter commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.17%. Comparing base (9f3a1a5) to head (64dbbc8).

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #1201   +/-   ##
=======================================
  Coverage   58.17%   58.17%           
=======================================
  Files         310      310           
  Lines       15702    15703    +1     
=======================================
+ Hits         9135     9136    +1     
  Misses       6567     6567           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants