Skip to content

Run multiple datasets and evaluate quality of derotation#38

Merged
lauraporta merged 27 commits intomainfrom
metrics-and-batch
Mar 17, 2025
Merged

Run multiple datasets and evaluate quality of derotation#38
lauraporta merged 27 commits intomainfrom
metrics-and-batch

Conversation

@lauraporta
Copy link
Copy Markdown
Member

@lauraporta lauraporta commented Feb 14, 2025

Description

What is this PR

  • Bug fix
  • Addition of a new feature
  • Other

Why is this PR needed?
This new PR adds essential adaptations to run derotation on multiple datasets, which include fixing some bugs that were not evident and refined strategies to find the center of rotation.

What does this PR do?
Center of rotation can be found in two ways:

  • using the incremental rotation package as before, and an improved version of fit_ellipse.py. This PR solves issues related to NaNs handling in the centers list and better boundaries constraints.
  • using only the experimental dataset with 80 rotations and minimizing the PTD (a metric that signals quality of derotation by tracking a unique blob) value with different centers with bayesian optimization (BO). See bayesian_optimization.py. For this purpose the function calculate_mean_images has been exported in a separate file.

Running on multiple datasets via an external call:

  • a new script called derotate_batch.py handles the call to the full pipeline and prepares the configuration script with the correct paths. Uses BO to find the best center of rotation
  • consequentially the FullPipeline class has been adapted to accept a dict config object. It also handles the call to the BO class.
  • config.yml file has been updated to expose parameters useful for the BO.

Other minor adjustments are present, including calculations of angular velocity and related debugging plot! Very useful when dealing with different datasets that might have motor artefacts...

A few examples of the new plots:
rotation_angles 14 36 14

References

Issues linked.

How has this PR been tested?

Previous tests pass.

Is this a breaking change?

No.

Does this PR require an update to the documentation?

N/A

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 marked this pull request as ready for review March 10, 2025 14:28
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 10, 2025

Codecov Report

Attention: Patch coverage is 22.64151% with 246 lines in your changes missing coverage. Please review.

Project coverage is 43.71%. Comparing base (41416e1) to head (250e5e1).

Files with missing lines Patch % Lines
derotation/analysis/full_derotation_pipeline.py 11.25% 142 Missing ⚠️
derotation/derotate_batch.py 0.00% 35 Missing ⚠️
derotation/analysis/metrics.py 19.51% 33 Missing ⚠️
derotation/analysis/bayesian_optimization.py 34.28% 23 Missing ⚠️
derotation/analysis/mean_images.py 72.72% 6 Missing ⚠️
derotation/analysis/fit_ellipse.py 78.57% 3 Missing ⚠️
derotation/simulate/synthetic_data.py 60.00% 2 Missing ⚠️
derotation/analysis/blob_detection.py 0.00% 1 Missing ⚠️
...tation/analysis/incremental_derotation_pipeline.py 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #38      +/-   ##
==========================================
- Coverage   51.56%   43.71%   -7.86%     
==========================================
  Files           9       13       +4     
  Lines         894     1153     +259     
==========================================
+ Hits          461      504      +43     
- Misses        433      649     +216     

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

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.

Here are my comments so far, will continue once the bug fixes are in!

) # Add cluster labels

cluster_counts = Counter(all_blobs[:, -1]) # Cluster labels
most_detected_label = max(cluster_counts, key=cluster_counts.get)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can also call cluster_counts.most_common(1)[0]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

don't know why this suggestion was not working 🤔

lauraporta and others added 2 commits March 17, 2025 15:54
Co-authored-by: Igor Tatarnikov <61896994+IgorTatarnikov@users.noreply.github.com>
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 extra comments with some issues I ran into while trying to run the pipeline on the example data.

@lauraporta lauraporta merged commit cb4d754 into main Mar 17, 2025
10 checks passed
@lauraporta lauraporta deleted the metrics-and-batch 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.

Improve script to run slurm jobs Add method to calculate angular velocity and save it to the csv Refactor usage of paths / config files

2 participants