Skip to content

Conversation

@saarah815
Copy link
Collaborator

@saarah815 saarah815 commented Aug 13, 2025

What is this PR

  • Bug fix
  • Addition of a new feature
  • Other

What does this PR do?

Allows for automated slice selection to match each slice in a slab to the optimal atlas slice.

References

#98

How has this PR been tested?

Tests added to test_registration_widget.py.

Is this a breaking change?

No.

Does this PR require an update to the documentation?

Yes.

Checklist:

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

saarah815 and others added 30 commits June 10, 2025 19:07
@codecov
Copy link

codecov bot commented Aug 13, 2025

Codecov Report

❌ Patch coverage is 93.38235% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.54%. Comparing base (1f87560) to head (925696f).

Files with missing lines Patch % Lines
brainglobe_registration/registration_widget.py 93.38% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #124      +/-   ##
==========================================
+ Coverage   92.30%   92.54%   +0.24%     
==========================================
  Files          15       15              
  Lines        1221     1355     +134     
==========================================
+ Hits         1127     1254     +127     
- Misses         94      101       +7     

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

@saarah815 saarah815 marked this pull request as ready for review August 13, 2025 17:10
@IgorTatarnikov IgorTatarnikov self-requested a review August 26, 2025 16:50
Copy link
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.

Works great out of the box, I have some more conceptual questions before I dive deeper into the code.

Also, perhaps we should explore now optimising the pitch/yaw/roll at all! This is much less of an issue in 3D as elastix will account for that as long as the subvolume is small enough. Could we try optimising just the start z-plane and end z-plane, by running a quick affine registration of the first slice with MI as the target. This should speed up the process significantly, we can then extract a slab from the atlas with a bit of a fudge factor in terms of atlas position (an extra 5 planes on each side) and then use that as the registration target?

Comment on lines +1020 to +1056
result_first = run_bayesian_generator(
atlas_image,
first_slice,
params["z_range"],
params["pitch_bounds"],
params["yaw_bounds"],
params["roll_bounds"],
params["init_points"],
params["n_iter"],
params["metric"],
params["weights"],
)

try:
while True:
next(result_first)
progress_i += 1
yield {"progress": progress_i}
except StopIteration as stop:
final_first = stop.value

logging.info(
"\nBayesian slice detection for the last slice in the slab..."
)

result_last = run_bayesian_generator(
atlas_image,
last_slice,
params["z_range"],
params["pitch_bounds"],
params["yaw_bounds"],
params["roll_bounds"],
params["init_points"],
params["n_iter"],
params["metric"],
params["weights"],
)
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if there's an elegant way to provide separate z_ranges or even perhaps completely separate parameters for the start and end slice of the slab?

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.

3 participants