Skip to content

[S30-134][feat] grating offset calibration small improvements - #3545

Open
pieleric wants to merge 3 commits into
delmic:masterfrom
pieleric:feat-grating-offset-calibration-small-improvements
Open

[S30-134][feat] grating offset calibration small improvements#3545
pieleric wants to merge 3 commits into
delmic:masterfrom
pieleric:feat-grating-offset-calibration-small-improvements

Conversation

@pieleric

@pieleric pieleric commented Aug 11, 2026

Copy link
Copy Markdown
Member

Force the CCD binning to 1 px horizontally, to ensure the best precision.

Improve the SPARC GUI alignment tab:

  • Rename "auto center" to "auto calib", to clarify what will happen.
  • Adjust the name of the button from pnl_calibrate to pnl_grating, to make
    it clearer.
  • Disable the rest of the tab while the calibration is running
  • Only allow to run the calibration procedure in LENS alignment mode.
  • Show the cross-hair while it's running.

Also fix some test cases due to issue with the simulator.

The horizontal reoslution is important when looking for the closest
position near the center. So the CCD should have binning = 1,
horizontally, always.
Copilot AI lite review requested due to automatic review settings August 11, 2026 03:27
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@pieleric, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 34 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9196f8d7-1088-44a5-977e-4e3fa3529569

📥 Commits

Reviewing files that changed from the base of the PR and between 7999c52 and 491bde5.

📒 Files selected for processing (6)
  • src/odemis/acq/align/goffset.py
  • src/odemis/acq/align/test/goffset_test.py
  • src/odemis/driver/simcam.py
  • src/odemis/gui/cont/tabs/sparc2_align_tab.py
  • src/odemis/gui/main_xrc.py
  • src/odemis/gui/xmlh/resources/panel_tab_sparc2_align.xrc

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR refines the SPARC2 grating offset auto-calibration workflow by improving the alignment tab UI labels/visibility, tightening GUI enable/disable behavior during automated procedures, and improving the simulated/algorithmic alignment behavior and tests.

Changes:

  • Renames and rewords the grating calibration panel/button labels/tooltips in the XRC resources and generated main_xrc.py.
  • Updates SPARC2 align tab controller to show/hide the grating panel per mode and to disable controls during acquisition/calibration.
  • Improves grating offset alignment robustness (binning/exposure handling + restoration) and updates simulation centering + alignment tests.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/odemis/gui/xmlh/resources/panel_tab_sparc2_align.xrc UI text updates and panel renaming for grating calibration section.
src/odemis/gui/main_xrc.py Regenerated XRC bindings to match renamed panel and updated UI strings.
src/odemis/gui/cont/tabs/sparc2_align_tab.py Calibration UX/control-state improvements; grating panel visibility changes; acquisition-state handling.
src/odemis/driver/simcam.py Adjusts simulated CCD “center” calculation to pixel-index center.
src/odemis/acq/align/test/goffset_test.py Test adjustments for simulator behavior and misalignment setup.
src/odemis/acq/align/goffset.py Adds detector binning normalization during alignment and restores prior detector state afterward.
Suppressed comments (1)

src/odemis/gui/cont/tabs/sparc2_align_tab.py:1646

  • If you defer forcing the crosshair until calibration actually starts, it should be enabled after the calibration future is created (so early returns don’t leave it stuck on).
        # Bind progress & done callbacks
        self._grating_calibration_future.add_done_callback(self._on_grating_calibration_done)
        self.panel.btn_auto_grating_center.SetLabel("Cancel")


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +542 to +544
restore_attrs = {}
if not model.hasVA(detector, "binning") or detector.binning.value[0] == 1:
return restore_attrs
Comment on lines +1602 to +1605
# Show the cross-hair, at the middle, to confirm the alignment is correct.
self.panel.vp_align_lens.canvas.fit_view_to_content()
self._grating_calib_prev_crosshair = self.panel.vp_align_lens.view.show_crosshair.value
self.panel.vp_align_lens.view.show_crosshair.value = True
Comment thread src/odemis/gui/cont/tabs/sparc2_align_tab.py
@pieleric pieleric changed the title [feat] grating offset calibration small improvements [S30-134][feat] grating offset calibration small improvements Aug 11, 2026
@pieleric
pieleric requested review from ilyushkin and tepals August 11, 2026 03:38
* Rename "auto center" to "auto calib", to clarify what will happen.
* Adjust the name of the button from pnl_calibrate to pnl_grating, to make
  it clearer.
* Disable the rest of the tab while the calibration is running
* Only allow to run the calibration procedure in LENS alignment mode.
* Show the cross-hair while it's running.
Fix the computation of the center of the CCD in the simulator.
It was shifted by 0.5 px, causing the "good" offset to actually not be
so good. This triggered the failure of test_scale_not_misaligned.

Also adjust the test_scale_not_misaligned to only concider the failure
if offset is more than 1px off. It was using 1e-6, which is over the
top in precision, especially as the simulator has noise.

test_single_detector_updates_grating would fail if the previous tests were run,
because the grating would be already calibrated,
and so the test would say that nothing has happened.
=> mis-align the grating before running the calibration to make sure
that something should happen.
@pieleric
pieleric force-pushed the feat-grating-offset-calibration-small-improvements branch from 6cd96fa to 491bde5 Compare August 11, 2026 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants