Skip to content

Skip angles with no frames in calculate_mean_images - #73

Draft
Sarthak-Shreshtha01 wants to merge 1 commit into
neuroinformatics-unit:mainfrom
Sarthak-Shreshtha01:fix/mean-images-missing-angles
Draft

Sarthak-Shreshtha01 wants to merge 1 commit into
neuroinformatics-unit:mainfrom
Sarthak-Shreshtha01:fix/mean-images-missing-angles

Conversation

@Sarthak-Shreshtha01

Copy link
Copy Markdown
Contributor

calculate_mean_images makes one mean image for each of 10, 20, ..., 350 degrees. When no frame has a given angle, for example when a recording only covers 0 to 180 degrees, np.mean of the empty selection returns an all-NaN image with a RuntimeWarning. It does not raise IndexError, so the except branch never ran: the NaN images were added to the result and the "Angle not found" warning was never logged.

With angles 0 to 180 in steps of 1 degree, 17 of the 35 returned images were all NaN. These images go on to blob detection when finding the center of rotation (IncrementalPipeline) and in the Bayesian optimisation.

This change skips angles with no frames and logs the warning for them. I added tests/test_unit/test_mean_images.py, which fails before the change and passes after it. The full test suite and the pre-commit hooks pass locally.

np.mean of an empty selection returns an all-NaN image with a
RuntimeWarning, not an IndexError, so missing angles were added to the
result as NaN images and the warning was never logged.

Signed-off-by: Sarthak <sarthakshreshtha345@gmail.com>
@codecov

codecov Bot commented Oct 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 45.43%. Comparing base (9204b2b) to head (b56ede6).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #73      +/-   ##
==========================================
+ Coverage   45.08%   45.43%   +0.34%     
==========================================
  Files          14       14              
  Lines        1129     1127       -2     
==========================================
+ Hits          509      512       +3     
+ Misses        620      615       -5     

☔ 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.

This branch has not been deployed

No deployments
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.

1 participant