navigate.model.model.Model
- class navigate.model.model.Model(args: Namespace, configuration: Optional[Dict[str, Any]] = None, event_queue: Optional[Queue] = None)
Bases:
object
Navigate Model Class
Model for Model-View-Controller Software Architecture.
- __init__(args: Namespace, configuration: Optional[Dict[str, Any]] = None, event_queue: Optional[Queue] = None) → None
Initialize the Model.
- Parameters:
args (argparse.Namespace) – Command line arguments.
configuration (Optional[Dict[str, Any]]) – Configuration dictionary. Defaults to None.
event_queue (multiprocessing.Queue) – Event queue. Receives events from the controller.
Methods
__init__
(args[, configuration, event_queue])Initialize the Model.
change_resolution
(resolution_value)Switch resolution mode of the microscope.
create_pipe
(pipe_name)Create a data pipe.
destroy_virtual_microscope
(microscope_name)Destroy a virtual microscope.
End the acquisition.
Get the active microscope.
Get camera line interval time, light sheet exposure, and full chip exposure times.
get_data_buffer
([img_width, img_height])Get the data buffer.
get_feature_list
(idx)Get feature list str by index
Return Microscopes device information.
Get the offset variance maps.
Get the position of the stage.
launch_virtual_microscope
(microscope_name, ...)Launch a virtual microscope.
load_feature_list_from_file
(filename, features)Append feature list from file
load_feature_list_from_str
(feature_list_str)Append feature list from feature_list_str
Load installed feature lists from system folder
load_images
([filenames])Load/Unload images to the Synthetic Camera
mark_saving_flags
(frame_ids)Mark saving flags for the ImageWriter
move_stage
(pos_dict[, wait_until_done])Moves the stages.
Pause the data thread.
prepare_acquisition
([turn_off_flags])Prepare the acquisition.
release_pipe
(pipe_name)Close a data pipe.
Reset live mode feature list.
Resume the data thread.
Run acquisition along with a feature list one time.
run_command
(command, *args, **kwargs)Receives commands from the controller.
run_data_process
([num_of_frames, data_func])Run the data process.
Stream live image to the GUI.
simplified_data_process
(microscope, ...[, ...])Run the data process.
Acquire an image after updating the waveforms.
Stop the stages.
Terminate the model.
update_data_buffer
([img_width, img_height])Update the Data Buffer
update_ilastik_setting
([...])Update the ilastik setting.
update_mirror
([coef, flatten])Update the mirror.
Attributes
Logger object.
Configuration dictionary.
Dictionary of plugin acquisition modes
Dictionary of virtual microscopes.
Dictionary of physical microscopes.
Name of the active microscope.
Name of the active microscope.
Imaging mode.
Number of images acquired.
Number of acquisitions.
Total number of acquisitions.
Total number of images.
Current exposure time in milliseconds
Pre-exposure time in milliseconds
Number of timeouts before aborting acquisition.
Time before acquisition.
Data buffer for image frames.
Number of active pixels in the x-dimension.
Number of active pixels in the y-dimension.
Binning mode.
stage positions.
saving flags for a frame
Is the model acquiring?
Current focus position.
Autofocus maximum entropy.
Autofocus maximum entropy position.
Signal thread.
Data thread.
Show image pipe.
Plot pipe.
Waveform queue.
Frame ID.
Inject a feature list?
Is the model live?
Is the model saving the data?
Stop signal and data threads?
Stop signal thread?
Pause data event.
Pause data ready lock.
Ask to pause data thread?
Number of frames in the data buffer.
Image writer.
add on feature in customized mode
List of features.
- change_resolution(resolution_value: str) → None
Switch resolution mode of the microscope.
- Parameters:
resolution_value (str) – Resolution mode.
- create_pipe(pipe_name: str) → Pipe
Create a data pipe.
Creates a pair of connection objects connected by a pipe which by default is duplex (two-way)
- Parameters:
pipe_name (str) – Name of pipe to create.
- Returns:
end1 – Connection object.
- Return type:
multiprocessing.Pipe
- destroy_virtual_microscope(microscope_name: str) → None
Destroy a virtual microscope.
- Parameters:
microscope_name (str) – Name of microscope.
- end_acquisition() → None
End the acquisition.
Sets the current channel to 0, clears the signal and data containers, disconnects buffer in live mode and closes the shutters.
- get_active_microscope() → Microscope
Get the active microscope.
- Returns:
microscope – Active microscope.
- Return type:
- get_camera_line_interval_and_exposure_time(exposure_time: float, number_of_pixel: int) → Tuple[float, float, float]
Get camera line interval time, light sheet exposure, and full chip exposure times.
- Parameters:
exposure_time (float) – camera global exposure time
number_of_pixel (int) – number of pixel in light sheet mode
- Returns:
camera_times –
- camera_exposure_timefloat
camera exposure time (s)
- camera_line_intervalfloat
camera line interval (s)
- full_chip_exposure_timefloat
Updated full chip exposure time (s).
- Return type:
Tuple[float, float, float]
- get_data_buffer(img_width: int = 512, img_height: int = 512) → List[SharedNDArray]
Get the data buffer.
If the number of active pixels in x and y changes, updates the data buffer and returns newly-sized buffer.
- Parameters:
img_height (int) – Number of active pixels in the x-dimension.
img_width (int) – Number of active pixels in the y-dimension.
- Returns:
data_buffer – Shared memory object.
- Return type:
List[SharedNDArray]
- get_feature_list(idx: int) → str
Get feature list str by index
- Parameters:
idx (int) – index of feature list
- Returns:
feature_list_str –
Any empty string if the feature is not found
The name of the feature if it is found
- Return type:
str
- get_microscope_info() → Dict[str, Any]
Return Microscopes device information.
- Returns:
microscope_info – Microscope device information.
- Return type:
Dict[str, Any]
- get_offset_variance_maps() → Tuple[ndarray, ndarray]
Get the offset variance maps.
- Returns:
offset_variance_maps – Offset variance maps.
- Return type:
Tuple[np.ndarray, np.ndarray]
- get_stage_position() → Dict[str, Any]
Get the position of the stage.
- Returns:
ret_pos_dict – Dictionary of stage positions.
- Return type:
dict
- launch_virtual_microscope(microscope_name: str, microscope_config: Dict[str, Any]) → List[SharedNDArray]
Launch a virtual microscope.
- Parameters:
microscope_name (str) – Name of microscope.
microscope_config (dict) – Configuration of microscope.
- Returns:
data_buffer – List of data buffer.
- Return type:
list
- load_feature_list_from_file(filename: str, features: list[str]) → None
Append feature list from file
- Parameters:
filename (str) – filename of the feature list.
features (list[str]) – list of feature names to load from file.
- load_feature_list_from_str(feature_list_str: str) → None
Append feature list from feature_list_str
- Parameters:
feature_list_str (str) – the str of a feature list
- load_feature_records() → None
Load installed feature lists from system folder
Note
System folder can be found at ‘…./.navigate/feature_lists’
- load_images(filenames: Optional[list[str]] = None) → None
Load/Unload images to the Synthetic Camera
- Parameters:
filenames (Optional[list[str]]) – The list of filenames to load.
- mark_saving_flags(frame_ids: list)
Mark saving flags for the ImageWriter
- Parameters:
frame_ids (list) – a list of frame ids
- move_stage(pos_dict: Dict[str, Any], wait_until_done=False) → bool
Moves the stages.
Updates the stage dictionary, moves to the desired position, and reports the position.
- Parameters:
pos_dict (Dict[str, Any]) – Dictionary of stage positions.
wait_until_done (bool) – Checks “on target state” after command and waits until done.
- Returns:
success – Was the move successful?
- Return type:
bool
- pause_data_thread() → None
Pause the data thread.
Function is called when user pauses the acquisition.
- prepare_acquisition(turn_off_flags: bool = True) → None
Prepare the acquisition.
This function is called when user starts the acquisition. Sets flags. Calculates all the waveforms. Sets the Camera Sensor Mode Initializes the data buffer and starts camera. Opens Shutters
- Parameters:
turn_off_flags (bool) – Turn off the flags.
- release_pipe(pipe_name: str) → None
Close a data pipe.
- Parameters:
pipe_name (str) – Name of pipe to close.
- reset_feature_list() → None
Reset live mode feature list.
- resume_data_thread() → None
Resume the data thread.
Function is called when user resumes the acquisition.
- run_acquisition() → None
Run acquisition along with a feature list one time.
- run_command(command: str, *args: List[Union[str, int]], **kwargs: Dict[str, Any])
Receives commands from the controller.
- Parameters:
command (str) – Type of command to run.
*args (List[Union[str, int]]) – List of arguments to pass to the command.
**kwargs (Dict[str, Any]) – Dictionary of keyword arguments to pass to the command.
- run_data_process(num_of_frames: Optional[int] = 0, data_func: Optional[callable] = None) → None
Run the data process.
This function is the structure of data thread.
- Parameters:
num_of_frames (Optional[int]) – Number of frames to acquire. Default is 0.
data_func (Optional[callable]) – Function to run on the acquired data. Default is None.
- run_live_acquisition() → None
Stream live image to the GUI.
Recalculates the waveforms for each image, thereby allowing people to adjust acquisition parameters in real-time.
- simplified_data_process(microscope: Microscope, show_img_pipe: Pipe, data_func: Optional[callable] = None) → None
Run the data process.
- Parameters:
microscope (Microscope) – Instance of the Microscope object.
show_img_pipe (multiprocessing.Pipe) – The pipe for delivering images to the Controller.
data_func (callable) – Function to run on the acquired data.
- snap_image() → None
Acquire an 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 DAQ cards.
- stop_stage() → None
Stop the stages.
- terminate() → None
Terminate the model.
- update_data_buffer(img_width: int = 512, img_height: int = 512) → None
Update the Data Buffer
- Parameters:
img_width (int) – Number of active pixels in the x-dimension.
img_height (int) – Number of active pixels in the y-dimension.
- update_ilastik_setting(display_segmentation: Optional[bool] = False, mark_position: Optional[bool] = True, target_labels: Optional[list[int]] = [1]) → None
Update the ilastik setting.
- Parameters:
display_segmentation (Optional[bool]) – Display segmentation. Default is False.
mark_position (Optional[bool]) – Mark position. Default is True.
target_labels (Optional[list[int]]) – Target labels. Default is [1].
- update_mirror(coef: list = [], flatten: bool = False) → None
Update the mirror.
- Parameters:
coef (list) – The list of coefficients. Default is [].
flatten (bool) – Flatten the mirror? Default is False.
- acquisition_count
Number of acquisitions.
- Type:
int
- active_microscope
Name of the active microscope.
- Type:
str
- active_microscope_name
Name of the active microscope.
- Type:
str
- addon_feature
add on feature in customized mode
- Type:
list
- ask_to_pause_data_thread
Ask to pause data thread?
- Type:
bool
- binning
Binning mode.
- Type:
str
- camera_wait_iterations
Number of timeouts before aborting acquisition.
- Type:
int
- configuration
Configuration dictionary.
- Type:
dict
- current_exposure_time
Current exposure time in milliseconds
- Type:
float
- data_buffer
Data buffer for image frames.
- Type:
List[SharedNDArray]
- data_buffer_positions
stage positions.
- Type:
array
- data_buffer_saving_flags
saving flags for a frame
- Type:
array
- data_thread
Data thread.
- Type:
threading.Thread
- event_queue
Waveform queue.
- Type:
multiprocessing.Queue
- f_position
Current focus position.
- Type:
float
- feature_list
List of features.
- Type:
list
- focus_pos
Autofocus maximum entropy position.
- Type:
float
- frame_id
Frame ID.
- Type:
int
- image_count
Number of images acquired.
- Type:
int
- image_writer
Image writer.
- Type:
- imaging_mode
Imaging mode.
- Type:
str
- img_height
Number of active pixels in the y-dimension.
- Type:
int
- img_width
Number of active pixels in the x-dimension.
- Type:
int
- injected_flag
Inject a feature list?
- Type:
bool
- is_acquiring
Is the model acquiring?
- Type:
bool
- is_live
Is the model live?
- Type:
bool
- is_save
Is the model saving the data?
- Type:
bool
- logger
Logger object.
- Type:
object
- max_entropy
Autofocus maximum entropy.
- Type:
float
- microscopes
Dictionary of physical microscopes.
- Type:
dict
- number_of_frames
Number of frames in the data buffer.
- Type:
int
- pause_data_event
Pause data event.
- Type:
event
- pause_data_ready_lock
Pause data ready lock.
- Type:
threading.Lock
- plot_pipe
Plot pipe.
- Type:
multiprocessing.connection.Connection
- plugin_acquisition_modes
Dictionary of plugin acquisition modes
- Type:
dict
- pre_exposure_time
Pre-exposure time in milliseconds
- Type:
float
- show_img_pipe
Show image pipe.
- Type:
multiprocessing.connection.Connection
- signal_thread
Signal thread.
- Type:
threading.Thread
- start_time
Time before acquisition.
- Type:
float
- stop_acquisition
Stop signal and data threads?
- Type:
bool
- stop_send_signal
Stop signal thread?
- Type:
bool
- total_acquisition_count
Total number of acquisitions.
- Type:
int
- total_image_count
Total number of images.
- Type:
int
- virtual_microscopes
Dictionary of virtual microscopes.
- Type:
dict