Skip to content

Commit ded6e63

Browse files
Merge branch 'develop' into pr/941
2 parents fd27e4c + c08428c commit ded6e63

35 files changed

+233
-257
lines changed

src/navigate/controller/sub_controllers/__init__.py

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,23 @@
22
Sub-controllers for navigate.
33
"""
44

5-
from .stage_controller import StageController # noqa
6-
from .acquire_bar_controller import AcquireBarController # noqa
7-
from .channels_tab_controller import ChannelsTabController # noqa
8-
from .camera_view_controller import CameraViewController # noqa
9-
from .camera_setting_controller import CameraSettingController # noqa
10-
from .waveform_tab_controller import WaveformTabController # noqa
11-
from .waveform_popup_controller import WaveformPopupController # noqa
12-
from .autofocus_popup_controller import AutofocusPopupController # noqa
13-
from .features_popup_controller import FeaturePopupController # noqa
14-
from .feature_advanced_setting_controller import (
15-
FeatureAdvancedSettingController, # noqa
16-
)
17-
from .keystroke_controller import KeystrokeController # noqa
18-
from .multi_position_controller import MultiPositionController # noqa
19-
from .ilastik_popup_controller import IlastikPopupController # noqa
20-
from .camera_map_setting_popup_controller import CameraMapSettingPopupController # noqa
21-
from .microscope_popup_controller import MicroscopePopupController # noqa
22-
from .adaptiveoptics_popup_controller import AdaptiveOpticsPopupController # noqa
5+
from .stages import StageController # noqa
6+
from .acquire_bar import AcquireBarController # noqa
7+
from .channels_tab import ChannelsTabController # noqa
8+
from .camera_view import CameraViewController # noqa
9+
from .camera_settings import CameraSettingController # noqa
10+
from .waveform_tab import WaveformTabController # noqa
11+
from .waveform_popup import WaveformPopupController # noqa
12+
from .autofocus import AutofocusPopupController # noqa
13+
from .features_popup import FeaturePopupController # noqa
14+
from .feature_advanced_setting import FeatureAdvancedSettingController # noqa
15+
from .keystrokes import KeystrokeController # noqa
16+
from .multiposition import MultiPositionController # noqa
17+
from .ilastik import IlastikPopupController # noqa
18+
from .camera_map import CameraMapSettingPopupController # noqa
19+
from .microscope_popup import MicroscopePopupController # noqa
20+
from .adaptive_optics import AdaptiveOpticsPopupController # noqa
21+
2322
# from .uninstall_plugin_controller import UninstallPluginController # noqa
24-
from .plugins_controller import PluginsController, UninstallPluginController # noqa
25-
from .menu_controller import MenuController # noqa
23+
from .plugins import PluginsController, UninstallPluginController # noqa
24+
from .menus import MenuController # noqa

src/navigate/controller/sub_controllers/acquire_bar_controller.py renamed to src/navigate/controller/sub_controllers/acquire_bar.py

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
# Third Party Imports
3838

3939
# Local Imports
40-
from navigate.controller.sub_controllers.gui_controller import GUIController
40+
from navigate.controller.sub_controllers.gui import GUIController
4141
from navigate.view.popups.acquire_popup import AcquirePopUp
4242

4343
# Logger Setup
@@ -54,20 +54,21 @@ def __init__(self, view, parent_controller):
5454
Parameters
5555
----------
5656
view : object
57-
Instance of the Acquire Bar View.
58-
parent_view : object
59-
Instance of the Main View.
57+
Instance of the View.
6058
parent_controller : object
6159
Instance of the Main Controller.
6260
"""
6361
super().__init__(view, parent_controller)
6462

