Skip to content

Derotate with shifts and ellipses#35

Merged
lauraporta merged 23 commits intomainfrom
feature/rotator-bug-fix
Feb 14, 2025
Merged

Derotate with shifts and ellipses#35
lauraporta merged 23 commits intomainfrom
feature/rotator-bug-fix

Conversation

@lauraporta
Copy link
Copy Markdown
Member

@lauraporta lauraporta commented Feb 3, 2025

Description

Screenshot 2025-02-04 at 13 26 56

Type of PR

  • Bug fix
  • New feature
  • Other

Why is this PR needed?

This PR enables the derotation of movies where the transformation is elliptical, leveraging homography and shear principles. It also addresses key bugs in the Rotator class.

Summary of Changes

Main Updates:

  1. Fixed multiple bugs in the Rotator class.
  2. Integrated apply_homography into the main derotation function.
  3. Improved docstrings throughout the codebase.
  4. Added logic for calculating orientation and rotation angle in the fit_ellipse module, ensuring a fully integrated test pipeline.

Refactoring:

  1. Split the large integration test (tests/test_integration/test_finding_center_of_rotation.py) into two separate components:
    • derotation/simulate/synthetic_data.py: Contains logic to generate synthetic rotated and derotated movies for tests and examples.
    • tests/test_integration/test_derotation_with_simulated_data.py: An integration test using synthetic data.
    • This test can also be run as a script to generate figures, aiding in the development of new derotation features.
  2. Conceptual change in testing approach: Instead of feeding a fixed center of rotation, we now specify the shift from the expected center based on image shape. This ensures compatibility with images of various sizes.
  3. Moved blob detection logic: Previously in incremental_derotation_pipeline, now extracted into a dedicated blob_detection module. Its functionalities help in the following:
    • Identify cell positions post-rotation.
    • Fit ellipses.
    • Assess derotation quality—if the blob centers remain stable, the derotation is considered successful.

Testing

  • Added test cases covering various critical parameters.
  • Tests generate debugging plots to aid analysis.

Breaking Changes

  • No breaking changes introduced.

Documentation Updates

  • Updated relevant docstrings.

Checklist

  • Code has been tested locally.
  • Added tests for all new functionality.
  • Updated documentation to reflect changes.
  • Code formatted using pre-commit.

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 4, 2025

Codecov Report

Attention: Patch coverage is 67.04981% with 86 lines in your changes missing coverage. Please review.

Project coverage is 51.56%. Comparing base (5d95792) to head (66b5353).
Report is 24 commits behind head on main.

Files with missing lines Patch % Lines
derotation/simulate/synthetic_data.py 59.28% 68 Missing ⚠️
derotation/analysis/blob_detection.py 57.89% 16 Missing ⚠️
derotation/derotate_by_line.py 90.90% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #35      +/-   ##
==========================================
+ Coverage   47.26%   51.56%   +4.29%     
==========================================
  Files           7        9       +2     
  Lines         677      894     +217     
==========================================
+ Hits          320      461     +141     
- Misses        357      433      +76     

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

@lauraporta lauraporta marked this pull request as ready for review February 4, 2025 13:33
@lauraporta lauraporta force-pushed the feature/rotator-bug-fix branch from c99dc37 to 25381ae Compare February 4, 2025 17:39
Copy link
Copy Markdown
Member

@IgorTatarnikov IgorTatarnikov left a comment

Choose a reason for hiding this comment

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

Looks good, just a few comments here and there

Copy link
Copy Markdown
Member Author

@lauraporta lauraporta left a comment

Choose a reason for hiding this comment

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

Thank you, I've committed a few of your suggestions

lauraporta and others added 8 commits February 14, 2025 15:07
Co-authored-by: Igor Tatarnikov <61896994+IgorTatarnikov@users.noreply.github.com>
Co-authored-by: Igor Tatarnikov <61896994+IgorTatarnikov@users.noreply.github.com>
Co-authored-by: Igor Tatarnikov <61896994+IgorTatarnikov@users.noreply.github.com>
Co-authored-by: Igor Tatarnikov <61896994+IgorTatarnikov@users.noreply.github.com>
Co-authored-by: Igor Tatarnikov <61896994+IgorTatarnikov@users.noreply.github.com>
Co-authored-by: Igor Tatarnikov <61896994+IgorTatarnikov@users.noreply.github.com>
@lauraporta lauraporta merged commit 41416e1 into main Feb 14, 2025
12 checks passed
@lauraporta lauraporta deleted the feature/rotator-bug-fix branch April 8, 2025 15:17
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.

More features to the Rotator / microscope simulation Rotation plane misalignment Increase test coverage

2 participants