Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge sides #132

Merged
merged 9 commits into from
Jul 1, 2022
Merged
4 changes: 2 additions & 2 deletions src/aslm/controller/aslm_configuration_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ def get_pixels(self, verbose=False):
self.configuration.CameraParameters['y_pixels']]

def get_framerate(self, verbose=False):
'''
"""
# Gets default framerate info from camera
'''
"""
pass # TODO Kevin this is where you pull in and then calculate the info from the config file to initializing the framerate widgets

def get_stage_position(self):
Expand Down
26 changes: 13 additions & 13 deletions src/aslm/controller/aslm_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@
# Standard Library Imports
import tkinter
import multiprocessing as mp
import time
import threading
from pathlib import Path

# Third Party Imports

Expand All @@ -62,7 +60,8 @@
# Local Model Imports
from aslm.model.aslm_model import Model
from aslm.model.aslm_model_config import Session as session
from aslm.model.concurrency.concurrency_tools import ObjectInSubprocess, SharedNDArray
from aslm.model.concurrency.concurrency_tools import ObjectInSubprocess
from aslm.tools.common_dict_tools import update_settings_common, update_stage_dict

# debug
from aslm.controller.aslm_debug import Debug_Module
Expand All @@ -71,11 +70,11 @@
from pathlib import Path

# Logger Setup

import logging
p = __name__.split(".")[1]
logger = logging.getLogger(p)


class ASLM_controller:
""" ASLM Controller

Expand Down Expand Up @@ -140,7 +139,7 @@ def __init__(

# etl setting file
self.etl_constants_path = etl_constants_path
self.etl_setting = session(self.etl_constants_path, self.verbose)
self.etl_constants = session(self.etl_constants_path, self.verbose)

# Initialize the View
self.view = view(root)
Expand Down Expand Up @@ -285,10 +284,12 @@ def popup_etl_setting():
etl_setting_popup = remote_popup(self.view) # TODO: should we rename etl_setting popup to remote_focus_popup?
self.etl_controller = Etl_Popup_Controller(etl_setting_popup,
self,
self.verbose,
self.etl_setting,
self.etl_constants,
self.etl_constants_path,
self.experiment.GalvoParameters)
self.configuration,
self.experiment.GalvoParameters,
self.verbose)

self.etl_controller.set_experiment_values(self.resolution_value.get())
self.etl_controller.set_mode(self.acquire_bar_controller.mode)

Expand Down Expand Up @@ -335,7 +336,7 @@ def popup_autofocus_setting():
meso_res_sub_menu = tkinter.Menu(self.view.menubar.menu_resolution)
self.view.menubar.menu_resolution.add_cascade(menu=meso_res_sub_menu,label='Mesoscale')

for res in self.etl_setting.ETLConstants['low'].keys():
for res in self.etl_constants.ETLConstants['low'].keys():
meso_res_sub_menu.add_radiobutton(label=res,
variable=self.resolution_value,
value=res)
Expand Down Expand Up @@ -449,7 +450,7 @@ def set_mode_of_sub(self, mode):
self.etl_controller.set_mode(mode)
if mode == 'stop':
# GUI Failsafe
self.acquire_bar_controller.view.acquire_btn.configure(text='Acquire')
self.acquire_bar_controller.stop_acquire()

def update_camera_view(self):
r"""Update the real-time parameters in the camera view (channel number, max counts, image, etc.)
Expand Down Expand Up @@ -546,6 +547,7 @@ def execute(self, command, *args):
'laser_info': self.resolution_info.ETLConstants[self.resolution][self.mag]
}
"""
update_settings_common(self, args)
self.threads_pool.createThread('model', lambda: self.model.run_command('update_setting', *args))

elif command == 'autofocus':
Expand Down Expand Up @@ -715,9 +717,7 @@ def move_stage(self, pos_dict):
"""

# Update our local stage dictionary
for axis, val in pos_dict.items():
ax = axis.split('_')[0]
self.experiment.StageParameters[ax] = val
update_stage_dict(self, pos_dict)

# Pass to model
self.model.move_stage(pos_dict)
Expand Down
10 changes: 5 additions & 5 deletions src/aslm/controller/sub_controllers/acquire_bar_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
p = __name__.split(".")[1]
logger = logging.getLogger(p)


class Acquire_Bar_Controller(GUI_Controller):
def __init__(self, view, parent_controller, verbose=False):
super().__init__(view, parent_controller, verbose)
Expand Down Expand Up @@ -153,9 +154,7 @@ def launch_popup_window(self):
# tell the controller to stop acquire(continuous mode)
self.parent_controller.execute('stop_acquire')
else:
# if the mode is 'live'
if self.mode == 'live':
self.view.acquire_btn.configure(text='Stop')
self.view.acquire_btn.configure(text='Stop')
self.parent_controller.execute('acquire')

def update_microscope_mode(self, *args):
Expand All @@ -174,8 +173,6 @@ def update_file_type(self, file_type):
"""
self.saving_settings['file_type'] = file_type.get()



