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
  • navigate.controller.sub_controllers.camera_view.CameraViewController
  • View page source

navigate.controller.sub_controllers.camera_view.CameraViewController

class navigate.controller.sub_controllers.camera_view.CameraViewController(view, parent_controller=None)

Bases: BaseViewController

Camera View Controller Class.

__init__(view, parent_controller=None) → None

Initialize the Camera View Controller Class.

Parameters:
  • view (CameraTab) – The Camera tkinter frame that contains the widgets.

  • parent_controller (Controller) – The parent controller of the camera view controller.

Methods

__init__(view[, parent_controller])

Initialize the Camera View Controller Class.

add_crosshair(image)

Adds a cross-hair to the image.

apply_lut(image)

Applies a LUT to an image.

array_to_image(image)

Convert a numpy array to a PIL Image.

calculate_offset()

Calculates the offset of the image.

detect_saturation(image)

Look for any pixels at the maximum intensity allowable for the camera.

digital_zoom()

Apply digital zoom.

display_image(image)

Display an image using the LUT specified in the View.

display_mask(mask)

Display segmentation mask

down_sample_image(image)

Down-sample the data for image display according to widget size.

execute(command, *args)

This function is called when a command is passed from a child process.

flip_image(image)

Flip the image according to the flip flags.

get_absolute_position()

Gets the absolute position of the computer mouse.

get_selected_channels([microscope_state])

Get the selected microscope channels from the MicroscopeState.

identify_channel_index_and_slice()

As images arrive, identify channel index and slice.

initialize(name, data)

Sets widgets based on data given from main controller/config.

initialize_non_live_display(...)

Initialize the non-live display.

left_click(*_)

Toggles cross-hair on image upon left click event.

mark_position()

Marks the current position of the microscope in the multi-position acquisition table.

mouse_wheel(event)

Digitally zooms in or out on the image upon scroll wheel event.

move_crosshair()

Move the crosshair to a non-default position.

move_stage()

Move the stage according to the position the user clicked.

populate_image(image)

Converts image to an ImageTk.PhotoImage and populates the Tk Canvas

popup_menu(event)

Right-Click Popup Menu

process_image()

Process the image to be displayed.

refresh(width, height)

Refresh the window.

register_event_listener(event_name, ...)

Register event listener in the parent_controller

reset_display([display_flag, reset_crosshair])

Set the display back to the original digital zoom.

resize(event)

Resize the window.

scale_image_intensity(image)

Scale the data to the min/max counts, and adjust bit-depth.

set_experiment_values()

Sets values of widgets based on experiment setting

set_mask_color_table(colors)

Set up segmentation mask color table

set_mode([mode])

Sets mode of camera_view_controller.

show_verbose_info(*info)

Prints verbose information to the console

slider_update(*_)

Updates the image when the slider is moved.

toggle_min_max_buttons([display])

Checks the value of the autoscale widget.

transpose_image(image)

Transpose the image according to the flip flags.

try_to_display_image(image)

Try to display an image.

update_canvas_size()

Update the canvas size.

update_display_state(*_)

Image Display Combobox Called.

update_experiment_values()

Collects all the values of widgets

update_lut(target)

Update the LUT in the Camera View.

update_max_counts()

Update the max counts in the camera view.

update_min_max_counts([display])

Get min and max count values from the View.

update_snr()

Updates the signal-to-noise ratio.

update_transpose_state([display])

Get Flip XY widget value from the View.

Attributes

custom_events

Custom events for this controller

image_metrics

The dictionary of image metrics widgets.

display_state

The display state.

rolling_frames

The number of frames to average.

max_intensity_history

The list of maximum intensity values.

display_mask_flag

The flag for displaying the mask.

mask_color_table

The display mask flag.

ilastik_mask_ready_lock

The lock for the ilastik mask.

ilastik_seg_mask

The ilastik mask.

add_crosshair(image: ndarray) → ndarray

