def display(parent: Optional[QWidget] = None) -> None: """ Synchronously opens the preferences dialog. """ dialog = PreferencesDialog(parent) result = dialog.exec_() if result == QDialog.Accepted: Preferences.save(dialog.value())
def _onDisplayableSampleChange( self, displayableSample: DisplayableSample) -> None: if Preferences.get( ).precacheExpectedImages and self.model.results is not None: self.model.results.precache( cache_kernels2d=Preferences.get().cacheKernels2D, cache_expected_image_for=displayableSample) self._updateDataInWidget(initialDisplayOfData=True)
def initUserFilesIfNeeded() -> None: """ Initializes all directories and files that will be used to store the user's data. """ # Create directories if they don't exist for userFileDir in UserFileDirs.list(): os.makedirs(userFileDir, exist_ok=True) # Init preferences file from frcpredict.ui import Preferences Preferences.initFile()
def _uiKernelResultChange(self, runInstance: RunInstance, kernelResult: Optional[KernelSimulationResult], initialDisplayOfData: bool) -> None: """ Retrieves the expected image for the given kernel simulation result and tells the widget to display it. """ if self.widget.outputDirector() is None: return displayableSample = self.widget.outputDirector().value( ).displayableSample if kernelResult is not None and displayableSample is not None: sampleImageArr = displayableSample.get_image_arr( runInstance.imaging_system_settings.scanning_step_size) expectedImageArr = kernelResult.get_expected_image( runInstance, displayableSample, cache_kernels2d=Preferences.get().cacheKernels2D) else: sampleImageArr = None expectedImageArr = None self.widget.updateExpectedImage( expectedImageArr, autoRange=initialDisplayOfData or self.model.panZoomAutoReset, autoLevel=initialDisplayOfData or self.model.autoLevelAutoPerform, autoLevelLowerCutoff=self.model.autoLevelLowerCutoff) self._sampleImageArr = sampleImageArr self._expectedImageArr = expectedImageArr
def __init__(self, widget) -> None: super().__init__(deepcopy(Preferences.get()), widget) # Prepare UI events widget.precacheFrcCurvesChanged.connect(self._uiPrecacheFrcCurveChange) widget.precacheExpectedImagesChanged.connect( self._uiPrecacheExpectedImagesChanged) widget.cacheKernels2DChanged.connect(self._uiCacheKernels2DChanged)
def run(self) -> None: try: results = self._runInstance.simulate( cache_kernels2d=Preferences.get().cacheKernels2D, precache_frc_curves=Preferences.get().precacheFrcCurves, preprocessing_finished_callback=self.signals. preprocessingFinished, progress_updated_callback=self.signals.progressUpdated) if results is not None: self.signals.done.emit(results) else: self.signals.aborted.emit() except Exception as e: print(format_exc()) self.signals.error.emit(str(e)) finally: self._hasFinished = True
def _uiKernelResultChange(self, runInstance: RunInstance, kernelResult: Optional[KernelSimulationResult], _) -> None: self.model.kernels2D = kernelResult.get_kernels2d(runInstance, cache=Preferences.get().cacheKernels2D)