Problem
The current fine_focus implementation in gently/agent/tools/focus_tools.py uses a software-controlled step-and-capture approach:
for i, pos in enumerate(positions):
result = await client.capture_lightsheet_image(
piezo_position=float(pos),
galvo_position=float(galvo_position)
)
This is slow because each iteration requires:
- Send piezo move command
- Wait for piezo to settle
- Trigger camera acquisition
- Wait for exposure + readout
- Transfer image data
- Repeat
For a typical 21-position sweep (±10μm at 1μm steps), this adds significant overhead from communication latency and settle times.
Proposed Solution
Use hardware-triggered scanning where:
- Galvo stays constant at the specified position
- Piezo scans continuously through the range
- Camera acquires a stack triggered by piezo controller
This would use the existing volume acquisition infrastructure but with:
- Galvo held at a single position (not scanning)
- Piezo providing the Z movement
- Camera in triggered/streaming mode
Benefits
- Much faster acquisition (single trigger starts entire sweep)
- Piezo controller handles precise timing
- Reduced communication overhead
- More consistent timing between frames
Implementation Notes
- May need a new client method like
capture_piezo_stack() or modify acquire_volume() to support galvo-constant mode
- Focus score calculation remains the same (analyze returned stack)
- Consider if existing
acquire_volume can be parameterized for this use case
Related Code
gently/agent/tools/focus_tools.py - fine_focus() function
gently/plans.py - existing volume acquisition plans
Problem
The current
fine_focusimplementation ingently/agent/tools/focus_tools.pyuses a software-controlled step-and-capture approach:This is slow because each iteration requires:
For a typical 21-position sweep (±10μm at 1μm steps), this adds significant overhead from communication latency and settle times.
Proposed Solution
Use hardware-triggered scanning where:
This would use the existing volume acquisition infrastructure but with:
Benefits
Implementation Notes
capture_piezo_stack()or modifyacquire_volume()to support galvo-constant modeacquire_volumecan be parameterized for this use caseRelated Code
gently/agent/tools/focus_tools.py-fine_focus()functiongently/plans.py- existing volume acquisition plans