navigate Logo

Getting Started

  • Quick Start Guide
  • Software Installation
  • I Want To…

User Guide

  • Supported Hardware
  • Supported File Formats
  • User Interface Walkthrough
  • Setting Up A Microscope
  • Acquiring Data
  • Case Studies

Development

  • Contributing Guidelines
  • Developer Install
  • Software Architecture
  • Feature Container
  • REST-API
  • Plugin Architecture

Troubleshooting & Known Issues

  • Troubleshooting
  • Known Issues

Plugins

  • navigate Plugin Template
  • navigate Confocal Projection
  • navigate at Scale
  • navigate Constant Velocity Acquisition
  • navigate MMCore
  • navigate ilastik Server
  • navigate Photoactivation

Reference

  • Implemented Microscopes
  • Software API
    • navigate.config
    • navigate.controller
    • navigate.log_files
    • navigate.model
      • navigate.model.analysis
      • navigate.model.concurrency
      • navigate.model.data_sources
      • navigate.model.device_startup_functions
      • navigate.model.devices
      • navigate.model.features
        • navigate.model.features.adaptive_optics
        • navigate.model.features.auto_tile_scan
        • navigate.model.features.autofocus
        • navigate.model.features.common_features
        • navigate.model.features.feature_container
        • navigate.model.features.feature_related_functions
        • navigate.model.features.image_writer
        • navigate.model.features.remove_empty_tiles
        • navigate.model.features.restful_features
        • navigate.model.features.update_setting
        • navigate.model.features.volume_search
      • navigate.model.metadata_sources
      • navigate.model.microscope
      • navigate.model.model
      • navigate.model.plugins_model
      • navigate.model.waveforms
    • navigate.tools
    • navigate.view
navigate
  • Acquiring Data
  • Currently Implemented Features
  • navigate.model.features.autofocus
  • navigate.model.features.autofocus.Autofocus
  • View page source

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_func_data()

End the autofocus routine.

end_func_signal()

End the autofocus routine.

get_autofocus_frame_num()

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.

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.

run()

Run the Autofocusing Routine

Attributes

model

Model object

max_entropy

Maximum entropy

f_frame_id

Frame id

frame_num

Number of frames

init_pos

Initial position

f_pos

Focus position

focus_pos

Focus position

target_frame_id

Target frame id

get_frames_num

Number of frames

plot_data

Plot data

total_frame_num

Total frame number

fine_step_size

Fine step size

fine_pos_offset

Fine position offset

coarse_step_size

Coarse step size

coarse_steps

Coarse steps

signal_id

Signal id

autofocus_frame_queue

Autofocus frame queue

autofocus_pos_queue

Autofocus position queue

target_channel

Target channel

config_table

Configuration table

device

Device name

device_ref

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

model

Model object

Type:

Model

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

Previous Next

© Copyright 2025, Dean Lab, UT Southwestern Medical Center.