def create_mask(self):
        """
        Create untransformed binary mask, sent out the signal to DMD widget for
        further transformation.

        Returns
        -------
        None.

        """
        flag_fill_contour = self.fillContourButton.isChecked()
        flag_invert_mode = self.invertMaskButton.isChecked()
        contour_thickness = self.thicknessSpinBox.value()
        target_laser = self.transform_for_laser_menu.selectedItems()[0].text()
        
        # Get the list of rois from the current ROIitems in "Select" Drawwidget.
        list_of_rois = self.get_list_of_rois()
        
        # Signal to mask requesting widget.
        current_mask_sig = [list_of_rois, flag_fill_contour, contour_thickness, flag_invert_mode, target_laser]
        
        #---- This is the roi list sent to DMD to generate final stack of masks.----
        self.sig_to_calling_widget["mask_{}".format(self.mask_index_spinbox.value())] = current_mask_sig
        
        # Show the untransformed mask
        self.current_mask = ProcessImage.CreateBinaryMaskFromRoiCoordinates(list_of_rois, \
                                                       fill_contour = flag_fill_contour, \
                                                       contour_thickness = contour_thickness, \
                                                       invert_mask = flag_invert_mode)
        self.untransformed_mask_dict["mask_{}".format(self.mask_index_spinbox.value())] = self.current_mask
        
        self.mask_view.setImage(self.current_mask)
Exemple #2
0
    def create_mask(self):
        flag_fill_contour = self.fillContourButton.isChecked()
        flag_invert_mode = self.invertMaskButton.isChecked()
        contour_thickness = self.thicknessSpinBox.value()

        list_of_rois = self.get_list_of_rois()

        self.mask = ProcessImage.CreateBinaryMaskFromRoiCoordinates(list_of_rois, \
                                                       fill_contour = flag_fill_contour, \
                                                       contour_thickness = contour_thickness, \
                                                       invert_mask = flag_invert_mode)

        self.mask_view.setImage(self.mask)
Exemple #3
0
    def receive_mask_coordinates(self, sig):
        ## Receive untransformed mask coordinates, transform them, create mask,
        ## send mask to DMD.

        [list_of_rois, flag_fill_contour, contour_thickness,
         flag_invert_mode] = sig

        list_of_rois = self.transform_coordinates(list_of_rois)

        self.mask = ProcessImage.CreateBinaryMaskFromRoiCoordinates(list_of_rois, \
                                                       fill_contour = flag_fill_contour, \
                                                       contour_thickness = contour_thickness, \
                                                       invert_mask = flag_invert_mode,
                                                       mask_resolution = (768,1024))
        fig, axs = plt.subplots(1, 1)
        axs.imshow(self.mask)
        self.DMD.send_data_to_DMD(self.mask)
Exemple #4
0
    def receive_mask_coordinates(self, sig_from_CoordinateWidget):
        """
        Receive untransformed mask coordinates, transform them, create mask, send mask to DMD.

        PARAMETERS
        ----------
        sig_from_CoordinateWidget : list.  [[signal for first frame], [signal for second frame], ...]
                Signal sent out from CoordinateWidget which contains list of ROIs
                and other parameters for transformation and mask generation.
        """
        for each_mask_key in sig_from_CoordinateWidget:
            print(f"len {len(sig_from_CoordinateWidget)}")
            list_of_rois = sig_from_CoordinateWidget[each_mask_key][0]
            flag_fill_contour = sig_from_CoordinateWidget[each_mask_key][1]
            contour_thickness = sig_from_CoordinateWidget[each_mask_key][2]
            flag_invert_mode = sig_from_CoordinateWidget[each_mask_key][3]
            for_which_laser = sig_from_CoordinateWidget[each_mask_key][4]

            list_of_rois_transformed = self.transform_coordinates(
                list_of_rois, for_which_laser)

            mask_single_frame = ProcessImage.CreateBinaryMaskFromRoiCoordinates(
                list_of_rois_transformed,
                fill_contour=flag_fill_contour,
                contour_thickness=contour_thickness,
                invert_mask=flag_invert_mode,
                mask_resolution=(768, 1024),
            )
            fig, axs = plt.subplots(1, 1)
            axs.imshow(mask_single_frame)
            print("each_mask_key {}".format(each_mask_key))
            # Here the self.mask is always a 3-dimentional np array with the 3rd axis being number of images.
            if each_mask_key == "mask_1":
                self.mask = mask_single_frame[:, :, np.newaxis]
            else:
                self.mask = np.concatenate(
                    (self.mask, mask_single_frame[:, :, np.newaxis]), axis=2)

        self.DMD_actuator.send_data_to_DMD(self.mask)