6563
#: str: Acquisition image mode.
6664
self.mode = "live"
65+
6766
#: bool: Whether the image will be saved.
6867
self.is_save = False
68+
6969
#: bool: Whether the microscope is acquiring.
7070
self.is_acquiring = False
71+
7172
#: dict: Dictionary of different operating modes.
7273
self.mode_dict = {
7374
"Continuous Scan": "live",
@@ -101,10 +102,6 @@ def progress_bar(self, images_received, microscope_state, mode, stop=False):
101102
Number of images received in the controller.
102103
stop : bool
103104
Stop flag to set back to 0.
104-
105-
Examples
106-
--------
107-
>>> progress_bar(0, microscope_state, mode)
108105
"""
109106

110107
if images_received == 0:
@@ -171,10 +168,7 @@ def progress_bar(self, images_received, microscope_state, mode, stop=False):
171168
except ZeroDivisionError:
172169
pass
173170

174-
if (
175-
mode == "z-stack"
176-
or mode == "ConstantVelocityAcquisition"
177-
):
171+
if mode == "z-stack" or mode == "ConstantVelocityAcquisition":
178172
top_percent_complete = 100 * (
179173
images_received / top_anticipated_images
180174
)
@@ -223,9 +217,7 @@ def update_progress_label(self, seconds_left):
223217
hours, remainder = divmod(seconds_left, 3600)
224218
minutes, seconds = divmod(remainder, 60)
225219
self.view.total_acquisition_label.config(
226-
text=f"{int(hours):02}"
227-
f":{int(minutes):02}"
228-
f":{int(seconds):02}"
220+
text=f"{int(hours):02}" f":{int(minutes):02}" f":{int(seconds):02}"
229221
)
230222

231223
def set_mode(self, mode):
@@ -235,10 +227,6 @@ def set_mode(self, mode):
235227
----------
236228
mode: str
237229
Mode could be: 'live', 'z-stack', 'single', 'projection',
238-
239-
Examples
240-
--------
241-
>>> set_mode('live')
242230
"""
243231
# update pull down combobox
244232
reverse_dict = dict(map(lambda v: (v[1], v[0]), self.mode_dict.items()))
@@ -258,10 +246,6 @@ def get_mode(self):
258246
-------
259247
mode : str
260248
Current imaging mode.
261-
262-
Examples
263-
--------
264-
>>> get_mode()
265249
"""
266250
return self.mode
267251

@@ -271,12 +255,7 @@ def add_mode(self, mode):
271255
self.view.pull_down["values"] = list(self.mode_dict.keys())
272256

273257
def stop_acquire(self):
274-
"""Stop the acquisition.
275-
276-
Examples
277-
--------
278-
>>> stop_acquire()
279-
"""
258+
"""Stop the acquisition."""
280259
self.stop_progress_bar()
281260
self.view.acquire_btn.configure(text="Acquire")
282261
self.view.acquire_btn.configure(state="normal")
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
# from matplotlib.axes import Axes
4040

4141
# Local application imports
42-
from navigate.controller.sub_controllers.gui_controller import GUIController
42+
from navigate.controller.sub_controllers.gui import GUIController
4343

4444
# Logger Setup
4545
p = __name__.split(".")[1]
@@ -318,7 +318,7 @@ def run_tony_wilson(self):
318318
# set the saving file name before running
319319
if self.widgets["save_report"]["variable"].get():
320320
save_dir = self.parent_controller.configuration["experiment"]["Saving"][
321-
"save_directory"
321+
"save_directory"
322322
]
323323

324324
self.report_path = filedialog.asksaveasfilename(
@@ -334,7 +334,7 @@ def save_report_to_file(self, report):
334334
full_report = {}
335335

336336
for i, page in enumerate(report):
337-
full_report[f"iter_{i}"] = page
337+
full_report[f"iter_{i}"] = page
338338

339339
import pandas as pd
340340

src/navigate/controller/sub_controllers/autofocus_popup_controller.py renamed to src/navigate/controller/sub_controllers/autofocus.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
from tkinter import messagebox
3939

4040
# Local Imports
41-
from navigate.controller.sub_controllers.gui_controller import GUIController
41+
from navigate.controller.sub_controllers.gui import GUIController
4242
from navigate.tools.common_functions import combine_funcs
4343

4444

@@ -62,13 +62,17 @@ def __init__(self, view, parent_controller):
6262
The parent controller of the autofocus popup.
6363
"""
6464
super().__init__(view, parent_controller)
65+
6566
#: dict: The autofocus setting dictionary.
6667
self.widgets = self.view.get_widgets()
68+
6769
#: object: The autofocus figure.
6870
self.autofocus_fig = self.view.fig
71+
6972
#: object: The autofocus coarse plot.
7073
self.autofocus_coarse = self.view.coarse
7174
self.populate_experiment_values()
75+
7276
#: object: The autofocus coarse plot.
7377
self.coarse_plot = None
7478

@@ -147,7 +151,7 @@ def start_autofocus(self):
147151
value = float(setting_dict[f"{k}_range"])
148152
if step <= 0 or value < step:
149153
warning_message += f"{k} settings are not correct!\n"
150-
except:
154+
except Exception:
151155
warning_message += f"{k} settings are not correct!\n"
152156
if warning_message:
153157
messagebox.showerror(
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import tifffile
4040

4141
# Local application imports
42-
from navigate.controller.sub_controllers.gui_controller import GUIController
42+
from navigate.controller.sub_controllers.gui import GUIController
4343
from navigate.config import get_navigate_path
4444
from navigate.model.analysis.camera import compute_scmos_offset_and_variance_map
4545

@@ -62,10 +62,13 @@ def __init__(self, view, parent_controller=None):
6262
Parent controller of this controller.
6363
"""
6464
super().__init__(view, parent_controller)
65+
6566
#: str: Path to the camera maps directory.
6667
self.map_path = os.path.join(get_navigate_path(), "camera_maps")
68+
6769
#: np.ndarray: Offset map.
6870
self.off = None
71+
6972
#: np.ndarray: Variance map.
7073
self.var = None
7174

@@ -79,10 +82,6 @@ def showup(self):
7982
"""Show the popup.
8083
8184
This method is called by the parent controller.
82-
83-
Example
84-
-------
85-
>>> self.parent_controller.show_popup("camera_map_setting_popup")
8685
"""
8786
self.view.showup()
8887

@@ -138,13 +137,11 @@ def display_plot(self):
138137

139138
self.view.axs[0].hist(self.off.ravel(), bins=range(0, 2**8))
140139
self.view.axs[1].hist(self.var.ravel() * 0.47 * 0.47, bins=range(0, 2**8))
141-
142140
self.view.axs[0].set_xlabel("Offset (counts)")
143141
self.view.axs[0].set_ylabel("Frequency")
144142
self.view.axs[0].set_yscale("log")
145143
self.view.axs[1].set_xlabel("Variance (counts$^2$)")
146144
self.view.axs[1].set_ylabel("Frequency")
147145
self.view.axs[1].set_yscale("log")
148146
self.view.fig.tight_layout()
149-
150147
self.view.fig.canvas.draw_idle()

src/navigate/controller/sub_controllers/camera_setting_controller.py renamed to src/navigate/controller/sub_controllers/camera_settings.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
# Third Party Imports
3737

3838
# Local Imports
39-
from navigate.controller.sub_controllers.gui_controller import GUIController
39+
from navigate.controller.sub_controllers.gui import GUIController
4040

4141
# Logger Setup
4242
p = __name__.split(".")[1]
@@ -58,44 +58,59 @@ def __init__(self, view, parent_controller=None):
5858
"""
5959
super().__init__(view, parent_controller)
6060

61-
# default values
6261
#: bool: True if in initialization
6362
self.in_initialization = True
63+
6464
#: str: Resolution value
6565
self.resolution_value = "1x"
66+
6667
#: str: Mode value
6768
self.mode = "stop"
69+
6870
#: str: Solvent type
6971
self.solvent = "BABB"
7072

7173
# Getting Widgets/Buttons
74+
7275
#: dict: Mode widgets
7376
self.mode_widgets = view.camera_mode.get_widgets()
77+
7478
#: dict: Framerate widgets
7579
self.framerate_widgets = view.framerate_info.get_widgets()
80+
7681
#: dict: ROI widgets
7782
self.roi_widgets = view.camera_roi.get_widgets()
83+
7884
#: dict: ROI buttons
7985
self.roi_btns = view.camera_roi.get_buttons()
8086

8187
# initialize
88+
8289
#: int: Default pixel size
8390
self.default_pixel_size = None
91+
8492
#: int: Default width
8593
#: int: Default height
8694
self.default_width, self.default_height = None, None
95+
8796
#: int: Trigger type - 1: Internal, 2: External, 3: Synchronous
8897
self.trigger_source = None
98+
8999
#: int: Trigger active - 1: Edge, 2: Level, 3: Synchronous
90100
self.trigger_active = None
101+
91102
#: int: Readout speed
92103
self.readout_speed = None
104+
93105
#: int: Camera width step interval
94106
self.step_width = 4
107+
95108
#: int: Camera height step interval
96109
self.step_height = 4
110+
97111
#: int: Camera width minimum
98112
self.min_width = 4
113+
99114
#: int: Camera height minimum
100115
self.min_height = 4
101116
self.initialize()
@@ -187,6 +202,7 @@ def populate_experiment_values(self):
187202
self.camera_setting_dict = self.parent_controller.configuration["experiment"][
188203
"CameraParameters"
189204
]
205+
190206
#: dict: Microscope state dictionary
191207
self.microscope_state_dict = self.parent_controller.configuration["experiment"][
192208
"MicroscopeState"
@@ -450,7 +466,7 @@ def calculate_physical_dimensions(self):
450466
try:
451467
x_pixel = float(self.roi_widgets["Width"].get())
452468
y_pixel = float(self.roi_widgets["Height"].get())
453-
except ValueError as e:
469+
except ValueError:
454470
return
455471

456472
microscope_state_dict = self.parent_controller.configuration["experiment"][
@@ -505,7 +521,7 @@ def update_number_of_pixels(self, *args):
505521

506522
if self.pixel_event_id:
507523
self.view.after_cancel(self.pixel_event_id)
508-
524+
509525
pixels = self.mode_widgets["Pixels"].get()
510526
if pixels == "":
511527
return

src/navigate/controller/sub_controllers/camera_view_controller.py renamed to src/navigate/controller/sub_controllers/camera_view.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
import copy
4545

4646
# Local Imports
47-
from navigate.controller.sub_controllers.gui_controller import GUIController
47+
from navigate.controller.sub_controllers.gui import GUIController
4848
from navigate.model.analysis.camera import compute_signal_to_noise
4949
from navigate.tools.common_functions import VariableWithLock
5050

0 commit comments

Comments
 (0)