navigate.model.features.autofocus.Autofocus
- class navigate.model.features.autofocus.Autofocus(model, device='stage', device_ref='f')
Bases:
object
Autofocus Data Process
This function is called by the data thread. It will get the data from the autofocus_frame_queue and calculate the entropy of the image. The entropy is then compared to the maximum entropy and the position is saved if it is higher. The autofocus_pos_queue is then filled with the next position to move to. If the autofocus_pos_queue is empty, the autofocus is finished.
- __init__(model, device='stage', device_ref='f')
Initialize the Autofocus class.
- Parameters:
model (Model) – Model object
device (str) – Device name
device_ref (str) – Device reference
Methods
__init__
(model[, device, device_ref])Initialize the Autofocus class.
End the autofocus routine.
End the autofocus routine.
Calculate how many frames are needed to get the best focus position.
get_steps
(ranges, step_size)Calculate number of steps for autofocusing routine.
in_func_data
([frame_ids])Run the autofocus routine.
Run the autofocus routine.
Prepare the autofocus routine.
Prepare the autofocus routine.
Robust autofocus routine.
run
()Run the Autofocusing Routine
Attributes
Model object
Maximum entropy
Frame id
Number of frames
Initial position
Focus position
Focus position
Target frame id
Number of frames
Plot data
Total frame number
Fine step size
Fine position offset
Coarse step size
Coarse steps
Signal id
Autofocus frame queue
Autofocus position queue
Target channel
Configuration table
Device name
Device reference
- end_func_data()
End the autofocus routine.
- Returns:
True if the autofocus routine is finished.
- Return type:
bool
- end_func_signal()
End the autofocus routine.
- get_autofocus_frame_num()
Calculate how many frames are needed to get the best focus position.
- Returns:
Number of frames to be processed.
- Return type:
int
- static get_steps(ranges, step_size)
Calculate number of steps for autofocusing routine.
- Parameters:
ranges (float) – Distance to be traveled during the autofocusing routine
step_size (float) – Step size for autofocusing routine
- Returns:
steps (float) – Number of steps for the stack
pos_offset (float) – Need to figure out.
- in_func_data(frame_ids=[])
Run the autofocus routine.
- Parameters:
frame_ids (list) – List of frame ids to be processed.
- Returns:
frame_ids – List of frame ids to be processed.
- Return type:
list
- in_func_signal()
Run the autofocus routine.
- pre_func_data()
Prepare the autofocus routine.
- pre_func_signal()
Prepare the autofocus routine.
- robust_autofocus()
Robust autofocus routine.
TODO: Current values for amplitude, sigma, and alpha are hard-coded. Fitting is unfortunately unstable.
- Returns:
fit_data (list) – Autofocus data
focus_position (float) – Focus position
r_squared (float) – R-Squared value
- run()
Run the Autofocusing Routine
- Returns:
Autofocus parameters.
- Return type:
dict
- autofocus_frame_queue
Autofocus frame queue
- Type:
Queue
- autofocus_pos_queue
Autofocus position queue
- Type:
Queue
- coarse_step_size
Coarse step size
- Type:
float
- coarse_steps
Coarse steps
- Type:
int
- config_table
Configuration table
- Type:
dict
- device
Device name
- Type:
str
- device_ref
Device reference
- Type:
str
- f_frame_id
Frame id
- Type:
int
- f_pos
Focus position
- Type:
float
- fine_pos_offset
Fine position offset
- Type:
float
- fine_step_size
Fine step size
- Type:
float
- focus_pos
Focus position
- Type:
float
- frame_num
Number of frames
- Type:
int
- get_frames_num
Number of frames
- Type:
int
- init_pos
Initial position
- Type:
float
- max_entropy
Maximum entropy
- Type:
float
- plot_data
Plot data
- Type:
list
- signal_id
Signal id
- Type:
int
- target_channel
Target channel
- Type:
int
- target_frame_id
Target frame id
- Type:
int
- total_frame_num
Total frame number
- Type:
int