Ejemplo n.º 1
0
    def imageStackOpened(self):

        # Add in a new tab
        self.parent.imageTabDisplay.newTab(self.image_class)

        # Do background correction if required
        if self.backgroundCorrectionCheckBox.isChecked():

            # Open the progress window
            openWindow(self.parent, ImageCorrectionProgressBarWindow,
                       'progress_bar')

            # Get the settings in memory
            do_median = self.parent.config.background_type == 'Median'
            do_division = self.parent.config.correction_type == 'Division'
            do_intensity_correction = self.parent.config.correct_intensity
            replace_tab = not self.parent.config.correct_newtab

            # Apply the background correction
            corrected_array = backgroundCorrection(
                self.image_class.image.source,
                median=do_median,
                divide=do_division)

            # Apply the intensity fluctuation correction - if required
            if do_intensity_correction:
                _intensity_correction_type = self.parent.config.intensity_correction_type.lower(
                )
                corrected_array = intensityCorrection(
                    corrected_array, correction=_intensity_correction_type)

            # Load the array in a file
            new_class = ImageCollection(corrected_array,
                                        name=self.image_class.name.strip() +
                                        ' (Corrected)',
                                        space_scale=self.parent.space_scale,
                                        space_unit=self.parent.space_unit,
                                        frame_rate=self.parent.frame_rate)

            # Update the current tab
            if replace_tab:
                # Get the current tab
                tab_id = self.parent.imageTabDisplay.currentIndex()

                # Update the tab
                new_class.name = self.image_class.name
                self.parent.imageTabDisplay.replaceTab(tab_id, new_class)

            # Create a new tab
            else:
                self.parent.imageTabDisplay.newTab(new_class)

            # Close the progress window
            self.parent.subWindows['progress_bar'].close()
            self.parent.application.processEvents()

        # Close the current window
        self.close()
Ejemplo n.º 2
0
    def processImage(self):

        # Retrieve the user selection
        do_division = self.correctionTypeComboBox.currentText() == 'Division'
        do_median = self.backgroundTypeComboBox.currentText() == 'Median'
        do_intensity_correction = self.correctFluctuationsCheckBox.isChecked()
        do_crop = self.cropCheckBox.isChecked()
        crop_size = int(self.cropSizeEntry.text())
        do_bit_correction = self.signCorrectionCheckBox.isChecked()
        replace_tab = self.replaceTabCheckBox.isChecked()

        # Crop the image - if required
        if do_crop:
            self.image_array = cropImage(self.image_array, (crop_size,crop_size))

        # Correct signed bits image - if required
        if do_bit_correction:
            self.image_array = correctSignedBits(self.image_array)

        # Open the progress window
        openWindow(self.parent, ImageCorrectionProgressBarWindow, 'progress_bar')

        # Apply the background correction
        self.image_array = backgroundCorrection(self.image_array, median=do_median, divide=do_division)

        # Apply the intensity fluctuation correction - if required
        if do_intensity_correction:
            self.image_array = intensityCorrection(self.image_array)

        # Get the current tab
        tab_id = self.parent.imageTabDisplay.currentIndex()
        old_class = self.parent.imageTabDisplay.displayedTabs[tab_id].image_class

        # Load the array in a file
        new_class = ImageCollection(self.image_array, name=old_class.name.strip()+' (Corrected)', space_scale=old_class.scale.space_scale, space_unit=old_class.scale.space_unit, frame_rate=old_class.scale.frame_rate)

        # Update the current tab
        if replace_tab:
            new_class.name = old_class.name
            self.parent.imageTabDisplay.replaceTab(tab_id, new_class)

        # Create a new tab
        else:
            self.parent.imageTabDisplay.newTab(new_class)

        # Close the progress window
        self.parent.subWindows['progress_bar'].close()
        self.parent.application.processEvents()

        # Close the window
        self.close()