mesoSPIM.src package

Subpackages

Submodules

mesoSPIM.src.WebcamWindow module

Simple webcam display widget, can be used stand-alone author: Nikita Vladimirov, @nvladimus, 2022 License: GPL-3

class mesoSPIM.src.WebcamWindow.WebcamWindow(*args: Any, **kwargs: Any)[source]

Bases: QWidget

sig_move_absolute

alias of dict

sig_state_request

alias of dict

start_capture()[source]

mesoSPIM.src.mesoSPIM_AcquisitionManagerWindow module

mesoSPIM Acquisition Manager Window

class mesoSPIM.src.mesoSPIM_AcquisitionManagerWindow.MyStyle(*args: Any, **kwargs: Any)[source]

Bases: QProxyStyle

drawPrimitive(element, option, painter, widget=None)[source]

Draw a line across the entire row rather than just the column we’re hovering over.

class mesoSPIM.src.mesoSPIM_AcquisitionManagerWindow.mesoSPIM_AcquisitionManagerWindow(*args: Any, **kwargs: Any)[source]

Bases: QWidget

add_row()[source]
append_time_index_to_filenames(time_index)[source]

Appends the time index to each filename

auto_illumination(margin_um=500)[source]
copy_row()[source]
delete_all_rows()[source]

Displays a warning that this will delete the entire table and then proceeds to delete if the user clicks ‘Yes’

delete_row()[source]

Deletes the selected row

disable()[source]
disable_gui()[source]

Disables all buttons and controls, enables stop button

display_information(string, fontsize=12)[source]
display_no_row_selected_warning()[source]
display_status_message(string, time=0)[source]

Displays a message in the status bar for a time in ms

If time=0, the message will stay.

display_warning(string)[source]
enable()[source]
enable_gui()[source]

Enables all GUI controls, disables stop button

generate_filenames()[source]
get_first_selected_row()[source]

Little helper method to provide the first row out of a selection range

get_selected_rows()[source]

Little helper method to provide the selected rows

load_table()[source]
mark_all_current_parameters()[source]
mark_current_etl_parameters()[source]
mark_current_focus()[source]

Marks both foci start focus

mark_current_rotation()[source]
mark_current_state()[source]
mark_current_xy_position()[source]
model_changed

alias of AcquisitionModel

move_selected_row_down()[source]
move_selected_row_up()[source]
preview_acquisition()[source]
run_focus_tracking_wizard()[source]
run_image_processing_wizard()[source]
run_tiling_wizard()[source]
save_table()[source]
selected_row_changed(new_selection, old_selection)[source]
set_folder_names()[source]
set_item_delegates()[source]

Several columns should have certain delegates

If I decide to move colums, the delegates should move with them

Here, I need the configuration to provide the options for the delegates.

set_selected_row(row)[source]

Little helper method to allow setting the selected row

set_state()[source]
sig_move_absolute

alias of dict

sig_warning

alias of str

start_selected()[source]

Get the selected row and run this (single) row only

Indices is a list of selected QModelIndex objects, we’re only interested in the first.

statusBar

Setting the model up

update_acquisition_size_prediction()[source]
update_acquisition_time_prediction()[source]

mesoSPIM.src.mesoSPIM_Camera module

mesoSPIM Camera class, intended to run in its own thread

class mesoSPIM.src.mesoSPIM_Camera.mesoSPIM_Camera(*args: Any, **kwargs: Any)[source]

Bases: QObject

Top-level class for all cameras

add_images_to_series(acq, acq_list)
end_image_series(acq, acq_list)
end_live()
get_live_image()
prepare_image_series(acq, acq_list)

Row is a row in a AcquisitionList

prepare_live()
set_camera_binning(value)[source]
set_camera_display_acquisition_subsampling(factor)[source]
set_camera_display_live_subsampling(factor)[source]
set_camera_exposure_time(time)[source]

Sets the exposure time in seconds

Parameters:

time (float) – exposure time to set

set_camera_line_interval(time)[source]

Sets the line interval in seconds

Parameters:

time (float) – interval time to set

set_state(value)[source]
sig_status_message

alias of str

sig_write_images

alias of Acquisition

snap_image(write_flag=True)

“Snap an image and display it

state_request_handler(dict)

The request handling is done with exec() to write fewer lines of code.

stop()

Stops acquisition

class mesoSPIM.src.mesoSPIM_Camera.mesoSPIM_DemoCamera(*args: Any, **kwargs: Any)[source]

Bases: mesoSPIM_GenericCamera

close_camera()[source]
get_image()[source]

Should return a single numpy array

get_images_in_series()[source]

Should return a single numpy array

get_live_image()[source]
open_camera()[source]
set_binning(binning_string)[source]
class mesoSPIM.src.mesoSPIM_Camera.mesoSPIM_GenericCamera(*args: Any, **kwargs: Any)[source]

