Exemplo n.º 1
0
        private void FitScan(Scan s, double gateStart, double gateEnd)
        {
            double scanStart = SpectrumGateLow;
            double scanEnd   = SpectrumGateHigh;

            double[] xDat = s.ScanParameterArray;
            double[] yDat = s.GetTOFOnIntegralArray(0, gateStart, gateEnd);
            spectrumFitter.Fit(
                xDat,
                yDat,
                spectrumFitter.SuggestParameters(xDat, yDat, scanStart, scanEnd)
                );
        }
Exemplo n.º 2
0
        public override TSolution[] Apply(TSolution[] population)
        {
            Selector.BeforeSelection(population);
            var parents = Selector.Select(population);

            var children = new TSolution[parents.Length];

            for (int i = 0; i < children.Length; i++)
            {
                children[i] = new TSolution();
            }
            Crossover.CrossCoordinates(parents, children);

            Mutator.MutateCoordinates(children);
            Evaluator.Evaluate(children);
            Fitter.Fit(children);
            return(children);
        }
Exemplo n.º 3
0
        private void FitAverageTOF()
        {
            Scan averageScan = Controller.GetController().DataStore.AverageScan;
            TOF  tof;

            if (window.GetTofFitDataSelection() == 0)
            {
                tof = (TOF)((ArrayList)averageScan.GetGatedAverageOnShot(
                                startSpectrumGate,
                                endSpectrumGate).TOFs)[0];
            }
            else
            {
                if (((ScanPoint)(averageScan.Points[0])).OffShots.Count == 0)
                {
                    return;                                                           //make sure there are some offshots
                }
                tof = (TOF)((ArrayList)averageScan.GetGatedAverageOffShot(
                                startSpectrumGate,
                                endSpectrumGate).TOFs)[0];
            }
            double[] doubleTimes = new double[tof.Times.Length];
            for (int i = 0; i < tof.Times.Length; i++)
            {
                doubleTimes[i] = (double)tof.Times[i];
            }
            tofFitter.Fit(
                doubleTimes,
                tof.Data,
                tofFitter.SuggestParameters(
                    doubleTimes,
                    tof.Data,
                    tof.Times[0],
                    tof.Times[tof.Times.Length - 1])
                );
            window.ClearTOFFit();
            window.PlotTOFFit(tof.GateStartTime, tof.ClockPeriod, tofFitter.FittedValues);
            // update the parameter report
            window.SetLabel(window.tofFitResultsLabel, tofFitter.ParameterReport);
        }
Exemplo n.º 4
0
        public void Run(string path, Counter counter)
        {
            ISpectrumReader reader = new ThermoRawSpectrumReader();

            reader.Init(path);

            IGUIFinder finder  = new BinarySearchFinder(PPM);
            IProcess   picking = new LocalNeighborPicking();
            Dictionary <int, List <GUI> > pointMaps = new Dictionary <int, List <GUI> >();

            int start = reader.GetFirstScan();
            int end   = reader.GetLastScan();

            Parallel.For(start, end, (i) =>
            {
                if (reader.GetMSnOrder(i) < 2)
                {
                    ISpectrum spectrum = picking.Process(reader.GetSpectrum(i));
                    lock (resultLock)
                    {
                        pointMaps[i] = finder.FindGlucoseUnits(spectrum);
                    }
                }
                counter.Add(end - start);
            });
            List <List <GUI> > points =
                pointMaps.OrderBy(p => p.Key).Select(p => p.Value).ToList();

            IGUISequencer sequencer = new DynamicProgrammingSequencer();
            List <GUI>    guiPoints = sequencer.Choose(points);

            Dictionary <int, GUI> guiSelected = new Dictionary <int, GUI>();

            foreach (GUI gui in guiPoints)
            {
                if (guiSelected.ContainsKey(gui.Unit))
                {
                    if (guiSelected[gui.Unit].Peak.GetIntensity() < gui.Peak.GetIntensity())
                    {
                        guiSelected[gui.Unit] = gui;
                    }
                }
                else
                {
                    guiSelected[gui.Unit] = gui;
                }
            }

            Retention.Clear();
            Guis.Clear();

            List <GUI> looped = guiSelected.Values.OrderBy(g => g.Scan).ToList();
            string     output = Path.Combine(Path.GetDirectoryName(path),
                                             Path.GetFileNameWithoutExtension(path) + ".csv");

            using (FileStream ostrm = new FileStream(output, FileMode.OpenOrCreate, FileAccess.Write))
            {
                using (StreamWriter writer = new StreamWriter(ostrm))
                {
                    writer.WriteLine("scan,time,gui,peak,intensity");
                    foreach (GUI gui in looped)
                    {
                        int    scan = gui.Scan;
                        double time = reader.GetRetentionTime(scan);
                        Retention.Add(time);
                        Guis.Add(gui.Unit);
                        writer.WriteLine(scan.ToString() + "," +
                                         time.ToString() + "," +
                                         gui.Unit.ToString() + "," +
                                         gui.Peak.GetMZ().ToString() + "," +
                                         gui.Peak.GetIntensity().ToString());
                    }
                    writer.Flush();
                }
            }
            Fitter.Fit(Retention, Guis);
        }
Exemplo n.º 5
0
 public override void Initialize(TSolution[] population)
 {
     Initializer.InitializeCoordinates(population);
     Evaluator.Evaluate(population);
     Fitter.Fit(population);
 }