private async void ButtonPopulationRefine_Click(object sender, RoutedEventArgs e) { if (ActivePopulation == null) { return; } //if (ActivePopulation.Species.Count > 1) //{ // await this.ShowMessageAsync("Oopsie", "Multiple species aren't supported yet. Oh, the irony!"); // return; //} if (ActivePopulation.Species.Count == 0) { await this.ShowMessageAsync("Oopsie", "There are no species in this population. Please create one first."); return; } CustomDialog SettingsDialog = new CustomDialog(); SettingsDialog.HorizontalContentAlignment = HorizontalAlignment.Center; SettingsDialog.DataContext = ActivePopulation.LastRefinementOptions; DialogRefinementSettings SettingsDialogContent = new DialogRefinementSettings(); SettingsDialogContent.DataContext = ActivePopulation.LastRefinementOptions; SettingsDialogContent.Close += async() => await this.HideMetroDialogAsync(SettingsDialog); SettingsDialogContent.StartRefinement += async() => { await this.HideMetroDialogAsync(SettingsDialog); ClearSpeciesDisplay(); // To avoid UI updates from refinement thread ProcessingOptionsMPARefine Options = ActivePopulation.LastRefinementOptions; Options.BFactorWeightingThreshold = 0.25M; Options.DoAstigmatismDelta = Options.DoDefocus; Options.DoAstigmatismAngle = Options.DoDefocus; Dispatcher.Invoke(() => { SettingsDialogContent.DataContext = null; }); PerformRefinementIteration(Options); UpdateSpeciesDisplay(); }; SettingsDialog.Content = SettingsDialogContent; await this.ShowMetroDialogAsync(SettingsDialog); }
private async void ButtonPopulationRefine_Click(object sender, RoutedEventArgs e) { if (ActivePopulation == null) { return; } //if (ActivePopulation.Species.Count > 1) //{ // await this.ShowMessageAsync("Oopsie", "Multiple species aren't supported yet. Oh, the irony!"); // return; //} if (ActivePopulation.Species.Count == 0) { await this.ShowMessageAsync("Oopsie", "There are no species in this population. Please create one first."); return; } CustomDialog SettingsDialog = new CustomDialog(); SettingsDialog.HorizontalContentAlignment = HorizontalAlignment.Center; DialogRefinementSettings SettingsDialogContent = new DialogRefinementSettings(); SettingsDialogContent.Close += async() => await this.HideMetroDialogAsync(SettingsDialog); SettingsDialogContent.StartRefinement += async() => { await this.HideMetroDialogAsync(SettingsDialog); ClearSpeciesDisplay(); // To avoid UI updates from refinement thread ProcessingOptionsMPARefine Options = new ProcessingOptionsMPARefine(); Options.NIterations = (int)SettingsDialogContent.SliderNIterations.Value; Options.MinimumCTFRefinementResolution = (float)SettingsDialogContent.SliderCTFResolution.Value; Options.ImageWarpResolution = new int2((int)SettingsDialogContent.SliderImageWarpWidth.Value, (int)SettingsDialogContent.SliderImageWarpHeight.Value); Options.VolumeWarpResolution = new int4((int)SettingsDialogContent.SliderVolumeWarpWidth.Value, (int)SettingsDialogContent.SliderVolumeWarpHeight.Value, (int)SettingsDialogContent.SliderVolumeWarpDepth.Value, (int)SettingsDialogContent.SliderVolumeWarpDuration.Value); Options.RefineMovies = (bool)SettingsDialogContent.CheckRefineTiltMovies.IsChecked; Options.RefinedComponentsWarp = 0; if ((bool)SettingsDialogContent.CheckImageWarp.IsChecked) { Options.RefinedComponentsWarp |= WarpOptimizationTypes.ImageWarp; } if ((bool)SettingsDialogContent.CheckVolumeWarp.IsChecked) { Options.RefinedComponentsWarp |= WarpOptimizationTypes.VolumeWarp; } if ((bool)SettingsDialogContent.CheckStageAngles.IsChecked) { Options.RefinedComponentsWarp |= WarpOptimizationTypes.AxisAngle; } if ((bool)SettingsDialogContent.CheckParticlePositions.IsChecked) { Options.RefinedComponentsWarp |= WarpOptimizationTypes.ParticlePosition; } if ((bool)SettingsDialogContent.CheckParticleAngles.IsChecked) { Options.RefinedComponentsWarp |= WarpOptimizationTypes.ParticleAngle; } if ((bool)SettingsDialogContent.CheckBeamTilt.IsChecked) { Options.RefinedComponentsWarp |= WarpOptimizationTypes.BeamTilt; } if ((bool)SettingsDialogContent.CheckMagnification.IsChecked) { Options.RefinedComponentsWarp |= WarpOptimizationTypes.Magnification; } Options.RefinedComponentsCTF = 0; if ((bool)SettingsDialogContent.CheckDefocus.IsChecked) { Options.RefinedComponentsCTF |= CTFOptimizationTypes.Defocus; Options.RefinedComponentsCTF |= CTFOptimizationTypes.AstigmatismDelta; Options.RefinedComponentsCTF |= CTFOptimizationTypes.AstigmatismAngle; } if ((bool)SettingsDialogContent.CheckPhaseShift.IsChecked) { Options.RefinedComponentsCTF |= CTFOptimizationTypes.PhaseShift; } if ((bool)SettingsDialogContent.CheckBeamTilt.IsChecked) { Options.RefinedComponentsCTF |= CTFOptimizationTypes.BeamTilt; } if ((bool)SettingsDialogContent.CheckMagnification.IsChecked) { Options.RefinedComponentsCTF |= CTFOptimizationTypes.PixelSize; } PerformRefinementIteration(Options); UpdateSpeciesDisplay(); }; SettingsDialog.Content = SettingsDialogContent; await this.ShowMetroDialogAsync(SettingsDialog); }