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

Find centre of rotation #24

Open
wants to merge 50 commits into
base: main
Choose a base branch
from

Conversation

lauraporta
Copy link
Member

@lauraporta lauraporta commented Sep 19, 2024

Description

What is this PR

  • Bug fix
  • Addition of a new feature
  • Other

Why is this PR needed?
See #12

What does this PR do?

Creates methods and pipeline to find the centre of rotation in the incremental dataset.

⚠️ It does not fix the wobbling issues. The pipeline works well with simulated data but worsens the real datasets.

Pipeline

Find the centre

Find the centre of rotation using the incremental rotations datasets, in which the sample was rotated at discrete angles with 10deg intervals. Centre of rotation is found by fitting an ellipse to the brightest ROI location at each of the 10deg configurations.
New methods include:

  • find_center_of_rotation
  • get_coords_of_largest_blob
  • plot_blob_detection
  • fit_ellipse_to_points
  • plot_ellipse_fit_and_centers

ellipse_fit

max_projection_with_center

Use the new centre

In order to use the new centre of rotation, the derotate_an_image_array_line_by_line needed to be totally rewritten. I am discarding the usage of scipy.ndimage.rotate and using classic linear algebra to rotate the matrices. With this new implementation the derotation is so much faster! 🚀

How has this PR been tested?

The performance of the de-rotation when the centre of rotation is shifted has been tested with simulated data generated by the class Rotator.

I created a stepwise array of angles to imitate the incremental rotation dataset, and a sinusoidal array as the main experimental session dataset.
rotation_angles

I then rotated a sample image that has two blobs that imitate two ROIs (one brighter than the other).
test_image

Ellipse fit works well with a shifted centre:
ellipse_fit

And derotation works smothly. This is the proof that in principle my derotation with shifted centres works.

I added tests to cover this new functionality and the pipeline.

Is this a breaking change?

No

Checklist:

  • The code has been tested locally
  • Tests have been added to cover all new functionality
  • The documentation has been updated to reflect any changes
  • The code has been formatted with pre-commit

@lauraporta lauraporta linked an issue Sep 19, 2024 that may be closed by this pull request
… feature - also make separate module for hooks
This was referenced Oct 2, 2024
@lauraporta lauraporta changed the base branch from main to feature/rotator October 3, 2024 15:04
@lauraporta lauraporta changed the base branch from feature/rotator to main October 3, 2024 15:20
@lauraporta lauraporta marked this pull request as ready for review October 3, 2024 15:24
@lauraporta lauraporta marked this pull request as draft October 3, 2024 15:24
Copy link

codecov bot commented Oct 3, 2024

Codecov Report

Attention: Patch coverage is 65.42553% with 65 lines in your changes missing coverage. Please review.

Project coverage is 44.33%. Comparing base (3e797a4) to head (3f631bf).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...tation/analysis/incremental_derotation_pipeline.py 51.48% 49 Missing ⚠️
derotation/analysis/full_derotation_pipeline.py 26.31% 14 Missing ⚠️
derotation/derotate_by_line.py 93.33% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main      #24       +/-   ##
===========================================
+ Coverage   20.39%   44.33%   +23.94%     
===========================================
  Files          12        6        -6     
  Lines         760      636      -124     
===========================================
+ Hits          155      282      +127     
+ Misses        605      354      -251     

☔ 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 October 4, 2024 10:37
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.

Find optimal centre of rotations
1 participant