Esempio n. 1
0
        private void AdjustYAxis()
        {
            if (Movie == null)
            {
                return;
            }

            TiltSeries Series = Movie as TiltSeries;

            if ((Movie.GetType() == typeof(Movie) || ShowSeriesAverage) && (Movie.PS1D == null || Movie.Simulated1D == null))
            {
                return;
            }
            if (Series != null && (Series.TiltPS1D.Count <= TiltID || Series.TiltPS1D[TiltID] == null))
            {
                return;
            }

            float2[] ExperimentalData = (Series == null || _ShowSeriesAverage) ? Movie.PS1D : Series.TiltPS1D[TiltID];
            float2[] SimulatedData    = (Series == null || _ShowSeriesAverage) ? Movie.Simulated1D : Series.GetTiltSimulated1D(TiltID);

            int MinN = (int)(ExperimentalData.Length * FittingRangeMin);
            int N    = (int)(ExperimentalData.Length * (FittingRangeMax - FittingRangeMin));

            IEnumerable <float> RelevantExperimental = ExperimentalData.Select(p => p.Y).Skip(MinN).Take(N);
            IEnumerable <float> RelevantSimulated    = SimulatedData.Select(p => p.Y).Skip(MinN).Take(N);

            float MinExperimental = MathHelper.Min(RelevantExperimental);
            float MaxExperimental = MathHelper.Max(RelevantExperimental);
            float MinSimulated    = MathHelper.Min(RelevantSimulated);
            float MaxSimulated    = MathHelper.Max(RelevantSimulated);

            Plot1DAxisY.MinValue = Math.Min(MinExperimental, MinSimulated);
            Plot1DAxisY.MaxValue = Math.Max(MaxExperimental, MaxSimulated) * 1.25f;

            Plot1DAxisY.LabelFormatter        = val => val.ToString("F3", CultureInfo.InvariantCulture);
            Plot1DAxisYQuality.LabelFormatter = val => val.ToString("F3", CultureInfo.InvariantCulture);
            Plot1DAxisX.LabelFormatter        = val => (Movie.OptionsCTF.Window / val * (double)Movie.OptionsCTF.BinnedPixelSizeMean).ToString("F2") + " Å";
        }
Esempio n. 2
0
        private async void Movie_CTF1DChanged(object sender, EventArgs e)
        {
            try
            {
                AdjustGridVisibility();
                if (Movie == null)
                {
                    return;
                }

                TiltSeries Series = Movie as TiltSeries;

                bool NoDataAvailable = false;
                if ((Movie.GetType() == typeof(Movie) || ShowSeriesAverage) && (Movie.PS1D == null || Movie.Simulated1D == null))
                {
                    NoDataAvailable = true;
                }
                else if (Series != null && (Series.TiltPS1D.Count <= TiltID || Series.TiltPS1D[TiltID] == null))
                {
                    NoDataAvailable = true;
                }

                if (NoDataAvailable)
                {
                    Plot1DSeriesExperimental.Values = null;
                    Plot1DSeriesSimulated.Values    = null;
                    Plot1DSeriesQuality.Values      = null;

                    return;
                }

                //ProgressCTF1D.Visibility = Visibility.Visible;
                Movie   movie           = Movie;
                decimal fittingRangeMin = FittingRangeMin;

                //await Task.Delay(1000);
                await Task.Run(() =>
                {
                    float2[] ExperimentalData = (Series == null || _ShowSeriesAverage) ? movie.PS1D : Series.TiltPS1D[TiltID];
                    float2[] SimulatedData    = (Series == null || _ShowSeriesAverage) ? movie.Simulated1D : Series.GetTiltSimulated1D(TiltID);
                    Cubic1D ScaleData         = (Series == null || _ShowSeriesAverage) ? movie.SimulatedScale : Series.TiltSimulatedScale[TiltID];

                    int N = ExperimentalData.Length * 2;

                    ChartValues <ObservablePoint> ExperimentalValues = new ChartValues <ObservablePoint>(ExperimentalData.Select(p => new ObservablePoint(p.X *N, p.Y)));
                    ChartValues <ObservablePoint> SimulatedValues    = new ChartValues <ObservablePoint>(SimulatedData.Select(p => new ObservablePoint(p.X *N, p.Y)));

                    CTF CTF         = (Series == null || _ShowSeriesAverage) ? movie.CTF : Series.GetTiltCTF(TiltID);
                    float[] Quality = CTF.EstimateQuality(ExperimentalData.Select(p => p.Y).ToArray(), ScaleData.Interp(ExperimentalData.Select(p => p.X).ToArray()), (float)fittingRangeMin, 16, true);

                    Dispatcher.Invoke(() =>
                    {
                        Plot1DSeriesExperimental.Values = ExperimentalValues;
                        Plot1DSeriesSimulated.Values    = SimulatedValues;
                        Plot1DSeriesQuality.Values      = new ChartValues <double>(Quality.Select(v => (double)Math.Max(0, v)));
                    });
                });

                AdjustYAxis();
                FittingRangeChanged(null, new DependencyPropertyChangedEventArgs());

                //ProgressCTF1D.Visibility = Visibility.Hidden;
            }
            catch
            {
            }
        }