def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # load objects
        self.microcontroller = microcontroller.Microcontroller_Simulation()
        self.navigationController = core.NavigationController(
            self.microcontroller)

        self.camera_1 = camera.Camera_Simulation(sn='FW0190110139')  # tracking
        self.camera_2 = camera.Camera_Simulation(
            sn='FU0190090030')  # fluorescence

        self.configurationManager_1 = core.ConfigurationManager(
            filename=str(Path.home()) + "/configurations_tracking.xml")
        self.configurationManager_2 = core.ConfigurationManager(
            filename=str(Path.home()) + "/configurations_fluorescence.xml")

        self.streamHandler_1 = core.StreamHandler()
        self.liveController_1 = core.LiveController(
            self.camera_1,
            self.microcontroller,
            self.configurationManager_1,
            control_illumination=False)
        #self.autofocusControlle_1 = core.AutoFocusController(self.camera,self.navigationController,self.liveController)
        #self.multipointController_1 = core.MultiPointController(self.camera,self.navigationController,self.liveController,self.autofocusController,self.configurationManager)
        self.imageSaver_1 = core.ImageSaver()

        self.streamHandler_2 = core.StreamHandler()
        self.liveController_2 = core.LiveController(
            self.camera_2,
            self.microcontroller,
            self.configurationManager_2,
            control_illumination=True)
        self.autofocusController_2 = core.AutoFocusController(
            self.camera_2, self.navigationController, self.liveController_2)
        self.multipointController_2 = core.MultiPointController(
            self.camera_2, self.navigationController, self.liveController_2,
            self.autofocusController_2, self.configurationManager_2)
        self.imageSaver_2 = core.ImageSaver()

        self.trackingController = core.TrackingController(
            self.microcontroller, self.navigationController)

        # open the camera
        # camera start streaming
        self.camera_1.open()
        self.camera_1.set_software_triggered_acquisition(
        )  #self.camera.set_continuous_acquisition()
        self.camera_1.set_callback(self.streamHandler_1.on_new_frame)
        self.camera_1.enable_callback()

        self.camera_2.open()
        self.camera_2.set_software_triggered_acquisition(
        )  #self.camera.set_continuous_acquisition()
        self.camera_2.set_callback(self.streamHandler_2.on_new_frame)
        self.camera_2.enable_callback()

        # load widgets
        self.navigationWidget = widgets.NavigationWidget(
            self.navigationController)

        self.cameraSettingWidget_1 = widgets.CameraSettingsWidget(
            self.camera_1, self.liveController_1)
        self.liveControlWidget_1 = widgets.LiveControlWidget(
            self.streamHandler_1, self.liveController_1,
            self.configurationManager_1)
        self.recordingControlWidget_1 = widgets.RecordingWidget(
            self.streamHandler_1, self.imageSaver_1)
        #self.trackingControlWidget = widgets.TrackingControllerWidget(self.streamHandler_1,self.trackingController)

        self.cameraSettingWidget_2 = widgets.CameraSettingsWidget(
            self.camera_2, self.liveController_2)
        self.liveControlWidget_2 = widgets.LiveControlWidget(
            self.streamHandler_2, self.liveController_2,
            self.configurationManager_2)
        #self.recordingControlWidget_2 = widgets.RecordingWidget(self.streamHandler_2,self.imageSaver_2)
        self.multiPointWidget_2 = widgets.MultiPointWidget(
            self.multipointController_2, self.configurationManager_2)

        # layout widgets
        layout = QGridLayout()  #layout = QStackedLayout()
        layout.addWidget(self.cameraSettingWidget_1, 0, 0)
        layout.addWidget(self.liveControlWidget_1, 1, 0)
        layout.addWidget(self.navigationWidget, 2, 0)
        #layout.addWidget(self.autofocusWidget,3,0)
        layout.addWidget(self.recordingControlWidget_1, 4, 0)

        layout.addWidget(self.cameraSettingWidget_2, 5, 0)
        layout.addWidget(self.liveControlWidget_2, 6, 0)
        #layout.addWidget(self.recordingControlWidget_2,7,0)
        layout.addWidget(self.multiPointWidget_2, 8, 0)

        # transfer the layout to the central widget
        self.centralWidget = QWidget()
        self.centralWidget.setLayout(layout)
        self.setCentralWidget(self.centralWidget)

        # load window
        self.imageDisplayWindow_1 = core.ImageDisplayWindow('Tracking')
        self.imageDisplayWindow_1.show()
        self.imageDisplayWindow_2 = core.ImageDisplayWindow('Fluorescence')
        self.imageDisplayWindow_2.show()
        self.imageArrayDisplayWindow = core.ImageArrayDisplayWindow(
            'Multi-channel')
        self.imageArrayDisplayWindow.show()

        # make connections
        self.navigationController.xPos.connect(
            self.navigationWidget.label_Xpos.setNum)
        self.navigationController.yPos.connect(
            self.navigationWidget.label_Ypos.setNum)
        self.navigationController.zPos.connect(
            self.navigationWidget.label_Zpos.setNum)

        self.streamHandler_1.signal_new_frame_received.connect(
            self.liveController_1.on_new_frame)
        self.streamHandler_1.image_to_display.connect(
            self.imageDisplayWindow_1.display_image)
        self.streamHandler_1.packet_image_to_write.connect(
            self.imageSaver_1.enqueue)
        #self.streamHandler_1.packet_image_for_tracking.connect(self.trackingController.on_new_frame)

        self.liveControlWidget_1.signal_newExposureTime.connect(
            self.cameraSettingWidget_1.set_exposure_time)
        self.liveControlWidget_1.signal_newAnalogGain.connect(
            self.cameraSettingWidget_1.set_analog_gain)
        self.liveControlWidget_1.update_camera_settings()

        self.streamHandler_2.signal_new_frame_received.connect(
            self.liveController_2.on_new_frame)
        self.streamHandler_2.image_to_display.connect(
            self.imageDisplayWindow_2.display_image)
        self.streamHandler_2.packet_image_to_write.connect(
            self.imageSaver_2.enqueue)

        self.liveControlWidget_2.signal_newExposureTime.connect(
            self.cameraSettingWidget_2.set_exposure_time)
        self.liveControlWidget_2.signal_newAnalogGain.connect(
            self.cameraSettingWidget_2.set_analog_gain)
        self.liveControlWidget_2.update_camera_settings()

        self.multipointController_2.image_to_display.connect(
            self.imageDisplayWindow_2.display_image)
        self.multipointController_2.image_to_display_multi.connect(
            self.imageArrayDisplayWindow.display_image)
        self.multipointController_2.signal_current_configuration.connect(
            self.liveControlWidget_2.set_microscope_mode)
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # load objects
        self.camera = camera.Camera_Simulation()
        self.microcontroller = microcontroller.Microcontroller_Simulation()

        self.streamHandler = core.StreamHandler()
        self.liveController = core.LiveController(self.camera,
                                                  self.microcontroller)
        self.navigationController = core.NavigationController(
            self.microcontroller)
        self.autofocusController = core.AutoFocusController(
            self.camera, self.navigationController, self.liveController)
        self.multipointController = core.MultiPointController(
            self.camera, self.navigationController, self.liveController,
            self.autofocusController)
        self.trackingController = core.TrackingController(
            self.microcontroller, self.navigationController)
        self.imageSaver = core.ImageSaver()
        self.imageDisplay = core.ImageDisplay()
        '''
		# thread
		self.thread_multiPoint = QThread()
		self.thread_multiPoint.start()
		self.multipointController.moveToThread(self.thread_multiPoint)
		'''

        # open the camera
        # camera start streaming
        self.camera.open()
        self.camera.set_software_triggered_acquisition(
        )  #self.camera.set_continuous_acquisition()
        self.camera.set_callback(self.streamHandler.on_new_frame)
        self.camera.enable_callback()

        # load widgets
        self.cameraSettingWidget = widgets.CameraSettingsWidget(
            self.camera, self.liveController)
        self.liveControlWidget = widgets.LiveControlWidget(
            self.streamHandler, self.liveController)
        self.navigationWidget = widgets.NavigationWidget(
            self.navigationController)
        self.autofocusWidget = widgets.AutoFocusWidget(
            self.autofocusController)
        self.recordingControlWidget = widgets.RecordingWidget(
            self.streamHandler, self.imageSaver)
        self.trackingControlWidget = widgets.TrackingControllerWidget(
            self.streamHandler, self.trackingController)
        self.multiPointWidget = widgets.MultiPointWidget(
            self.multipointController)

        self.recordTabWidget = QTabWidget()
        self.recordTabWidget.addTab(self.recordingControlWidget,
                                    "Simple Recording")
        self.recordTabWidget.addTab(self.trackingControlWidget, "Tracking")
        self.recordTabWidget.addTab(self.multiPointWidget,
                                    "Multipoint Acquisition")

        # layout widgets
        layout = QGridLayout()  #layout = QStackedLayout()
        layout.addWidget(self.cameraSettingWidget, 0, 0)
        layout.addWidget(self.liveControlWidget, 1, 0)
        layout.addWidget(self.navigationWidget, 2, 0)
        layout.addWidget(self.autofocusWidget, 3, 0)
        layout.addWidget(self.recordTabWidget, 4, 0)

        # transfer the layout to the central widget
        self.centralWidget = QWidget()
        self.centralWidget.setLayout(layout)
        self.setCentralWidget(self.centralWidget)

        # load window
        self.imageDisplayWindow = core.ImageDisplayWindow()
        self.imageDisplayWindow.show()

        # make connections
        self.streamHandler.signal_new_frame_received.connect(
            self.liveController.on_new_frame)
        self.streamHandler.image_to_display.connect(self.imageDisplay.enqueue)
        self.streamHandler.packet_image_to_write.connect(
            self.imageSaver.enqueue)
        self.streamHandler.packet_image_for_tracking.connect(
            self.trackingController.on_new_frame)
        self.imageDisplay.image_to_display.connect(
            self.imageDisplayWindow.display_image
        )  # may connect streamHandler directly to imageDisplayWindow
        self.navigationController.xPos.connect(
            self.navigationWidget.label_Xpos.setNum)
        self.navigationController.yPos.connect(
            self.navigationWidget.label_Ypos.setNum)
        self.navigationController.zPos.connect(
            self.navigationWidget.label_Zpos.setNum)
        self.autofocusController.image_to_display.connect(
            self.imageDisplayWindow.display_image)
        self.multipointController.image_to_display.connect(
            self.imageDisplayWindow.display_image)

        self.camera.start_streaming()