Bases: QObject

Generic mesoSPIM camera class meant for subclassing.

close_camera()[source]
close_image_series()[source]
close_live_mode()[source]
get_image()[source]

Should return a single numpy array

get_images_in_series()[source]

Should return a single numpy array

get_live_image()[source]
initialize_image_series()[source]
initialize_live_mode()[source]
open_camera()[source]
set_binning(binning_string)[source]
set_exposure_time(time)[source]
set_line_interval(time)[source]
class mesoSPIM.src.mesoSPIM_Camera.mesoSPIM_HamamatsuCamera(*args: Any, **kwargs: Any)[source]

Bases: mesoSPIM_GenericCamera

close_camera()[source]
close_image_series()[source]
close_live_mode()[source]
get_image()[source]

Should return a single numpy array

get_images_in_series()[source]

Should return a single numpy array

get_live_image()[source]
initialize_image_series()[source]
initialize_live_mode()[source]
open_camera()[source]

Hamamatsu-specific code

print_camera_properties(message='Camera properties')[source]

Camera properties

set_binning(binningstring)[source]
set_camera_sensor_mode(mode)[source]
set_exposure_time(time)[source]
set_line_interval(time)[source]
class mesoSPIM.src.mesoSPIM_Camera.mesoSPIM_PCOCamera(*args: Any, **kwargs: Any)[source]

Bases: mesoSPIM_GenericCamera

close_camera()[source]
close_image_series()[source]
close_live_mode()[source]
get_image()[source]

Should return a single numpy array

get_images_in_series()[source]

Should return a single numpy array

get_live_image()[source]
initialize_image_series()[source]
initialize_live_mode()[source]
open_camera()[source]
set_binning(binningstring)[source]
set_exposure_time(time)[source]
set_line_interval(time)[source]
class mesoSPIM.src.mesoSPIM_Camera.mesoSPIM_PhotometricsCamera(*args: Any, **kwargs: Any)[source]

Bases: mesoSPIM_GenericCamera

close_camera()[source]
close_image_series()[source]
close_live_mode()[source]
get_image()[source]

Should return a single numpy array

get_images_in_series()[source]

Should return a single numpy array

get_live_image()[source]
initialize_image_series()[source]

The Photometrics cameras expect integer exposure times, otherwise they default to the minimum value

initialize_live_mode()[source]

The Photometrics cameras expect integer exposure times, otherwise they default to the minimum value

open_camera()[source]
report_pvcam_parameter(description, parameter)[source]
set_binning(binningstring)[source]
set_exposure_time(time)[source]
set_line_interval(time)[source]

mesoSPIM.src.mesoSPIM_CameraWindow module

mesoSPIM CameraWindow

class mesoSPIM.src.mesoSPIM_CameraWindow.mesoSPIM_CameraWindow(*args: Any, **kwargs: Any)[source]

Bases: QWidget

adjust_levels(pct_low=25, pct_hi=99.99)[source]

‘Adjust histogram levels

change_overlay(overlay_name)
draw_crosshairs()[source]
draw_lightsheet_marker()[source]
get_image_shape()[source]
get_roi()[source]
hide_light_sheet_marker()[source]
ini_subsampling

Initialize crosshairs

px2um(px, scale=1)[source]

Unit converter

set_image(image)[source]
set_roi(mode='box', x_y_w_h=(0, 0, 100, 100))[source]
sig_update_roi

alias of tuple

update_image_from_deque()
update_status(subsampling=2.0)

mesoSPIM.src.mesoSPIM_ContrastWindow module

class mesoSPIM.src.mesoSPIM_ContrastWindow.mesoSPIM_ContrastWindow(*args: Any, **kwargs: Any)[source]

Bases: QWidget

closeEvent(event)[source]

Override close event: window becomes hidden and inactive, but still exists and ready to pop up when called

set_image(image)

mesoSPIM.src.mesoSPIM_Core module

Core for the mesoSPIM project

mesoSPIM.src.mesoSPIM_Core.logger = <Logger mesoSPIM.src.mesoSPIM_Core (WARNING)>

PyQt5 Imports

class mesoSPIM.src.mesoSPIM_Core.mesoSPIM_Core(*args: Any, **kwargs: Any)[source]

Bases: QObject

This class is the pacemaker of a mesoSPIM

append_timing_info_to_metadata(acq)[source]

Appends a metadata.txt file Path contains the file to be written

check_motion_limits(acq_list)[source]

Check if the motion limits of the stage are violated for each acquisition in the given list.

Parameters:

acq_list (list) – A list of dictionaries representing acquisitions, where each dictionary contains the x, y, and z positions.

Returns:

A list of indices of acquisitions in the input list that violate the motion limits.

Return type:

list

close_acquisition(acq, acq_list)[source]
close_acquisition_list(acq_list)[source]
close_image_series()[source]