Adds a cross-hair to the image.

Parameters:

image (np.ndarray) – Image data.

Returns:

image – Image data with cross-hair.

Return type:

np.ndarray

apply_lut(image: ndarray) → ndarray

Applies a LUT to an image.

Red is reserved for saturated pixels. self.color_values = [‘gray’, ‘gradient’, ‘rainbow’]

Parameters:

image (np.ndarray) – Image data.

Returns:

image – Image data with LUT applied.

Return type:

np.ndarray

array_to_image(image: ndarray) → <module 'PIL.Image' from '/opt/hostedtoolcache/Python/3.9.22/x64/lib/python3.9/site-packages/PIL/Image.py'>

Convert a numpy array to a PIL Image.

If a color mask is present, it will apply the mask to the image.

Parameters:

image (np.ndarray) – Image data.

Returns:

image – A PIL Image

Return type:

Image

calculate_offset() → tuple

Calculates the offset of the image.

Returns:

  • offset_x (int) – The offset of the image in x.

  • offset_y (int) – The offset of the image in y.

detect_saturation(image: ndarray) → None

Look for any pixels at the maximum intensity allowable for the camera.

Note

The camera is set to 16-bit depth, so the maximum intensity is 2^16 - 1. If another camera is used, this function should be updated to reflect the maximum intensity value.

Parameters:

image (np.ndarray) – Image data.

digital_zoom() → ndarray

Apply digital zoom.

The x and y positions are between 0 and the canvas width and height respectively.

Returns:

image – Image after digital zoom applied

Return type:

np.ndarray

display_image(image: ndarray) → None

Display an image using the LUT specified in the View.

If Autoscale is selected, automatically calculates the min and max values for the data.

If Autoscale is not selected, takes the user values as specified in the min and max counts.

Parameters:

image (np.ndarray) – Image data.

display_mask(mask: ndarray) → None

Display segmentation mask

Parameters:

mask (np.ndarray) – Segmentation mask to display

down_sample_image(image: ndarray) → ndarray

Down-sample the data for image display according to widget size.

Interpolation type is cv2.INTER_LINEAR by default.

Parameters:

image (np.ndarray) – Image data.

Returns:

down_sampled_image – Down-sampled image data.

Return type:

np.ndarray

execute(command, *args)

This function is called when a command is passed from a child process.

Parameters:
  • command (str) – command name

  • args (tuple) – command arguments

flip_image(image: ndarray) → ndarray

Flip the image according to the flip flags.

Parameters:

image (np.ndarray) – Image data.

Returns:

image – Flipped and/or transposed image data.

Return type:

numpy.ndarray

get_absolute_position() → tuple

Gets the absolute position of the computer mouse.

Returns:

  • x (int) – The x position of the mouse.

  • y (int) – The y position of the mouse.

get_selected_channels(microscope_state: Optional[dict] = None) → None

Get the selected microscope channels from the MicroscopeState.

Parameters:

microscope_state (Optional[dict]) – The microscope state dictionary object.

identify_channel_index_and_slice() → tuple

As images arrive, identify channel index and slice.

Returns:

  • channel_idx (int) – The channel index.

  • slice_idx (int) – The slice index.

initialize(name: str, data: list)

Sets widgets based on data given from main controller/config.

Parameters:
  • name (str) – ‘minmax’, ‘image’.

  • data (list) – Min and max intensity values.

initialize_non_live_display(microscope_state: dict, camera_parameters: dict) → None

Initialize the non-live display.

Parameters:
  • microscope_state (dict) – Microscope state.

  • camera_parameters (dict) – Camera parameters.

left_click(*_) → None

Toggles cross-hair on image upon left click event.

mark_position() → None

Marks the current position of the microscope in the multi-position acquisition table.

mouse_wheel(event: Event) → None

Digitally zooms in or out on the image upon scroll wheel event.

