-
Notifications
You must be signed in to change notification settings - Fork 11
Description
Grid ROI: Missing spacing parameters for non-uniform grids
Description
The grid ROI feature is not working correctly for images where subimages/features don't fill the entire image area. This is particularly problematic for real-world data like:
- Laser spot arrays with gaps between spots
- Diffraction patterns
- Any regularly spaced features with significant gaps or offsets
Problem
Users can adjust:
- Number of rows/columns (nx, ny)
- ROI size (xsize, ysize) - percentage of cell size
- Position offset (xtranslation, ytranslation) - percentage translation
But cannot adjust:
- Spacing between ROIs (distance between adjacent ROI centers)
The grid ROI extraction always assumes an evenly distributed grid across the entire image, calculating cell spacing as width / nx and height / ny. This fails when:
- Spots/features don't fill the whole image
- There's significant offset from the edges
- The actual spacing between features differs from the calculated cell width/height
Example Case
When trying to extract a 7×7 spot grid from laser_spot_array_raw.png:
- The spots have gaps between them
- The first spot has a significant offset from the image edges
- The automatically computed spacing (image_width / 7) doesn't match the actual spot spacing
- Result: ROIs don't align with the actual spots
Classification
This is a bug fix rather than a feature addition because:
- The grid ROI feature claims to extract grids of subimages
- It fails for a significant class of real-world images (non-uniform/gapped grids)
- The missing parameters are essential for the feature to work as intended
- Users have no workaround without modifying image coordinates or manually creating ROIs
Proposed Solution
Add two new parameters to ROIGridParam:
- xstep: Horizontal spacing between ROI centers, as percentage of auto-computed cell width (default 100%)
- ystep: Vertical spacing between ROI centers, as percentage of auto-computed cell height (default 100%)
With default values (100%), the behavior remains unchanged (evenly distributed grid). Users can adjust these values to:
- < 100%: Tighter spacing (ROIs closer together)
- > 100%: Wider spacing (ROIs farther apart)
Impact
Without this fix, the grid ROI feature is essentially unusable for a large class of real-world scientific data where features are regularly spaced but don't fill the entire image.
Related Code
- Sigima:
sigima/proc/image/extraction.py-ROIGridParamclass andgenerate_image_grid_roi()function - DataLab:
datalab/gui/roigrideditor.py- Grid ROI editor dialog
Affected Versions
- DataLab 1.0.2
- Sigima 1.0.3