Cleans up after series without waveform update

close_shutters()

If shutterswitch = True in the config: Assumes that the shutter_left line is the general shutter and the shutter_right line is the left/right switch (Right==True)

execute_galil_program()[source]

Little helper method to execute the program loaded onto the Galil stage: allows hand controller to operate

execute_script(script)
frame_queue_display

The signal-slot switchboard

get_free_disk_space(acq_list)[source]

Take the disk location of the first file and compute the free disk space

get_required_disk_space(acq_list)[source]

“Compute total image data size from the acquisition list, in bytes

lightsheet_alignment_mode()[source]

Switches shutters after each image to allow coalignment of both lightsheets

list_to_string_with_carriage_return(input_list)[source]
live()[source]
move_absolute(sdict, wait_until_done=False, use_internal_position=True)
move_relative(dict, wait_until_done=False)
open_shutters()

Here the left/right mode is hacked in If shutterswitch = True in the config: Assumes that the shutter_left line is the general shutter and the shutter_right line is the left/right switch (Right==True)

pause(boolean)
prepare_acquisition(acq, acq_list)[source]

Housekeeping: Prepare the acquisition

prepare_acquisition_list(acq_list)[source]

Housekeeping: Prepare the acquisition list

prepare_image_series()[source]

Prepares an image series without waveform update

preview_acquisition(z_update=True)[source]
read_config_parameter(key, dictionary)[source]

Helper method to check if key exists in the dictionary and read its value, or throw a meaningful error

run_acquisition(acq, acq_list)[source]
run_acquisition_list(acq_list)[source]
run_time_lapse(tpoints=1, time_interval_sec=60)[source]

A quick and dirty implementation of time lapse via recursive function.

send_progress(cur_acq, tot_acqs, cur_image, images_in_acq, total_image_count, image_counter, time_passed_string, remaining_time_string)[source]
send_status_message_to_gui(string)
set_camera_exposure_time(time)
set_camera_line_interval(time)
set_filter(filter, wait_until_done=False)
set_intensity(intensity, wait_until_done=False)
set_laser(laser, wait_until_done=False, update_etl=True)
set_shutterconfig(shutterconfig)
set_state(state)[source]
set_zoom(zoom, wait_until_done=True, update_etl=True)
sig_add_images_to_image_series

alias of Acquisition

sig_end_image_series

alias of Acquisition

sig_end_live

Movement-related signals:

sig_get_snap_image

alias of bool

sig_move_absolute

alias of dict

sig_move_relative

alias of dict

sig_move_relative_and_wait_until_done

alias of dict

sig_polling_stage_position_start

ETL-related signals

sig_polling_stage_position_stop

ETL-related signals

sig_position

alias of dict

sig_prepare_image_series

alias of Acquisition

sig_progress

alias of dict

sig_run_timepoint

Camera-related signals

alias of int

sig_state_request

alias of dict

sig_state_request_and_wait_until_done

alias of dict

sig_status_message

alias of str

sig_unzero_axes

alias of list

sig_warning

alias of str

sig_write_metadata

alias of Acquisition

sig_zero_axes

alias of list

snap(write_flag=True, laser_blanking=True)[source]
snap_image(laser_blanking=True)[source]

Snaps a single image after updating the waveforms.

Can be used in acquisitions where changing waveforms are required, but there is additional overhead due to the need to write the waveforms into the buffers of the NI cards.

snap_image_in_series(laser_blanking=True)[source]

Snaps and image from a series without waveform update

start(row=None)[source]
state_request_handler(dict)
stop()[source]
stop_movement()
unzero_axes(list)
visual_mode()[source]
zero_axes(list)

mesoSPIM.src.mesoSPIM_ImageWriter module

mesoSPIM Image Writer class, intended to run in the Camera Thread and handle file I/O

class mesoSPIM.src.mesoSPIM_ImageWriter.mesoSPIM_ImageWriter(*args: Any, **kwargs: Any)[source]

Bases: QObject

abort_writing()

Terminate writing and close all files if STOP button is pressed

check_versions()[source]

Take care of API changes in different library versions

end_acquisition(acq, acq_list)
image_to_disk(acq, acq_list, image)[source]
prepare_acquisition(acq, acq_list)[source]
write_images(acq, acq_list)

Write available images to disk. The actual images are passed via self.frame_queue from the Camera thread, NOT via the signal/slot mechanism as before, starting from v.1.10.0. This is to avoid the overhead of signal/slot mechanism and to improve performance.

write_metadata(acq, acq_list)
write_snap_image(image)[source]
write_snap_metadata(path)[source]

mesoSPIM.src.mesoSPIM_MainWindow module

class mesoSPIM.src.mesoSPIM_MainWindow.mesoSPIM_MainWindow(*args: Any, **kwargs: Any)[source]

Bases: QMainWindow