Exemple #3
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # load objects
        self.camera = camera.Camera()
        self.microcontroller = microcontroller.Microcontroller_Simulation()

        self.configurationManager = core.ConfigurationManager()
        self.streamHandler = core_volumetric_imaging.StreamHandler(
            crop_width=500, crop_height=500)
        self.liveController = core.LiveController(self.camera,
                                                  self.microcontroller,
                                                  self.configurationManager)
        self.navigationController = core.NavigationController(
            self.microcontroller)
        self.autofocusController = core.AutoFocusController(
            self.camera, self.navigationController, self.liveController)
        self.multipointController = core.MultiPointController(
            self.camera, self.navigationController, self.liveController,
            self.autofocusController, self.configurationManager)
        self.trackingController = core.TrackingController(
            self.microcontroller, self.navigationController)
        self.imageSaver = core.ImageSaver()
        self.imageDisplay = core.ImageDisplay()

        # open the camera
        # camera start streaming
        self.camera.open()
        self.camera.set_software_triggered_acquisition(
        )  #self.camera.set_continuous_acquisition()
        self.camera.set_callback(self.streamHandler.on_new_frame)
        self.camera.enable_callback()

        # load widgets
        self.cameraSettingWidget = widgets.CameraSettingsWidget(
            self.camera, self.liveController)
        self.liveControlWidget = widgets.LiveControlWidget(
            self.streamHandler, self.liveController, self.configurationManager)
        self.navigationWidget = widgets.NavigationWidget(
            self.navigationController)
        self.autofocusWidget = widgets.AutoFocusWidget(
            self.autofocusController)
        self.recordingControlWidget = widgets.RecordingWidget(
            self.streamHandler, self.imageSaver)
        self.trackingControlWidget = widgets.TrackingControllerWidget(
            self.streamHandler, self.trackingController)
        self.multiPointWidget = widgets.MultiPointWidget(
            self.multipointController, self.configurationManager)

        self.recordTabWidget = QTabWidget()
        self.recordTabWidget.addTab(self.recordingControlWidget,
                                    "Simple Recording")
        # self.recordTabWidget.addTab(self.trackingControlWidget, "Tracking")
        # self.recordTabWidget.addTab(self.multiPointWidget, "Multipoint Acquisition")

        # layout widgets
        layout = QGridLayout()  #layout = QStackedLayout()
        layout.addWidget(self.cameraSettingWidget, 0, 0)
        layout.addWidget(self.liveControlWidget, 1, 0)
        # layout.addWidget(self.navigationWidget,2,0)
        # layout.addWidget(self.autofocusWidget,3,0)
        layout.addWidget(self.recordTabWidget, 4, 0)

        # transfer the layout to the central widget
        self.centralWidget = QWidget()
        self.centralWidget.setLayout(layout)
        self.setCentralWidget(self.centralWidget)

        # load window
        self.imageDisplayWindow = core.ImageDisplayWindow()
        self.imageArrayDisplayWindow = core_volumetric_imaging.ImageArrayDisplayWindow(
        )
        self.imageDisplayWindow.show()
        self.imageArrayDisplayWindow.show()

        # make connections
        self.streamHandler.signal_new_frame_received.connect(
            self.liveController.on_new_frame)
        self.streamHandler.image_to_display.connect(self.imageDisplay.enqueue)
        self.streamHandler.packet_image_to_write.connect(
            self.imageSaver.enqueue)
        self.streamHandler.packet_image_for_tracking.connect(
            self.trackingController.on_new_frame)
        self.streamHandler.packet_image_for_array_display.connect(
            self.imageArrayDisplayWindow.display_image)
        self.imageDisplay.image_to_display.connect(
            self.imageDisplayWindow.display_image
        )  # may connect streamHandler directly to imageDisplayWindow
        self.navigationController.xPos.connect(
            self.navigationWidget.label_Xpos.setNum)
        self.navigationController.yPos.connect(
            self.navigationWidget.label_Ypos.setNum)
        self.navigationController.zPos.connect(
            self.navigationWidget.label_Zpos.setNum)
        self.autofocusController.image_to_display.connect(
            self.imageDisplayWindow.display_image)
        # self.multipointController.image_to_display.connect(self.imageDisplayWindow.display_image)
        self.multipointController.signal_current_configuration.connect(
            self.liveControlWidget.set_microscope_mode)
        self.multipointController.image_to_display_multi.connect(
            self.imageArrayDisplayWindow.display_image)
        self.liveControlWidget.signal_newExposureTime.connect(
            self.cameraSettingWidget.set_exposure_time)
        self.liveControlWidget.signal_newAnalogGain.connect(
            self.cameraSettingWidget.set_analog_gain)
        self.liveControlWidget.update_camera_settings()