Sets the self.zoom_value between 0.05 and 1 in .05 unit steps.

Parameters:

event (tk.Event) – num = 4 is zoom out. num = 5 is zoom in. x, y location. 0,0 is top left corner.

move_crosshair() → None

Move the crosshair to a non-default position.

move_stage() → None

Move the stage according to the position the user clicked.

populate_image(image: ndarray) → None

Converts image to an ImageTk.PhotoImage and populates the Tk Canvas

Note

When calling ImageTk.PhotoImage() to generate a new image, it will destroy what the canvas is showing, causing it to blink. This problem is solved by creating two images and alternating between them.

Parameters:

image (np.ndarray) – Image data.

popup_menu(event: Event) → None

Right-Click Popup Menu

Parameters:

event (tk.Event) – x, y location. 0,0 is top left corner.

process_image() → None

Process the image to be displayed.

Applies digital zoom, detects saturation, down-samples the image, scales the image intensity, adds a crosshair, applies the lookup table, and populates the image.

refresh(width: int, height: int) → None

Refresh the window.

Parameters:
  • width (int) – Width of the window.

  • height (int) – Height of the window.

register_event_listener(event_name, event_handler)

Register event listener in the parent_controller

Parameters:
  • event_name (str) – event name

  • event_handler (function) – event handler

reset_display(display_flag: bool = True, reset_crosshair: bool = True) → None

Set the display back to the original digital zoom.

Parameters:
  • display_flag (bool) – Flag for refreshing the image display. Default True.

  • reset_crosshair (bool) – Flag for resetting the crosshair. Default True.

resize(event: Event) → None

Resize the window.

Parameters:

event (tk.Event) – Tkinter event.

scale_image_intensity(image: ndarray) → ndarray

Scale the data to the min/max counts, and adjust bit-depth.

Parameters:

image (np.ndarray) – Image data.

Returns:

image – Scaled image data.

Return type:

np.ndarray

set_experiment_values()

Sets values of widgets based on experiment setting

setting_dict is a dictionary

set_mask_color_table(colors: list) → None

Set up segmentation mask color table

Parameters:

colors (list) – The list of colors to use for the segmentation mask

set_mode(mode: str = '')

Sets mode of camera_view_controller.

Parameters:

mode (str) – camera_view_controller mode.

show_verbose_info(*info)

Prints verbose information to the console

Parameters:

info (tuple) – information to be printed

slider_update(*_) → None

Updates the image when the slider is moved.

toggle_min_max_buttons(display: bool = False) → None

Checks the value of the autoscale widget.

If enabled, the min and max widgets are disabled and the image intensity is autoscaled. If disabled, miu and max widgets are enabled, and image intensity scaled.

transpose_image(image: ndarray) → ndarray

Transpose the image according to the flip flags.

Parameters:

image (np.ndarray) – Image data.

Returns:

image – Flipped and/or transposed image data.

Return type:

np.ndarray

try_to_display_image(image: ndarray) → None

Try to display an image.

In the live mode, images are automatically passed to the display function.

In the slice mode, images are passed to a spooled temporary file. However, when the same slice and channel index is acquired again, the image is updated. In all other cases, the image is only displayed upon slider events.

Parameters:

image (np.ndarray) – Image data.

update_canvas_size() → None

Update the canvas size.

update_display_state(*_) → None

Image Display Combobox Called.

Sets self.display_state to desired display format. Toggles state of slider widget. Sets number of positions.

update_experiment_values()

Collects all the values of widgets

setting_dict is a reference of experiment dictionary update the dictionary directly

update_lut(target) → None

Update the LUT in the Camera View.

When the LUT is changed in the GUI, this function is called. Updates the LUT.

update_max_counts() → None

Update the max counts in the camera view.

Function gets the number of frames to average from the VIEW.

If frames to average == 0 or 1, provides the maximum value from the last acquired data.

update_min_max_counts(display: bool = False)