Main application window which instantiates worker objects and moves them to a thread.

cascade_all_windows()[source]
check_config_file()[source]

Checks missing blocks in config file and gives suggestions. Todo: all new config options

check_instances(widget)[source]

Method to check whether a widget belongs to one of the Qt Classes specified.

Parameters:

widget (QtWidgets.QWidget) – Widget to check

Returns:

True if widget is in the list, False if not.

Return type:

return_value (bool)

choose_etl_config()[source]

File dialog for choosing the config file

choose_snap_folder()[source]
close_app()[source]
connect_combobox_to_state_parameter(combobox, option_list, state_parameter, int_conversion=False)[source]

Helper method to connect and initialize a combobox from the config

Parameters:
  • combobox (QtWidgets.QComboBox) – Combobox in the GUI to be connected

  • option_list (list) – List of selection options

  • state_parameter (str) – State parameter (has to exist in the config)

connect_spinbox_to_state_parameter(spinbox, state_parameter, conversion_factor=1)[source]

Helper method to connect and initialize a spinbox from the config

Parameters:
  • spinbox (QtWidgets.QSpinBox or QtWidgets.QDoubleSpinbox) – Spinbox in the GUI to be connected

  • state_parameter (str) – State parameter (has to exist in the config)

  • conversion_factor (float) – Conversion factor. If the config is in seconds, the spinbox displays ms: conversion_factor = 1000. If the config is in seconds and the spinbox displays microseconds: conversion_factor = 1000000

connect_widget_to_state_parameter(widget, state_parameter, conversion_factor)[source]

Helper method to (currently) connect spinboxes

create_script_window()[source]

Creates a script window for the user to input Python code.

create_widget_list(list, widget_list)[source]

Helper method to recursively loop through all the widgets in a list and their children. :param list: List of QtWidgets.QWidget objects :type list: list

display_status_message(string)

Displays a message in the status bar for a time in ms

display_warning(string)[source]
enable_gui(boolean)[source]
enable_mode_control_buttons(boolean)[source]
enable_move_buttons(axis='x', state=True)[source]
enable_stop_button(boolean)[source]
execute_script(script)
finished()[source]
get_state_parameter(state_parameter)[source]
initialize_and_connect_menubar()[source]
initialize_and_connect_widgets()[source]

Connecting the menu actions

launch_contrast_window()
launch_optimizer(ini_dict=None)
move_relative(pos_dict)
open_tiff()[source]

Open and display a TIFF file (stack), eg for demo and debugging purposes.

open_tile_view_window()[source]
open_webcam_window()[source]

Open USB webcam window using cam ID specified in config file.

pos2str(position)[source]

Little helper method for converting positions to strings

run_acquisition_list()[source]
run_lightsheet_alignment_mode()[source]
run_live()[source]
run_selected_acquisition()[source]
run_snap()[source]
run_timepoint(timepoint)
run_visual_mode()[source]
save_etl_config()[source]

Save current ETL parameters into config

scale_galvo_amp_w_zoom()
set_laser_intensity(value)
set_progressbars_to_busy()[source]

If min and max of a progress bar are 0, it shows a “busy” indicator

set_progressbars_to_standard()[source]
sig_enable_gui

alias of bool

sig_execute_script

alias of str

sig_launch_optimizer

alias of dict

sig_move_absolute

alias of dict

sig_move_relative

alias of dict

sig_state_request

alias of dict

sig_unzero_axes

alias of list

sig_zero_axes

alias of list

slow_down_spinbox(spinbox)[source]
spinbox_to_state_parameter(new_value, spinbox, state_parameter, conversion_factor)[source]
update_GUI_by_shutter_state()

Disables controls for the opposite ETL to avoid overriding parameters

update_etl_increments()[source]
update_gui_from_state()
update_position_indicators(dict)
update_progressbars(dict)
update_widget_from_state(widget, state_parameter_string, conversion_factor)[source]
zero_galvo_amp()[source]

Set the amplitude of both galvos to zero, or back to where it was, depending on button state

zero_left_etl()[source]

Zeros the amplitude of the left ETL for faster alignment

zero_right_etl()[source]

Zeros the amplitude of the right ETL for faster alignment

mesoSPIM.src.mesoSPIM_Optimizer module

Frontend of the optimizer which allows to use auto-focus or optimization of other microscope parameters Auto-focus is based on Autopilot paper (Royer at al, Nat Biotechnol. 2016 Dec;34(12):1267-1278. doi: 10.1038/nbt.3708.) author: Nikita Vladimirov, @nvladimus, 2021 License: GPL-3

class mesoSPIM.src.mesoSPIM_Optimizer.mesoSPIM_Optimizer(*args: Any, **kwargs: Any)[source]

Bases: QWidget

accept_new_state()
close_window()
create_results_window()[source]
discard_new_state()
get_params_from_gui()[source]
get_roi_dims(roi_dims)
plot_results()[source]
results_string()[source]