def launch_acquisition(self, popup_window):
"""
# Once the popup window has been filled out, we first create the save path using the create_save_path function.
Expand All @@ -198,6 +195,9 @@ def launch_acquisition(self, popup_window):
# Close the window
popup_window.popup.dismiss(self.verbose)

# We are now acquiring
self.view.acquire_btn.configure(text='Stop')

def exit_program(self):
self.show_verbose_info("Exiting Program")
# call the central controller to stop all the threads
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ def start_autofocus(self):
self.parent_controller.execute('autofocus')

def display_plot(self, data):
'''
"""
### Displays a plot of [focus, entropy] with data from autofocus routine
'''
"""

coarse_range = self.setting_dict['coarse_range']
coarse_step = self.setting_dict['coarse_step_size']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ def __init__(
)

def initialize(self, config):
'''
"""
## Function that sets widgets based on data given from main controller/config
'''
"""

# Get Default Configuration Values
self.default_pixel_size = config.configuration.CameraParameters['pixel_size_in_microns']
Expand Down Expand Up @@ -206,7 +206,7 @@ def update_experiment_values(self, setting_dict):
return True

def update_sensor_mode(self, *args):
'''
"""
Updates text in readout widget based on what sensor mode is selected
If we are in the Light Sheet mode, then we want the camera
self.model.CameraParameters['sensor_mode']) == 12
Expand All @@ -215,7 +215,7 @@ def update_sensor_mode(self, *args):
self.model.CameraParameters['sensor_mode']) == 1

Should initialize from the configuration file to the default version
'''
"""
# Camera Mode
sensor_value = self.mode_widgets['Sensor'].widget.get()
if sensor_value == 'Normal':
Expand Down
18 changes: 4 additions & 14 deletions src/aslm/controller/sub_controllers/camera_view_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def __init__(self, view, parent_controller=None, verbose=False):
# Stored Images
self.tk_image = None
self.image = None
self.cross_hair_image = None
self.saturated_pixels = None

# Widget Defaults
Expand All @@ -103,9 +104,9 @@ def __init__(self, view, parent_controller=None, verbose=False):
self.bit_depth = 8 # bit-depth for PIL presentation.

def initialize(self, name, data):
'''
"""
# Function that sets widgets based on data given from main controller/config
'''
"""
# Pallete section (colors, autoscale, min/max counts)
# keys = ['Frames to Avg', 'Image Max Counts', 'Channel']
if name == 'minmax':
Expand Down Expand Up @@ -180,10 +181,6 @@ def update_max_counts(self):
# Update GUI
self.image_metrics['Image'].set(np.max(self.temp_array))

if self.verbose:
print("Rolling Average: ", self.image_count, self.rolling_frames)
logger.debug(f"Rolling Average: , {self.image_count}, {self.rolling_frames}")

def downsample_image(self):
"""
# Down-sample the data for image display according to the configuration file.
Expand Down Expand Up @@ -278,8 +275,7 @@ def add_crosshair(self):
self.cross_hair_image[height, :] = 1

def apply_LUT(self):
"""
Applies a LUT to the image.
r"""Applies a LUT to the image.
Red is reserved for saturated pixels.
self.color_values = ['gray', 'gradient', 'rainbow']
"""
Expand Down Expand Up @@ -335,15 +331,11 @@ def toggle_min_max_buttons(self):
if self.autoscale is True: # Autoscale Enabled
self.image_palette['Min'].widget['state'] = 'disabled'
self.image_palette['Max'].widget['state'] = 'disabled'
if self.verbose:
print("Autoscale Enabled")
logger.debug("Autoscale Enabled")

elif self.autoscale is False: # Autoscale Disabled
self.image_palette['Min'].widget['state'] = 'normal'
self.image_palette['Max'].widget['state'] = 'normal'
if self.verbose:
print("Autoscale Disabled")
logger.debug("Autoscale Disabled")
self.update_min_max_counts()

Expand All @@ -357,7 +349,5 @@ def update_min_max_counts(self):
"""
self.min_counts = self.image_palette['Min'].get()
self.max_counts = self.image_palette['Max'].get()
if self.verbose:
print("Min and Max counts scaled to ", self.min_counts, self.max_counts)
logger.debug(f"Min and Max counts scaled to, {self.min_counts}, {self.max_counts}")

Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
p = __name__.split(".")[1]
logger = logging.getLogger(p)

'''
"""
TODO Create a dictionary for widgets that holds a list of widgets for each column.Will attempt after formatting.
'''
"""

class Channel_Setting_Controller(GUI_Controller):
def __init__(self, view, parent_controller=None, verbose=False):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,12 @@ def set_mode(self, mode):
self.mode = mode
self.channel_setting_controller.set_mode(mode)

state = 'normal' if mode == 'stop' else 'disabled'
self.view.stack_acq_frame.step_size_spinbox['state'] = state
self.view.stack_acq_frame.start_pos_spinbox['state'] = state
self.view.stack_acq_frame.end_pos_spinbox['state'] = state
state = 'active' if mode == 'stop' else 'disabled'
self.stack_acq_widgets['step_size'].state([state])
self.stack_acq_widgets['start_position'].state([state])
self.stack_acq_widgets['end_position'].state([state])

state = 'normal' if mode == 'stop' else 'disabled'
self.view.stack_timepoint_frame.save_check['state'] = state
self.view.stack_timepoint_frame.stack_pause_spinbox['state'] = state
self.view.stack_timepoint_frame.exp_time_spinbox['state'] = state
Expand Down
Loading