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

Allow expanded physical signal in calc_adc_params #512

Merged
merged 3 commits into from
Nov 25, 2024

Conversation

briangow
Copy link
Contributor

This PR updates calc_adc_params to allow an expanded physical signal to be passed. Previously only a non-expanded signal was allowed. The function will now calculate the adc_gain and baseline for p_signal or e_p_signal.

I check for the signal that is not None and then compute the gain and baseline. I moved the calculation itself to a new function calc_adc_gain_baseline so we could call it for either signal type.

@briangow briangow requested a review from bemoody October 29, 2024 14:13
@bemoody
Copy link
Collaborator

bemoody commented Oct 31, 2024

Thanks!

It could be optimized somewhat: calculating min/max using a generator expression

minvals.append(min(x for x in ch if not math.isnan(x)))

will be slower than doing it with numpy. But the important thing is that it works.

It would be good to add a test case; currently it looks like there is no test coverage for calc_adc_params. The easiest way to test it is using wfdb.wrsamp. So we should do that as a follow-up after merging this and #510.

@briangow
Copy link
Contributor Author

briangow commented Nov 4, 2024

Thanks!

It could be optimized somewhat: calculating min/max using a generator expression

minvals.append(min(x for x in ch if not math.isnan(x)))
will be slower than doing it with numpy. But the important thing is that it works.

It would be good to add a test case; currently it looks like there is no test coverage for calc_adc_params. The easiest way to test it is using wfdb.wrsamp. So we should do that as a follow-up after merging this and #510.

@bemoody , I have updated the code to use np.nanmin and np.nanmax instead of the generator function, as suggested.

I can look into adding a test once these PRs are merged.

Copy link
Collaborator

@bemoody bemoody left a comment

Choose a reason for hiding this comment

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

This looks good!

@bemoody bemoody merged commit 86028c4 into main Nov 25, 2024
14 checks passed
@bemoody bemoody deleted the bg_expanded_adc_params branch November 25, 2024 20:23
tompollard added a commit that referenced this pull request Jan 21, 2025
This pull request adds a changelog for `v4.2.0`. The changelog is based
on the following auto-generated summary of merge commits generated by
GitHub:

```
## What's Changed

* bug-fix: Numpy ValueError when cheking empty list equality by @ajadczaksunriselabs in #459
* bug-fix: Pandas set indexing error by @ajadczaksunriselabs in #460
* fix for /issues/452 by @tecamenz in #465
* Use numpydoc to render documentation by @SnoopJ in #472
* build(deps): bump readthedocs-sphinx-search from 0.1.1 to 0.3.2 in /docs by @dependabot in #477
* Update style by @bemoody in #482
* Fix NaN handling in Record.adc, and other fixes by @bemoody in #481
* Set upper bound on Numpy version (numpy = ">=1.10.1,<2.0.0"). Ref #493. by @tompollard in #494
* Update actions to use actions/checkout@v3 and actions/setup-python@v4. by @tompollard in #495
* Fix: Indent code to ensure 'j' is within for-loop in GQRS algorithm by @tompollard in #499
* Add write_dir argument to csv_to_wfdb. Fixes #67. by @tompollard in #492
* Fix warnings by @cbrnr in #502
* README improvements by @bemoody in #503
* Change in type promotion. Fixes to annotation.py by @tompollard in #506
* Use uv by @cbrnr in #504
* Change in type promotion. Fixes to _signal.py by @tompollard in #507
* Test round-trip write/read of supported binary formats by @bemoody in #509
* Corrected typo and extended allowed types for MultiSegmentRecord by @agent3gatech in #514
* Allow expanded physical signal in `calc_adc_params` by @briangow in #512
* Add capability to write signal with unique `samps_per_frame` to `wfdb.io.wrsamp` by @briangow in #510
* Fix selection of channels when converting to EDF by @SamJelfs in #519
* Change in type promotion introduced in Numpy 2.0. Fixes to edf.py. by @tompollard in #527
* Bump dependencies for NumPy 2 compatibility by @cbrnr in #511
* Bump version to v4.2.0 and update notes on creating new releases by @tompollard in #497

## New Contributors

* @ajadczaksunriselabs made their first contribution in #459
* @tecamenz made their first contribution in #465
* @SnoopJ made their first contribution in #472
* @dependabot made their first contribution in #477
* @agent3gatech made their first contribution in #514
* @SamJelfs made their first contribution in #519

**Full Changelog**: v4.1.2...v4.2.0
```
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.

2 participants