Skip to content

RoiStuff: emit the cropped data in live mode too - #21

Merged
seb5g merged 3 commits into
5.3.xfrom
fix/roistuff_live_crop
Oct 4, 2026
Merged

seb5g merged 3 commits into
5.3.xfrom
fix/roistuff_live_crop

Conversation

@seb5g

@seb5g seb5g commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes the bug in daq_2Dviewer_RoiStuff.py reported in PyMoDAQ/PyMoDAQ#1237: in live mode, grab_data built the cropped DataToExport but emitted the uncropped data.

  • A new crop() method is used by both the live and single grabs. It crops with dwa.vsig[roi_select_info.to_slices(False)], because the ROI select is given in the units of the viewer axes, which are scaled in this plugin. It returns the data unchanged if Use Roi is off or no ROI select has been made yet (that case crashed before).
  • The sliced extra attribute is now set on the cropped data, not on the original.
  • Removed the extra grab and emission done after the live loop, and the useless center_origin() call.
  • The crosshair position is logged instead of printed.

Test

Headless check with the plugin instantiated directly:

  • No ROI: (256, 256).
  • Use Roi without a selection: (256, 256), no crash.
  • With a ROI select of 10×20 pixels: a single grab gives (10, 20) with sliced=True, and the live mode gives 3 cropped (10, 20) frames.

This plugin is used as the reference example in the new ROI select documentation (PyMoDAQ/PyMoDAQ#1237).

🤖 Generated with Claude Code

- the live branch of grab_data built the cropped DataToExport but emitted the uncropped one
- factor the cropping in a crop() method used by both live and single grabs; it returns the data unchanged if
  'Use Roi' is off or no ROI select has been made yet (it crashed before)
- set the 'sliced' extra attribute on the cropped data (was set on the original one)
- remove the extra grab/emission done after the live loop and the useless center_origin
- log the crosshair position instead of printing it

Related to PyMoDAQ/PyMoDAQ#1237

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@seb5g
seb5g merged commit 72c9e36 into 5.3.x Oct 4, 2026
1 check failed
@seb5g
seb5g deleted the fix/roistuff_live_crop branch October 4, 2026 19:42
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.

1 participant