Skip to content

127 implement mims#193

Merged
frey-perez merged 34 commits into
mainfrom
127-implement-mims
Jun 6, 2025
Merged

127 implement mims#193
frey-perez merged 34 commits into
mainfrom
127-implement-mims

Conversation

@frey-perez
Copy link
Copy Markdown
Collaborator

@frey-perez frey-perez commented May 6, 2025

frey-perez and others added 13 commits January 17, 2025 10:33
* testing time  values, adding test data from R.

* testing values

* changed interpolate test to correlation

* doc strings

* ruff error.

* failing matrix test for older version of polars.

* interpolation correction

* testing values

* review changes + added md file from old branch.

* typo.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* step 1: find maxed out probabilities

* All major steps before final interpolation.

* minor renaming

* working version, partially updated doc strings.

* initial testing

* Doc strings

* further testing, doc strings changes.

* Final testing, error checks in metrics.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Superfluous print statements, doc string edit.

* minor parameter changes

* scipy ruff error

* removing.whl

* github  actions- ruff- scipy issue.

* initial changes.

* superfluous

* formatting

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* step 1: find maxed out probabilities

* All major steps before final interpolation.

* minor renaming

* working version, partially updated doc strings.

* initial testing

* Doc strings

* further testing, doc strings changes.

* Final testing, error checks in metrics.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Superfluous print statements, doc string edit.

* minor parameter changes

* scipy ruff error

* removing.whl

* github  actions- ruff- scipy issue.

* initial changes.

* superfluous

* formatting

* butterworth_filter

* aggregate+filter

* basic test, test data.

* further testing.

* Final testing, doc strings.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* set sorted error

* np.trapezoid error, imports error.

* mypy errors

* numpy timestamps normalization.

* max value issue

* max_value second fix.

* Max value aggregatoin bug.

* scipy trapezoid replacing numpy implementation

* missed an instance of np.trapezoid.

* variable name change.

* doc string change.

* tuple fix, other comments.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* independent mims module.

* combined_mims

* sample_data

* overall test

* paramertrize

* documentation

* note on extra timestamp

* spacing.

* documentation

* test error

* Update src/wristpy/processing/mims.py

Co-authored-by: Adam Santorelli <148909356+Asanto32@users.noreply.github.com>

* seperate mims testing.

* moving fixtures, reorganized testing.

* epochs are floats, truncation moved, new truncation argument.

* doc change.

* doc string, type hinting.

* typing error.

* updated markdown.

* markdown capitalization.

* doc string

---------

Co-authored-by: Adam Santorelli <148909356+Asanto32@users.noreply.github.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 6, 2025

Codecov Report

Attention: Patch coverage is 95.37037% with 10 lines in your changes missing coverage. Please review.

Project coverage is 95.96%. Comparing base (8ae0163) to head (4f04c46).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/wristpy/processing/mims.py 95.74% 8 Missing ⚠️
src/wristpy/core/orchestrator.py 85.71% 1 Missing ⚠️
src/wristpy/io/readers/readers.py 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #193      +/-   ##
==========================================
- Coverage   96.14%   95.96%   -0.19%     
==========================================
  Files          13       14       +1     
  Lines         778      991     +213     
==========================================
+ Hits          748      951     +203     
- Misses         30       40      +10     

☔ View full report in Codecov by Sentry.
📢 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.

@frey-perez frey-perez marked this pull request as ready for review May 16, 2025 15:54
@frey-perez frey-perez requested a review from Asanto32 May 16, 2025 15:54
@frey-perez frey-perez requested a review from reindervdw-cmi May 16, 2025 15:54
thresholds = thresholds or (0.029, 0.338, 0.604)
elif activity_metric == "ag_count":
thresholds = thresholds or (100, 3000, 5200)
elif activity_metric == "mims":
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can probably add a test for mims in test_orchestrator? To make sure it handles the dynamic range/thresholds properly?

Comment thread tests/unit/test_readers.py Outdated
Comment thread src/wristpy/core/cli.py Outdated
Comment thread src/wristpy/core/orchestrator.py Outdated
frey-perez and others added 3 commits May 20, 2025 17:58
Co-authored-by: Adam Santorelli <148909356+Asanto32@users.noreply.github.com>
Comment thread src/wristpy/io/readers/readers.py Outdated
Comment thread src/wristpy/processing/mims.py

else:
right = right[1:]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should this have an elif abs(len(left) - len(right)) > 1 error handler?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

should be covered by the error handling at the top of the function right?

if np.abs(len(left) - len(right)) >= 2:
        raise ValueError(
            f"Mismatch in {sign} edges. # left: {len(left)}, # right: {len(right)}"
        )

Comment thread src/wristpy/processing/mims.py Outdated

Args:
marker_length: Length of marker array.
left: indices indicating the left edge of a potential maxed-out region.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Define that these are vectors (assuming that they are indeed 1-dimensional vectors)

non_maxed_out_mask = np.abs(marker) < confidence_threshold
num_non_maxed = np.sum(non_maxed_out_mask)

if num_non_maxed / len(marker) < 0.3:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

where does this 0.3 "magic" value come from

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

https://github.com/mHealthGroup/MIMSunit/blob/master/R/extrapolate.R#L686-L689

That's the threshold they used for this here, didn't find any particular justification.

Comment thread src/wristpy/io/readers/readers.py Outdated

dynamic_range = _extract_dynamic_range(
metadata=data["metadata"],
file_type=file_type, # type: ignore
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

make the type ignore specific

@frey-perez frey-perez merged commit 4ed8686 into main Jun 6, 2025
26 checks passed
@frey-perez frey-perez deleted the 127-implement-mims branch June 6, 2025 17:27
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.

Task: Implement Monitor Independent Monitor Summary unit (MIMS)

3 participants