Exemple #4
0
    def __init__(self, is_simulation=False, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # load window
        if ENABLE_TRACKING:
            self.imageDisplayWindow = core.ImageDisplayWindow(
                draw_crosshairs=True)
            self.imageDisplayWindow.show_ROI_selector()
        else:
            self.imageDisplayWindow = core.ImageDisplayWindow(
                draw_crosshairs=True)
        self.imageArrayDisplayWindow = core.ImageArrayDisplayWindow()
        # self.imageDisplayWindow.show()
        # self.imageArrayDisplayWindow.show()

        # image display windows
        self.imageDisplayTabs = QTabWidget()
        self.imageDisplayTabs.addTab(self.imageDisplayWindow.widget,
                                     "Live View")
        self.imageDisplayTabs.addTab(self.imageArrayDisplayWindow.widget,
                                     "Multichannel Acquisition")

        # load objects
        if is_simulation:
            self.camera = camera.Camera_Simulation(
                rotate_image_angle=ROTATE_IMAGE_ANGLE, flip_image=FLIP_IMAGE)
            self.microcontroller = microcontroller.Microcontroller_Simulation()
        else:
            self.camera = camera.Camera(rotate_image_angle=ROTATE_IMAGE_ANGLE,
                                        flip_image=FLIP_IMAGE)
            self.microcontroller = microcontroller.Microcontroller()

        # configure the actuators
        self.microcontroller.configure_actuators()

        self.configurationManager = core.ConfigurationManager()
        self.streamHandler = core.StreamHandler(
            display_resolution_scaling=DEFAULT_DISPLAY_CROP / 100)
        self.liveController = core.LiveController(self.camera,
                                                  self.microcontroller,
                                                  self.configurationManager)
        self.navigationController = core.NavigationController(
            self.microcontroller)
        self.autofocusController = core.AutoFocusController(
            self.camera, self.navigationController, self.liveController)
        self.multipointController = core.MultiPointController(
            self.camera, self.navigationController, self.liveController,
            self.autofocusController, self.configurationManager)
        if ENABLE_TRACKING:
            self.trackingController = core.TrackingController(
                self.camera, self.microcontroller, self.navigationController,
                self.configurationManager, self.liveController,
                self.autofocusController, self.imageDisplayWindow)
        self.imageSaver = core.ImageSaver(
            image_format=Acquisition.IMAGE_FORMAT)
        self.imageDisplay = core.ImageDisplay()

        # open the camera
        # camera start streaming
        self.camera.open()
        # self.camera.set_reverse_x(CAMERA_REVERSE_X) # these are not implemented for the cameras in use
        # self.camera.set_reverse_y(CAMERA_REVERSE_Y) # these are not implemented for the cameras in use
        self.camera.set_software_triggered_acquisition(
        )  #self.camera.set_continuous_acquisition()
        self.camera.set_callback(self.streamHandler.on_new_frame)
        self.camera.enable_callback()

        # load widgets
        self.cameraSettingWidget = widgets.CameraSettingsWidget(
            self.camera, include_gain_exposure_time=False)
        self.liveControlWidget = widgets.LiveControlWidget(
            self.streamHandler, self.liveController, self.configurationManager)
        self.navigationWidget = widgets.NavigationWidget(
            self.navigationController)
        self.dacControlWidget = widgets.DACControWidget(self.microcontroller)
        self.autofocusWidget = widgets.AutoFocusWidget(
            self.autofocusController)
        self.recordingControlWidget = widgets.RecordingWidget(
            self.streamHandler, self.imageSaver)
        if ENABLE_TRACKING:
            self.trackingControlWidget = widgets.TrackingControllerWidget(
                self.trackingController,
                self.configurationManager,
                show_configurations=TRACKING_SHOW_MICROSCOPE_CONFIGURATIONS)
        self.multiPointWidget = widgets.MultiPointWidget(
            self.multipointController, self.configurationManager)

        self.recordTabWidget = QTabWidget()
        if ENABLE_TRACKING:
            self.recordTabWidget.addTab(self.trackingControlWidget, "Tracking")
        self.recordTabWidget.addTab(self.recordingControlWidget,
                                    "Simple Recording")
        self.recordTabWidget.addTab(self.multiPointWidget,
                                    "Multipoint Acquisition")

        # layout widgets
        layout = QVBoxLayout()  #layout = QStackedLayout()
        layout.addWidget(self.cameraSettingWidget)
        layout.addWidget(self.liveControlWidget)
        layout.addWidget(self.navigationWidget)
        if SHOW_DAC_CONTROL:
            layout.addWidget(self.dacControlWidget)
        layout.addWidget(self.autofocusWidget)
        layout.addWidget(self.recordTabWidget)
        layout.addStretch()

        # transfer the layout to the central widget
        self.centralWidget = QWidget()
        self.centralWidget.setLayout(layout)
        # self.centralWidget.setFixedSize(self.centralWidget.minimumSize())
        # self.centralWidget.setFixedWidth(self.centralWidget.minimumWidth())
        # self.centralWidget.setMaximumWidth(self.centralWidget.minimumWidth())
        self.centralWidget.setFixedWidth(
            self.centralWidget.minimumSizeHint().width())

        if SINGLE_WINDOW:
            dock_display = dock.Dock('Image Display', autoOrientation=False)
            dock_display.showTitleBar()
            dock_display.addWidget(self.imageDisplayTabs)
            dock_display.setStretch(x=100, y=None)
            dock_controlPanel = dock.Dock('Controls', autoOrientation=False)
            # dock_controlPanel.showTitleBar()
            dock_controlPanel.addWidget(self.centralWidget)
            dock_controlPanel.setStretch(x=1, y=None)
            dock_controlPanel.setFixedWidth(
                dock_controlPanel.minimumSizeHint().width())
            main_dockArea = dock.DockArea()
            main_dockArea.addDock(dock_display)
            main_dockArea.addDock(dock_controlPanel, 'right')
            self.setCentralWidget(main_dockArea)
            desktopWidget = QDesktopWidget()
            height_min = 0.9 * desktopWidget.height()
            width_min = 0.96 * desktopWidget.width()
            self.setMinimumSize(width_min, height_min)
        else:
            self.setCentralWidget(self.centralWidget)
            self.tabbedImageDisplayWindow = QMainWindow()
            self.tabbedImageDisplayWindow.setCentralWidget(
                self.imageDisplayTabs)
            self.tabbedImageDisplayWindow.setWindowFlags(
                self.windowFlags() | Qt.CustomizeWindowHint)
            self.tabbedImageDisplayWindow.setWindowFlags(
                self.windowFlags() & ~Qt.WindowCloseButtonHint)
            desktopWidget = QDesktopWidget()
            width = 0.96 * desktopWidget.height()
            height = width
            self.tabbedImageDisplayWindow.setFixedSize(width, height)
            self.tabbedImageDisplayWindow.show()

        # make connections
        self.streamHandler.signal_new_frame_received.connect(
            self.liveController.on_new_frame)
        self.streamHandler.image_to_display.connect(self.imageDisplay.enqueue)
        self.streamHandler.packet_image_to_write.connect(
            self.imageSaver.enqueue)
        # self.streamHandler.packet_image_for_tracking.connect(self.trackingController.on_new_frame)
        self.imageDisplay.image_to_display.connect(
            self.imageDisplayWindow.display_image
        )  # may connect streamHandler directly to imageDisplayWindow
        self.navigationController.xPos.connect(
            self.navigationWidget.label_Xpos.setNum)
        self.navigationController.yPos.connect(
            self.navigationWidget.label_Ypos.setNum)
        self.navigationController.zPos.connect(
            self.navigationWidget.label_Zpos.setNum)
        if ENABLE_TRACKING:
            self.navigationController.signal_joystick_button_pressed.connect(
                self.trackingControlWidget.slot_joystick_button_pressed)
        else:
            self.navigationController.signal_joystick_button_pressed.connect(
                self.autofocusController.autofocus)
        self.autofocusController.image_to_display.connect(
            self.imageDisplayWindow.display_image)
        self.multipointController.image_to_display.connect(
            self.imageDisplayWindow.display_image)
        self.multipointController.signal_current_configuration.connect(
            self.liveControlWidget.set_microscope_mode)
        self.multipointController.image_to_display_multi.connect(
            self.imageArrayDisplayWindow.display_image)
        self.liveControlWidget.signal_newExposureTime.connect(
            self.cameraSettingWidget.set_exposure_time)
        self.liveControlWidget.signal_newAnalogGain.connect(
            self.cameraSettingWidget.set_analog_gain)
        self.liveControlWidget.update_camera_settings()