Pretty formatting

run_optimization()
set_etl_amp_to_zero()[source]
set_mode_from_gui(choice)
set_parameters(param_dict=None, update_gui=True)[source]
set_roi(orientation='h', roi_perc=0.25)[source]
set_state(new_val)[source]
sig_move_absolute

alias of dict

sig_state_request

alias of dict

update_gui()[source]
update_image()

mesoSPIM.src.mesoSPIM_ScriptWindow module

mesoSPIM_ScriptWindow.py

class mesoSPIM.src.mesoSPIM_ScriptWindow.PythonHighlighter(*args: Any, **kwargs: Any)[source]

Bases: QSyntaxHighlighter

Syntax highlighter for the Python language.

braces = ['\\{', '\\}', '\\(', '\\)', '\\[', '\\]']
highlightBlock(text)[source]

Apply syntax highlighting to the given block of text.

keywords = ['and', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'exec', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'not', 'or', 'pass', 'print', 'raise', 'return', 'try', 'while', 'yield', 'None', 'True', 'False']
match_multiline(text, delimiter, in_state, style)[source]

Do highlighting of multi-line strings. delimiter should be a QRegExp for triple-single-quotes or triple-double-quotes, and in_state should be a unique integer to represent the corresponding state changes when inside those strings. Returns True if we’re still inside a multi-line string when this function is finished.

operators = ['=', '==', '!=', '<', '<=', '>', '>=', '\\+', '-', '\\*', '/', '//', '\\%', '\\*\\*', '\\+=', '-=', '\\*=', '/=', '\\%=', '\\^', '\\|', '\\&', '\\~', '>>', '<<']
mesoSPIM.src.mesoSPIM_ScriptWindow.format(color, style='')[source]

Return a QTextCharFormat with the given attributes.

class mesoSPIM.src.mesoSPIM_ScriptWindow.mesoSPIM_ScriptWindow(*args: Any, **kwargs: Any)[source]

Bases: QWidget

At some point: Change this into a Factory class for creating script windows

execute_script()[source]
highlight

Connect parent signals

load_script()[source]

Load a script

The empty string in the method arguments ensures that it remembers the last location from where a file was opened.

save_script()[source]

Save a script as .py file

sig_execute_script

alias of str

mesoSPIM.src.mesoSPIM_Serial module

Serial thread for the mesoSPIM project

This thread handles all connections with serial devices such as stages, filter wheels, zoom systems etc.

class mesoSPIM.src.mesoSPIM_Serial.mesoSPIM_Serial(*args: Any, **kwargs: Any)[source]

Bases: QObject

This class handles mesoSPIM serial connections

enable_ttl_motion(boolean)
execute_stage_program()[source]
go_to_rotation_position(wait_until_done=False)
move_absolute(sdict, wait_until_done=False, use_internal_position=True)
move_relative(sdict, wait_until_done=False)
pause(boolean)
report_position(sdict)
send_status_message(string)
set_filter(sfilter, wait_until_done=False)
set_zoom(zoom, wait_until_done=True)

Here, the state parameters are set before sending the value to the zoom – this is to avoid laggy update loops with the GUI.

sig_pause

alias of bool

sig_position

alias of dict

sig_state_request

alias of dict

sig_status_message

alias of str

sig_unzero_axes

alias of list

sig_zero_axes

alias of list

stage_limits_OK(sdict, safety_margin_n_moves=3)[source]

Safety margin is added to deal with delays in position reporting.

stage_limits_warning

Attaching the filterwheel

state_request_handler(sdict, wait_until_done=False)

mesoSPIM.src.mesoSPIM_Stages module

mesoSPIM Stage classes

class mesoSPIM.src.mesoSPIM_Stages.mesoSPIM_ASI_MS2000_Stage(*args: Any, **kwargs: Any)[source]

Bases: mesoSPIM_Stage

It is expected that the parent class has the following signals:

sig_move_relative = pyqtSignal(dict) sig_move_relative_and_wait_until_done = pyqtSignal(dict) sig_move_absolute = pyqtSignal(dict) sig_move_absolute_and_wait_until_done = pyqtSignal(dict) sig_zero = pyqtSignal(list) sig_unzero = pyqtSignal(list) sig_stop_movement = pyqtSignal()

Also contains a QTimer that regularily sends position updates, e.g during the execution of movements.

This implements an ASI MS2000 controller for a setup with the following configuration * ASI X Stage is equivalent to the mesoSPIM z-stage (moved during stacks direction) * ASI Y Stage is equivalent to the mesoSPIM y-stage * ASI Z-Stage is equivalent to the mesoSPIM f-stage (focus)

load_sample()[source]
log_slice(dictionary)
move_absolute(dict, wait_until_done=False, use_internal_position=True)[source]

ASI move absolute method

