Exemplo n.º 1
0
    def compressItem(self, item):
        def has_tiff(path):
            for f in os.listdir(path):
                if f.endswith(".tif"):
                    return True
            return False

        # figure out what type of folder this is
        if not has_tiff(item):
            self.statusBar.showMessage(
                "No tiffs to compress in " + shortname(item), 4000)
            return

        worker, thread = newWorkerThread(
            workers.CompressionWorker,
            item,
            "compress",
            self.compressTypeCombo.currentText(),
            workerConnect={
                "status_update":
                self.statusBar.showMessage,
                "finished":
                lambda: self.statusBar.showMessage("Compression finished", 4000
                                                   ),
            },
            start=True,
        )
        self.compressionThreads.append((worker, thread))
Exemplo n.º 2
0
    def startCUDAWorkers(self):
        # initialize the workers and threads

        for gpu in self.GPU_SET:
            # create new CUDAworker for every thread
            # each CUDAworker will control one cudaDeconv process (which only gets
            # one wavelength at a time)

            # grab the next arguments from the queue
            # THIS BREAKS the relationship between num_cuda_threads
            # and self.__CUDAworkers_done...
            # if len(self.__argQueue)== 0:
            #   return
            if not len(self.__argQueue):
                return
            args = self.__argQueue.pop(0)

            CUDAworker, thread = newWorkerThread(
                CudaDeconvWorker,
                args,
                {"CUDA_VISIBLE_DEVICES": gpu},
                wid=gpu,
                workerConnect={
                    # get progress messages from CUDAworker and pass to parent
                    "file_finished": self.on_file_finished,
                    "finished": self.on_CUDAworker_done,
                    # any messages go straight to the log window
                    # 'error': self.errorstring  # implement error signal?
                },
            )

            # need to store worker too otherwise will be garbage collected
            self.__CUDAthreads[gpu] = (thread, CUDAworker)

            # connect mainGUI abort CUDAworker signal to the new CUDAworker
            self.sig_abort.connect(CUDAworker.abort)

            # start the thread
            thread.start()
Exemplo n.º 3
0
    def decompressSelected(self):
        for item in self.listbox.selectedPaths():
            if not util.find_filepattern(item, "*.tar*"):
                self.statusBar.showMessage(
                    "No .tar file found in " + shortname(item), 4000)
                continue

            def onfinish():
                self.listbox.llsObjects[item]._register_tiffs()
                self.statusBar.showMessage("Decompression finished", 4000)

            worker, thread = newWorkerThread(
                workers.CompressionWorker,
                item,
                "decompress",
                self.compressTypeCombo.currentText(),
                workerConnect={
                    "status_update": self.statusBar.showMessage,
                    "finished": onfinish,
                },
                start=True,
            )
            self.compressionThreads.append((worker, thread))