Get min and max count values from the View.

When the min and max counts are toggled in the GUI, this function is called. Updates the min and max values.

Parameters:

display (bool) – Flag to display the image.

update_snr() → None

Updates the signal-to-noise ratio.

update_transpose_state(display: bool = False) → None

Get Flip XY widget value from the View.

If True, transpose the image.

apply_cross_hair

The flag for the display of the cross-hair.

Type:

bool

autoscale

The flag for autoscaling the image intensity.

Type:

bool

bit_depth

The bit depth of the image.

Type:

int

canvas

The tkinter canvas that displays the image.

Type:

tkinter.Canvas

canvas_height

The height of the canvas.

Type:

int

canvas_height_scale

The scaling factor for the height of the canvas.

Type:

int

canvas_width

The width of the canvas.

Type:

int

canvas_width_scale

The scaling factor for the width of the canvas.

Type:

int

colormap

The colormap for the image.

Type:

str

crosshair_x

Percentage of crosshair in x

Type:

float

crosshair_y

Percentage of crosshair in y

Type:

float

property custom_events

Custom events for this controller

Type:

dict

display_mask_flag

The flag for displaying the mask.

Type:

bool

display_state

The display state.

Type:

str

flip_flags

The flip flags for the camera.

Type:

dict

height

The height of the image.

Type:

int

ilastik_mask_ready_lock

The lock for the ilastik mask.

Type:

threading.Lock

ilastik_seg_mask

The ilastik mask.

Type:

numpy.ndarray

image

The image data.

Type:

numpy.ndarray

image_cache_flag

The flag for the image cache.

Type:

bool

image_count

The count of images.

Type:

int

image_metrics

The dictionary of image metrics widgets.

Type:

dict

image_mode

The imaging mode.

Type:

str

image_palette

The dictionary of image palette widgets.

Type:

dict

is_displaying_image

The lock for displaying the image.

Type:

VariableWithLock

logger

The logger for the camera view controller.

Type:

logging.Logger

mask_color_table

The display mask flag.

Type:

bool

max_counts

The maximum counts of the image.

Type:

int

max_intensity_history

The list of maximum intensity values.

Type:

list

microscope_name

The microscope name

Type:

str

min_counts

The minimum counts of the image.

Type:

int

mode

The mode of the camera view controller.

Type:

str

move_to_x

The x position of the mouse.

Type:

int

move_to_y

The y position of the mouse.

Type:

int

number_of_channels

The number of channels in the image.

Type:

int

number_of_slices

The number of slices in the image volume.

Type:

int

offset_crosshair

the flag for offsetting the crosshair

Type:

bool

original_image_height

The original height of the image.

Type:

int

original_image_width

The original width of the image.

Type:

int

parent_controller

parent controller

Type:

Controller

resize_event_id

The resize event ID.

Type:

event

rolling_frames

The number of frames to average.

Type:

int

saturated_pixels

The saturated pixels in the image.

Type:

np.ndarray

selected_channels

The selected channels being acquired.

Type:

list

slice_index

The index of the slice in the image volume.

Type:

int

stack_cycling_mode

The stack cycling mode.

Type:

str

tk_image

The tkinter image.

Type:

ImageTk.PhotoImage

tk_image2

The tkinter image 2.

Type:

ImageTk.PhotoImage

total_images_per_volume

The total number of images per volume.

Type:

int

transpose

The flag for transposing the image.

Type:

bool

view

GUI view

Type:

tkinter.Tk

width

The width of the canvas.

Type:

int

zoom_height

The zoom scale of the image.

Type:

float

zoom_offset

The zoom offset of the image.

Type:

numpy.ndarray

zoom_rect

The zoom rectangle of the image.

Type:

numpy.ndarray

zoom_scale

The zoom scale of the image.

Type:

float

zoom_value

The zoom value of the image.

Type:

float

zoom_width

The zoom width of the image.

Type:

int


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