Lots of implementation details in here, should be replaced by a facade

move_relative(sdict, wait_until_done=False)[source]

ASI move relative method

Lots of implementation details in here, should be replaced by a facade

pause(boolean)
report_position()[source]
sig_pause

alias of bool

state

ASI-specific code

stop()[source]
unload_sample()[source]
class mesoSPIM.src.mesoSPIM_Stages.mesoSPIM_ASI_Tiger_Stage(*args: Any, **kwargs: Any)[source]

Bases: mesoSPIM_Stage

It is expected that the parent class has the following signals:

sig_move_relative = pyqtSignal(dict) sig_move_relative_and_wait_until_done = pyqtSignal(dict) sig_move_absolute = pyqtSignal(dict) sig_move_absolute_and_wait_until_done = pyqtSignal(dict) sig_zero = pyqtSignal(list) sig_unzero = pyqtSignal(list) sig_stop_movement = pyqtSignal()

Also contains a QTimer that regularily sends position updates, e.g during the execution of movements.

enable_ttl_motion(boolean)[source]
load_sample()[source]
log_slice(dictionary)
move_absolute(dict, wait_until_done=False, use_internal_position=True)[source]

ASI move absolute method

Lots of implementation details in here, should be replaced by a facade

move_relative(sdict, wait_until_done=False)[source]

ASI move relative method Lots of implementation details in here, should be replaced by a facade

pause(boolean)
report_position()[source]
set_speed_from_config()[source]
sig_pause

alias of bool

stop()[source]
unload_sample()[source]
class mesoSPIM.src.mesoSPIM_Stages.mesoSPIM_DemoStage(*args: Any, **kwargs: Any)[source]

Bases: mesoSPIM_Stage

class mesoSPIM.src.mesoSPIM_Stages.mesoSPIM_PI_1toN(*args: Any, **kwargs: Any)[source]

Bases: mesoSPIM_Stage

Configuration with 1 controller connected to N stages, (e.g. C-884, default mesoSPIM V5 setup).

Note: configs as declared in mesoSPIM_config.py:

stage_parameters = {‘stage_type’‘PI_1controllerNstages’,

… }

pi_parameters = {‘controllername’‘C-884’,

‘stages’ : (‘L-509.20DG10’,’L-509.40DG10’,’L-509.20DG10’,’M-060.DG’,’M-406.4PD’,’NOSTAGE’), ‘refmode’ : (‘FRF’,), ‘serialnum’ : (‘118075764’), }

block_till_controller_is_ready()[source]

Blocks further execution (especially during referencing moves) till the PI controller returns ready

load_sample()[source]
move_absolute(sdict, wait_until_done=False, use_internal_position=True)

Lots of implementation details in here, should be replaced by a facade

TODO: Also lots of repeating code. TODO: DRY principle violated

move_relative(sdict, wait_until_done=False)

PI move relative method

Lots of implementation details in here, should be replaced by a facade

pitools

Setting up the PI stages

report_position()[source]
stop()
unload_sample()[source]
class mesoSPIM.src.mesoSPIM_Stages.mesoSPIM_PI_NtoN(*args: Any, **kwargs: Any)[source]

Bases: mesoSPIM_Stage

Expects following microscope configuration:

Sample XYZ movement: Physik Instrumente stage with three L-509-type stepper motor stages and individual C-663 controller. F movement: Physik Instrumente C-663 controller and custom stage with stepper motor Rotation: not implemented

All stage controller are of same type and the sample stages work with reference setting. Focus stage has reference mode set to off.

Note

configs as declared in mesoSPIM_config.py: stage_parameters = {‘stage_type’ : ‘PI_NcontrollersNstages’,

… }

pi_parameters = {‘axes_names’: (‘x’, ‘y’, ‘z’, ‘theta’, ‘f’),

‘stages’: (‘L-509.20SD00’, ‘L-509.40SD00’, ‘L-509.20SD00’, None, ‘MESOSPIM_FOCUS’), ‘controllername’: (‘C-663’, ‘C-663’, ‘C-663’, None, ‘C-663’), ‘serialnum’: (’******’, ‘******’, ‘******’, None, ‘******’), ‘refmode’: (‘FRF’, ‘FRF’, ‘FRF’, None, ‘RON’) }

make sure that reference points are not in conflict with general microscope setup and will not hurt optics under referencing at startup

load_sample()[source]

bring sample to imaging position

move_absolute(move_dict, wait_until_done=False, use_internal_position=True)[source]
move_relative(move_dict, wait_until_done=False)[source]

PI move relative method

report_position()[source]

report stage position

stop()[source]

stop stage movement

unload_sample()[source]

lift sample to sample handling position

wait_for_controller(controller)[source]
class mesoSPIM.src.mesoSPIM_Stages.mesoSPIM_PI_rotz_and_Galil_xyf_Stages(*args: Any, **kwargs: Any)[source]

