PYME.Analysis.piezo_movement_correction module¶
- PYME.Analysis.piezo_movement_correction.correct_target_positions(frames, events, metadata)¶
ProtocolFocus event descriptions list the intended focus target. Some piezos have a target tolerance and log their landing position with PiezoOnTarget. PiezoOffsetUpdate events are also accounted for.
- Parameters
- frames: ndarray
time array, e.g. data_source[‘t’], in units of frames
- events: list or structured ndarray
acquisition events
- metadata: PYME.IO.MetaDataHandler.MDHandlerBase
metadata with ‘Camera.CycleTime’ and ‘StartTime’ entries
- Returns
- corrected_focus: ndarray
focus positions for each element in frames
- PYME.Analysis.piezo_movement_correction.flag_piezo_movement(frames, events, metadata)¶
Flags localizations detected on frames between ProtocolFocus and PiezoOnTarget events.
- Parameters
- frames: ndarray
frame numbers, typically localization data_source[‘t’]
- events: list or structured ndarray
acquisition events
- metadata: PYME.IO.MetaDataHandler.MDHandlerBase
metadata with ‘Camera.CycleTime’ and ‘StartTime’ entries
- Returns
- moving: ndarray
boolean array where elements correspond to each element in frames. False indicates the piezo is stable while True flags elements in frames where the piezo doesn’t have a well defined position.
- PYME.Analysis.piezo_movement_correction.map_corrected_focus(events, metadata)¶
ProtocolFocus event descriptions list the intended focus target. Some piezos have a target tolerance and log their landing position with PiezoOnTarget. PiezoOffsetUpdate events are also accounted for.
- Parameters
- events: list or structured ndarray
acquisition events
- metadata: PYME.IO.MetaDataHandler.MDHandlerBase
metadata with ‘Camera.CycleTime’ and ‘StartTime’ entries
- Returns
- focus_mapping: PYME.Analysis.piecewiseMapping.piecewiseMap
callable function to return focus positions for each input frame number
- PYME.Analysis.piezo_movement_correction.map_piezo_moving(events, metadata)¶
Generates mapping function to flag whether input frames are between ProtocolFocus and PiezoOnTarget events.
- Parameters
- events: list or structured ndarray
acquisition events
- metadata: PYME.IO.MetaDataHandler.MDHandlerBase
metadata with ‘Camera.CycleTime’ and ‘StartTime’ entries
- Returns
- piezo_moving: PYME.Analysis.piecewiseMapping.piecewiseMap
callable object returning True for input frame numbers where the piezo is not settled.
- PYME.Analysis.piezo_movement_correction.spoof_focus_events_from_ontarget(events, metadata)¶
Generates a acquisition event array where events from (offset) piezo’s with on-target events are spoofed to look like standard ProtocolFocus events.
- Parameters
- events: list or structured ndarray
acquisition events
- metadata: PYME.IO.MetaDataHandler.MDHandlerBase
metadata with ‘Camera.CycleTime’ and ‘StartTime’ entries
- Returns
- ——-
- bonus_events: ndarray
events with piezo offsets accounted for and PiezoOnTarget events spoofed as ProtocolFocus events
Notes
The on-target events are fired from standard piezo classes, not the OffsetPiezo subclasses, so the PiezoOnTarget positions and ProtocolFocus events have an offset between them which we remove in the output normalized events if there are PiezoOffsetUpdate events available to do so.