def addProgJob(self, job_desc, generator, args, kwargs, finish_slot=None): job_entry = self.addJob(job_desc) bg_generator = threads.iterator( callback_slot=job_entry.progress, finished_slot=finish_slot, interrupt_signal=job_entry.sigCancel)(generator) bg_generator(*args, **kwargs)
def loadFullReconstruction(self): """ Sets up a full reconstruction for the current dataset based on the current workflow pipeline and configuration parameters. Does not run reconstruction if there is one already running. Called when the corresponding toolbar button is clicked. """ if not self.checkPipeline(): return value = QtGui.QMessageBox.question(None, 'Run Full Reconstruction', 'You are about to run a full reconstruction. ' 'This step can take some minutes. Do you want to continue?', (QtGui.QMessageBox.Yes | QtGui.QMessageBox.Cancel)) if value is QtGui.QMessageBox.Cancel: return currentWidget = self.centerwidget.widget(self.currentWidget()) self.manager.updateParameters() run_state = self.manager.saveState(currentWidget) recon_iter = threads.iterator(callback_slot=self.bottomwidget.log2local, interrupt_signal=self.bottomwidget.local_cancelButton.clicked, finished_slot=self.reconstructionFinished)(self.manager.reconGenerator) # pstart = self.ui.config_params.child('Start Projection').value() # pend = self.ui.config_params.child('End Projection').value() # pstep = self.ui.config_params.child('Step Projection').value() # sstart = self.ui.config_params.child('Start Sinogram').value() # send = self.ui.config_params.child('End Sinogram').value() # sstep = self.ui.config_params.child('Step Sinogram').value() proj = None sino = None chunk = None for f in self.manager.features: if 'Reader' in f.name: proj = f.projections sino = f.sinograms chunk = f.chunk if (not proj and not sino and not chunk) or (not proj[1] and not sino[1] and not chunk): sino = (0, currentWidget.data.shape[2], 1) proj = (0, currentWidget.data.shape[0], 1) chunk = cpu_count()*5 args = (currentWidget, run_state, proj, sino, chunk, cpu_count()) self.manager.recon_queue.put([recon_iter, args]) if self.recon_running: name = self.centerwidget.tabText(self.centerwidget.currentIndex()) msg.showMessage('Queued reconstruction for {}.'.format(name), timeout=0) self.runReconstruction()
def loadFullReconstruction(self): """ Sets up a full reconstruction for the current dataset based on the current workflow pipeline and configuration parameters. Does not run reconstruction if there is one already running. Called when the corresponding toolbar button is clicked. """ if not self.checkPipeline(): return value = QtGui.QMessageBox.question( None, 'Run Full Reconstruction', 'You are about to run a full reconstruction. ' 'This step can take some minutes. Do you want to continue?', (QtGui.QMessageBox.Yes | QtGui.QMessageBox.Cancel)) if value is QtGui.QMessageBox.Cancel: return currentWidget = self.centerwidget.currentWidget() self.manager.updateParameters() func_dict, theta, center, pipeline_dict, run_dict = self.manager.saveState( currentWidget) recon_iter = threads.iterator( callback_slot=self.bottom.log2local, except_slot=self.reconstructionFinished, interrupt_signal=self.bottom.local_cancelButton.clicked, finished_slot=self.reconstructionFinished)( self.manager.reconGenerator) # set up information for reconstruction proj, sino, width, proj_chunk, sino_chunk = self.get_reader_dims() dims = (proj, sino, width, sino_chunk, proj_chunk, cpu_count()) args = (currentWidget, func_dict, theta, center, pipeline_dict, run_dict, dims) self.queue_widget.recon_queue.append([recon_iter, args]) self.queue_widget.addRecon(args) if self.recon_running: name = self.centerwidget.tabText(self.centerwidget.currentIndex()) msg.showMessage('Queued reconstruction for {}.'.format(name), timeout=0) self.runReconstruction()
def runSlicePreview(self, datawidget, func_dict, theta, center, stack_dict, prange=None, dims=None): """ Callback function that receives the necessary widgets/information required to run a preview and add it to the viewer.TomoViewer.previewViewer Parameters ---------- datawidget : viewers.TomoViewer Widget containing dataset func_dict: dict Dictionary of function names and partials with keywords for the reconstruction theta: list List of values representing angular location of camera (for reconstruction) center: float Center of rotation of dataset stack_dict : dict Dictionary describing the workflow pipeline being run. This is displayed to the left of the preview image in the viewer.TomoViewer.previewViewer prange: dict, optional Dictionary containing parameter being tested for TestParamRange, and the function the parameter belongs to dims : tuple, optional Tuple containing dimensions of dataset to be reconstructed """ callback = partial(self.centerwidget.currentWidget().addSlicePreview, stack_dict, slice_no=self.preview_slices, prange=prange) err_message = 'Unable to compute slice preview. Check log for details.' except_slot = lambda: msg.showMessage(err_message) bg_fold = threads.iterator(callback_slot=callback, finished_slot=msg.clearMessage, lock=threads.mutex, except_slot=except_slot) bg_fold(self.manager.reconGenerator)(datawidget, func_dict, theta, center, None, None, dims, None, 'Slice')
def run3DPreview(self, datawidget, func_dict, theta, center, stack_dict, prange=None, dims=None): """ Callback function that receives the partial stack and corresponding dictionary required to run a preview and add it to the viewer.TomoViewer.preview3DViewer Parameters ---------- datawidget : viewers.TomoViewer Widget containing dataset func_dict: dict Dictionary of function names and partials with keywords for the reconstruction theta: list List of values representing angular location of camera (for reconstruction) center: float Center of rotation of dataset stack_dict : dict Dictionary describing the workflow pipeline being run. This is displayed to the left of the preview image in the viewer.TomoViewer.previewViewer dims : tuple, optional Tuple containing dimensions of dataset to be reconstructed """ self.manager.updateParameters() callback = partial( self.centerwidget.widget(self.currentIndex()).add3DPreview, stack_dict) err_message = 'Unable to compute 3D preview. Check log for details.' except_slot = lambda: msg.showMessage(err_message) bg_fold = threads.iterator(callback_slot=callback, finished_slot=msg.clearMessage, lock=threads.mutex, except_slot=except_slot) bg_fold(self.manager.reconGenerator)(datawidget, func_dict, theta, center, None, None, dims, None, '3D')
def runFullReconstruction(self): """ Sets up a full reconstruction to be run in a background thread for the current dataset based on the current workflow pipeline and configuration parameters. Called when the corresponding toolbar button is clicked. Made obsolete by loadFullReconstruction and runReconstruction """ if not self.checkPipeline(): return value = QtGui.QMessageBox.question(None, 'Run Full Reconstruction', 'You are about to run a full reconstruction. ' 'This step can take some minutes. Do you want to continue?', (QtGui.QMessageBox.Yes | QtGui.QMessageBox.Cancel)) if value is QtGui.QMessageBox.Cancel: return name = self.centerwidget.tabText(self.centerwidget.currentIndex()) msg.showMessage('Computing reconstruction for {}...'.format(name),timeout = 0) self.bottomwidget.local_console.clear() self.manager.updateParameters() recon_iter = threads.iterator(callback_slot=self.bottomwidget.log2local, interrupt_signal=self.bottomwidget.local_cancelButton.clicked, finished_slot=self.reconstructionFinished)(self.manager.functionStackGenerator)