Bases: mesoSPIM_Stage

Deprecated? Expects following microscope configuration:

Sample XYF movement: Galil controller with 3 axes Z-Movement and Rotation: PI C-884 mercury controller

block_till_controller_is_ready()[source]

Blocks further execution (especially during referencing moves) till the PI controller returns ready

execute_program()[source]

Executes program stored on the Galil controller

f_encodercounts_per_um

XYZ

Type:

Setting up the Galil stages

load_sample()[source]
move_absolute(dict, wait_until_done=False, use_internal_position=True)[source]

Galil move absolute method

Lots of implementation details in here, should be replaced by a facade

move_relative(sdict, wait_until_done=False)[source]

Galil move relative method

Lots of implementation details in here, should be replaced by a facade

pitools

Setting up the PI stages

report_position()[source]
stop()[source]
unload_sample()[source]
xyf_stage

PI-specific code

class mesoSPIM.src.mesoSPIM_Stages.mesoSPIM_Stage(*args: Any, **kwargs: Any)[source]

Bases: QObject

DemoStage for a mesoSPIM microscope

It is expected that the parent class has the following signals:

sig_move_relative = pyqtSignal(dict) sig_move_relative_and_wait_until_done = pyqtSignal(dict) sig_move_absolute = pyqtSignal(dict) sig_move_absolute_and_wait_until_done = pyqtSignal(dict) sig_zero = pyqtSignal(list) sig_unzero = pyqtSignal(list) sig_stop_movement = pyqtSignal()

Also contains a QTimer that regularily sends position updates, e.g during the execution of movements.

center_sample()[source]
create_internal_position_dict()[source]
create_position_dict()[source]
int_theta_pos

Create offsets

It should be:

int_x_pos = x_pos + int_x_pos_offset self.int_x_pos = self.x_pos + self.int_x_pos_offset

OR

x_pos = int_x_pos - int_x_pos_offset self.x_pos = self.int_x_pos - self.int_x_pos_offset

int_theta_pos_offset

currently hardcoded

Open question: Should these be in mm or microns? Answer: Microns for now….

Type:

Setting movement limits

load_sample()[source]
move_absolute(dict, wait_until_done=False, use_internal_position=True)
move_relative(sdict, wait_until_done=False)
report_position()
sig_pause

alias of bool

sig_position

alias of dict

sig_status_message

alias of str

state

The movement signals are emitted by the mesoSPIM_Core, which in turn instantiates the mesoSPIM_Serial object, both (must be) running in the same Core thread.

Therefore, the signals are emitted by the parent of the parent, which is slightly confusing and dirty.

stop()
theta_pos

Internal (software) positions

unload_sample()[source]
unzero_axes(list)[source]
zero_axes(list)[source]

mesoSPIM.src.mesoSPIM_State module

mesoSPIM State class. Only nominally a singleton class, but actually inherited by classes from their parent class.

class mesoSPIM.src.mesoSPIM_State.mesoSPIM_StateSingleton(*args, **kwargs)[source]

Bases: QObject

Singleton object containing the whole mesoSPIM state.

Only classes which control.

Access to attributes is mutex-locked to allow access from multiple threads.

If more than one state parameter should be set at the same time, the set_parameter

block_signals(boolean)[source]
get_parameter_dict(list)[source]

For a list of keys, get a state dict with the current values back.

All the values are read out under a QMutexLocker so that the state cannot be updated at the same time.

get_parameter_list(list)[source]

For a list of keys, get a state list with the current values back.

This is especially useful for unpacking.

All the values are read out under a QMutexLocker so that the state cannot be updated at the same time.

instance = None
set_parameters(dict)[source]

Sometimes, several parameters should be set at once without allowing the state being updated while a parameter is read.

mesoSPIM.src.mesoSPIM_TileViewWindow module

mesoSPIM TileViewWindows

class mesoSPIM.src.mesoSPIM_TileViewWindow.mesoSPIM_TileViewWindow(*args: Any, **kwargs: Any)[source]

Bases: QWidget

on_scale_changed(value=0.01)[source]
show_current_FOV()[source]

Show the current FOV in the center of the scene

show_tiles()[source]
sig_scale_changed

alias of float

state

Set up the UI

mesoSPIM.src.mesoSPIM_WaveFormGenerator module

mesoSPIM Waveform Generator - Creates and allows control of waveform generation.

mesoSPIM.src.mesoSPIM_WaveFormGenerator.logger = <Logger mesoSPIM.src.mesoSPIM_WaveFormGenerator (WARNING)>

National Instruments Imports

class mesoSPIM.src.mesoSPIM_WaveFormGenerator.mesoSPIM_DemoWaveFormGenerator(*args: Any, **kwargs: Any)[source]

Bases: mesoSPIM_WaveFormGenerator

