public static IsomerTrack ToTrack(IEnumerable<IonTransition> edges, CrossSectionSearchParameters parameters, int totalNumberOfVoltageGroups, FitLine fitline)
        {
            IsomerTrack track = new IsomerTrack(parameters.DriftTubeLengthInCm, totalNumberOfVoltageGroups, fitline, parameters.UseAverageTemperature);
            foreach (IonTransition edge in edges)
            {
                track.AddIonTransition(edge);
                ObservedPeak target = edge.Target;
                if (target.ObservationType != ObservationType.Virtual)
                {
                    track.AddObservation(target);
                }
            }

            return track;
        }
 /// <summary>
 /// The compute linear fit FitLine.
 /// </summary>
 private void ComputeLinearFitLine(FitLine fitline)
 {
     fitline.ResetPoints(this.ToContinuousXyPoints());
     fitline.PerformRegression();
     fitline.DiagnoseRegression();
     this.fitLine= fitline;
     this.fitLineNotComputed = false;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="IsomerTrack"/> class.
 /// </summary>
 /// <param name="driftTubeLengthInMeters">
 /// The drift Tube Length In Meters.
 /// </param>
 /// <param name="target">
 /// The inferedTarget.
 /// </param>
 public IsomerTrack(double driftTubeLengthInMeters, int numberOfVoltageGroups, FitLine fitline, bool useAverageTemperature)
 {
     this.driftTubeLengthInMeters = driftTubeLengthInMeters;
     this.fitLineNotComputed = true;
     this.observedPeaks = new HashSet<ObservedPeak>();
     this.definedVoltageGroups = new HashSet<VoltageGroup>();
     this.mobilityInfo.CollisionCrossSectionArea = 0;
     this.mobilityInfo.Mobility = 0;
     this.mobilityInfo.RSquared = 0;
     this.ionSignatureMatchingProbability = 0;
     this.numberOfVoltageGroups = numberOfVoltageGroups;
     this.fitLine = fitline;
     this.useMeanTemperature = useAverageTemperature;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="IsomerTrack"/> class.
 /// </summary>
 /// <param name="peaks">
 /// The peaks.
 /// </param>
 /// <param name="driftTubeLengthInMeters">
 /// The drift tube length in meters.
 /// </param>
 public IsomerTrack(IEnumerable<ObservedPeak> peaks, double driftTubeLengthInMeters, int numberOfVoltageGroups, FitLine fitline, bool useAverageTemperature)
     : this(driftTubeLengthInMeters, numberOfVoltageGroups, fitline, useAverageTemperature)
 {
     foreach (var peak in peaks)
     {
         this.AddObservation(peak);
     }
 }
 public void PlotMobilityFit(FitLine fitline, string plotLocation, int width, int height)
 {
     this.PlotDiagram(plotLocation, this.MobilityFitLinePlot(fitline), width, height);
 }
        /// <summary>
        /// The mobility fit FitLine plot.
        /// </summary>
        /// <param name="fitline">
        /// The fitline.
        /// </param>
        /// <returns>
        /// The <see cref="PlotModel"/>.
        /// </returns>
        private PlotModel MobilityFitLinePlot(FitLine fitline)
        {
            IEnumerable<ContinuousXYPoint> fitPointList = fitline.FitPointCollection.Select(x => x.Point);
            IEnumerable<ContinuousXYPoint> outlierList = fitline.OutlierCollection.Select(x => x.Point);
            Func<object, ScatterPoint> fitPointMap = obj =>
            {
                ContinuousXYPoint point = (ContinuousXYPoint)obj;
                double size = 5;
                double color = 0;
                ScatterPoint sp = new ScatterPoint(point.X, point.Y, size, color);
                return sp;
            };

            Func<object, ScatterPoint> OutlierPointMap = obj =>
            {
                ContinuousXYPoint point = (ContinuousXYPoint)obj;
                double size = 5;
                double color = 1;
                ScatterPoint sp = new ScatterPoint(point.X, point.Y, size, color);
                return sp;
            };

            PlotModel model = new PlotModel();
            model.TitlePadding = 0;
            model.Title = "Mobility Fit FitLine";

            ScatterSeries fitPointSeries = new ScatterSeries
            {
                Mapping = fitPointMap,
                ItemsSource = fitPointList,
            };

            ScatterSeries outlierSeries = new ScatterSeries
            {
                Mapping = OutlierPointMap,
                ItemsSource = outlierList,
            };

            Func<object, DataPoint> lineMap = obj =>
            {
                ContinuousXYPoint point = (ContinuousXYPoint)obj;
                double x = point.X;
                double y = fitline.ModelPredictX2Y(x);
                DataPoint sp = new DataPoint(x, y);
                return sp;
            };

            LineSeries fitlineSeries = new LineSeries()
            {
                Mapping = lineMap,
                ItemsSource = fitPointList,
                Color = OxyColors.Purple
            };

            var yAxis = new LinearAxis()
            {
                Title = "IMS scan time (milliseconds)",
                MajorGridlineStyle = LineStyle.Solid,
                Position = AxisPosition.Left,

                //MajorStep = 100.0,
                //MinorStep = 50.0,
                //Minimum = 0,
                //Maximum = 360,
                //FilterMinValue = 0,
                //FilterMaxValue = 360,
            };

            var xAxis = new LinearAxis()
            {
                Title = "Pressure / (Temperature * Voltage) (1 / V))",
                Position = AxisPosition.Bottom,
                MajorGridlineStyle = LineStyle.Solid,
                //MajorStep = 100.0,
                //MinorStep = 50.0,
                //Minimum = 1000,
                //Maximum = 2000,
                //MinimumRange = 100.0,
                //FilterMinValue = 1000,
                //FilterMaxValue = 2000,
            };

            model.Axes.Add(yAxis);
            model.Axes.Add(xAxis);
            model.Series.Add(fitPointSeries);
            model.Series.Add(outlierSeries);
            model.Series.Add(fitlineSeries);
            return model;
        }