Exemplo n.º 4
0
    def previewRegistration(self):
        RD = llsdir.RegDir(self.RegCalibPathLineEdit.text())
        if not RD.isValid:
            raise err.RegistrationError(
                "Registration Calibration dir not valid. Please check Fiducial Data path above."
            )

        if not self.RegFilePath.text():
            QtWidgets.QMessageBox.warning(
                self,
                "Must load registration file!",
                "No registration file!\n\nPlease click load, "
                "and load a registration file.  Or use the "
                "generate button to generate and load a new one.",
                QtWidgets.QMessageBox.Ok,
                QtWidgets.QMessageBox.NoButton,
            )
            return

        @QtCore.Slot(np.ndarray, float, float, dict)
        def displayRegPreview(array, dx=None, dz=None, params=None):
            win = ImgDialog(
                array,
                info=params,
                title="Registration Mode: {} -- RefWave: {}".format(
                    opts["regMode"], opts["regRefWave"]
                ),
            )
            win.overlayButton.click()
            win.maxProjButton.click()
            self.spimwins.append(win)

        self.previewButton.setDisabled(True)
        self.previewButton.setText("Working...")

        try:
            opts = self.getValidatedOptions()
        except Exception:
            self.previewButton.setEnabled(True)
            self.previewButton.setText("Preview")
            raise

        opts["regMode"] = self.RegCalib_channelRefModeCombo.currentText()
        if opts["regMode"].lower() == "none":
            opts["doReg"] = False
        else:
            opts["doReg"] = True
        opts["regRefWave"] = int(self.RegCalib_channelRefCombo.currentText())
        opts["regCalibPath"] = self.RegFilePath.text()
        opts["correctFlash"] = False
        opts["medianFilter"] = False
        opts["trimZ"] = (0, 0)
        opts["trimY"] = (0, 0)
        opts["trimX"] = (0, 0)
        opts["nIters"] = 0

        w, thread = newWorkerThread(
            workers.TimePointWorker,
            RD,
            [0],
            None,
            opts,
            workerConnect={"previewReady": displayRegPreview},
            start=True,
        )

        w.finished.connect(lambda: self.previewButton.setEnabled(True))
        w.finished.connect(lambda: self.previewButton.setText("Preview"))
        self.previewthreads = (w, thread)
Exemplo n.º 5
0
    def processFolder(self):

        folder = self.camCalibFolderLineEdit.text()

        darkavg = None
        if os.path.isfile(self.darkAVGLineEdit.text()):
            darkavg = tf.imread(self.darkAVGLineEdit.text())
        elif os.path.isfile(os.path.join(folder, "dark_AVG.tif")):
            darkavg = tf.imread(os.path.join(folder, "dark_AVG.tif"))
        darkstd = None
        if os.path.isfile(self.darkSTDLineEdit.text()):
            darkstd = tf.imread(self.darkSTDLineEdit.text())
        elif os.path.isfile(os.path.join(folder, "dark_STD.tif")):
            darkstd = tf.imread(os.path.join(folder, "dark_STD.tif"))

        if not all([isinstance(a, np.ndarray) for a in (darkavg, darkstd)]):
            if not pathHasPattern(folder, "*dark*.tif*"):
                QtW.QMessageBox.warning(
                    self,
                    "No dark images!",
                    "Camera calibration requires dark images, but none were provided"
                    " and none were detected in the specified folder."
                    " Read documentation on camera calibration for more info.",
                    QtW.QMessageBox.Ok,
                    QtW.QMessageBox.NoButton,
                )
                return

        if sum([isinstance(a, np.ndarray) for a in (darkavg, darkstd)]) == 1:
            if not pathHasPattern(folder, "*dark*.tif*"):
                QtW.QMessageBox.warning(
                    self,
                    "No dark images!",
                    "Camera calibration requires both a dark image average projection, "
                    " and a standard deviation projection, but only one of the"
                    " two was provided, and no *dark*.tif images "
                    " were detected in the specified folder."
                    " Read documentation on camera calibration for more info.",
                    QtW.QMessageBox.Ok,
                    QtW.QMessageBox.NoButton,
                )
                return
            else:
                reply = QtW.QMessageBox.question(
                    self,
                    "No dark images!",
                    "Camera calibration requires both a dark image average projection, "
                    " and a standard deviation projection, but only one of the"
                    " two was provided. *dark*.tif images "
                    " were detected in the specified folder, and will still be "
                    " used to calculate the projection images.  Continue?",
                    QtW.QMessageBox.Yes | QtW.QMessageBox.No,
                    QtW.QMessageBox.No,
                )
                if reply != QtW.QMessageBox.Yes:
                    return

        self.worker, self.thread = newWorkerThread(
            CamCalibWorker,
            folder,
            darkavg,
            darkstd,
            workerConnect={
                "progress": self.incrementProgress,
                "setProgMax": self.resetWithMax,
                "setStatus": self.statusLabel.setText,
                "finished": self.abortButton.hide,
            },
            start=True,
        )