Demo subclass of mesoSPIM_WaveFormGenerator class

close_tasks()[source]

Demo: closes the tasks for triggering, analog and counter outputs.

create_tasks()[source]

“Demo version of the actual DAQmx-based function.

run_tasks()[source]

Demo: runs the tasks for triggering, analog and counter outputs.

start_tasks()[source]

Demo: starts the tasks for camera triggering and analog outputs.

stop_tasks()[source]

“Demo: stop tasks

write_waveforms_to_tasks()[source]

Demo: write the waveforms to the slave tasks

class mesoSPIM.src.mesoSPIM_WaveFormGenerator.mesoSPIM_WaveFormGenerator(*args: Any, **kwargs: Any)[source]

Bases: QObject

This class contains the microscope state

Any access to this global state should only be done via signals sent by the responsible class for actually causing that state change in hardware.

bundle_galvo_and_etl_waveforms()[source]

Stacks the Galvo and ETL waveforms into a numpy array adequate for the NI cards.

In here, the assignment of output channels of the Galvo / ETL card to the corresponding output channel is hardcoded: This could be improved.

calculate_samples()[source]
close_tasks()[source]

Closes the tasks for triggering, analog and counter outputs. Tasks should only be closed are they are stopped.

config_check()[source]

Check config file for old/wrong/deprecated pieces

create_etl_waveforms()[source]
create_galvo_waveforms()[source]
create_laser_waveforms()[source]
create_tasks()[source]

Creates a tasks for the mesoSPIM:

These are: - the master trigger task, a digital out task that only provides a trigger pulse for the others - the camera trigger task, a counter task that triggers the camera in lightsheet mode - the stage trigger task, a counter task that provides a TTL trigger for stages that allow triggered movement (e.g. ASI stages) - the galvo and ETL task (analog out) that controls the left & right galvos for creation of

the light-sheet and shadow avoidance

  • the aser task (analog out) that controls all the laser intensities (Laser should only be on when the camera is acquiring) and the left/right ETL waveforms. This task is bundled with galvo-ETL task if a single DAQmx card is used, because multifunction DAQmx devices can only run only 1 AO hardware-timed task at a time (https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019KWYSA2&l=en-CH)

create_waveforms()[source]
rescale_galvo_amplitude_by_zoom(zoom: float)[source]
run_tasks()[source]

Runs the tasks for triggering, analog and counter outputs

Firstly, the master trigger triggers all other task via a shared trigger line (PFI line as given in the config file).

For this to work, all analog output and counter tasks have to be started so that they are waiting for the trigger signal.

Warning: master_trigger_task does not have explicit sample rate, because some cards like NI-6733 do not support this for DO lines. So the master pulse duration varies depening on the device. Can be as short as small as 1 micro-second!

save_etl_parameters_to_csv()

Saves the current ETL left/right offsets and amplitudes from the values to the ETL csv files

The .csv file needs to contain the following columns:

Wavelength Zoom ETL-Left-Offset ETL-Left-Amp ETL-Right-Offset ETL-Right-Amp

Creates a temporary cfg file with the ending _tmp

start_tasks()[source]

Starts the tasks for camera triggering and analog outputs

If the tasks are configured to be triggered, they won’t output any signals until run_tasks() is called.

state_request_handler(dict)
stop_tasks()[source]

Stops the tasks for triggering, analog and counter outputs

update_etl_parameters_from_csv(cfg_path, laser, zoom)[source]

Updates the internal ETL left/right offsets and amplitudes from the values in the ETL csv files

The .csv file needs to contain the follwing columns:

Wavelength Zoom ETL-Left-Offset ETL-Left-Amp ETL-Right-Offset ETL-Right-Amp

update_etl_parameters_from_laser(laser)[source]

Little helper method: Because laser changes need an ETL parameter update

update_etl_parameters_from_zoom(zoom)[source]

Little helper method: Because the mesoSPIM core is not handling the serial Zoom connection.

write_waveforms_to_tasks()[source]

Write the waveforms to the slave tasks

mesoSPIM.src.mesoSPIM_Zoom module

mesoSPIM Module for controlling a discrete zoom changer

Authors: Fabian Voigt, Nikita Vladimirov

class mesoSPIM.src.mesoSPIM_Zoom.DemoZoom(*args: Any, **kwargs: Any)[source]

Bases: QObject

set_zoom(zoom, wait_until_done=True)[source]
class mesoSPIM.src.mesoSPIM_Zoom.DynamixelZoom(*args: Any, **kwargs: Any)[source]

Bases: Dynamixel

set_zoom(zoom, wait_until_done=True)[source]

Changes zoom after checking that the commanded value exists

class mesoSPIM.src.mesoSPIM_Zoom.MitutoyoZoom(*args: Any, **kwargs: Any)[source]

Bases: QObject

set_zoom(zoom, wait_until_done=True)[source]

Module contents