public void test2()
        {
            double[] signal = new double[]
            { 1385, 1458, 1546, 1359, 1365, 1434, 1344, 1485, 1415, 1327, 1396, 1363, 1418, 1405, 1414, 1481,
              1324, 1321, 1260, 1441, 1409, 1501, 1440, 1428, 1456, 1546, 1598, 1444, 1389,
              1395, 1425, 1318, 1384, 1489, 1456, 1424, 1491, 1476, 1493, 1470, 1452, 1409, 1463, 1406, 1470, 1506, 1410 };
            List <double> t = new List <double>();

            for (int i = 0; i < signal.Length; i++)
            {
                t.Add(i);
            }

            SortedDictionary <double, List <double> > matrix =
                new SortedDictionary <double, List <double> >();

            for (int a = 1; a <= 5; a += 1)
            {
                double[] processed = CWT.Transform(signal, a);
                matrix[a] = processed.ToList();
            }

            RidgeLineFinder  coeffMatrix = new RidgeLineFinder();
            List <RidgeLine> lines       = coeffMatrix.Find(t, matrix);

            foreach (var item in lines)
            {
                Console.WriteLine(item.Pos);
                Console.WriteLine(item.Length);
                Console.WriteLine(GetString <int>(item.Index));
                Console.WriteLine(GetString <double>(item.Trace) + "\n");
            }
        }
        public void test1()
        {
            int           n = 7;
            List <double> t = new List <double>();

            for (int i = 0; i < n; i++)
            {
                t.Add(i);
            }

            List <double> coeff = new List <double>()
            {
                1.0, 2.0, 5.0, 4.0, 5.0, 6.0, 7.0
            };
            SortedDictionary <double, List <double> > matrix
                = new SortedDictionary <double, List <double> >();

            matrix[1] = coeff;

            RidgeLineFinder processor = new RidgeLineFinder(4);

            processor.Init(t, matrix);
            List <int> pos = processor.LocalMaxamIndexes(1);

            Console.WriteLine(pos.Count);
            foreach (int i in pos)
            {
                Console.WriteLine(i.ToString() + " " + coeff[i].ToString());
            }

            //Assert.AreEqual(5,coeff[pos[pos.Count-1]]);
        }
Beispiel #3
0
        public void test2()
        {
            string path = @"C:\Users\Rui Zhang\Downloads\Serum_1_C18_03292019_Ali.raw";

            ISpectrumReader reader = new ThermoRawSpectrumReader();

            reader.Init(path);
            RidgeLineFinder coeffMatrix = new RidgeLineFinder(1.0, 2, 1, 2);
            IProcess        processer   = new PeakPickingCWT(coeffMatrix);

            //for (int i = reader.GetFirstScan(); i < reader.GetLastScan(); i++)
            int i = 347;
            {
                if (reader.GetMSnOrder(i) < 2)
                {
                    ISpectrum    spectrum = reader.GetSpectrum(i);
                    List <IPeak> peaks    = spectrum.GetPeaks();
                    spectrum = processer.Process(spectrum);

                    IAreaCalculator    calculator     = new TrapezoidalRule();
                    IBounder           bounder        = new PerpendicularDrop();
                    PeakAreaCalculator areaCalculator = new PeakAreaCalculator(calculator, bounder);
                    areaCalculator.Init(peaks);

                    foreach (IPeak peak in spectrum.GetPeaks())
                    {
                        Console.WriteLine(peak.GetMZ() + " : " + areaCalculator.Area(peak).ToString());
                    }
                }
            }
        }
Beispiel #4
0
        public void test1()
        {
            var watch = new System.Diagnostics.Stopwatch();

            watch.Start();

            string path = @"C:\Users\Rui Zhang\Downloads\Serum_1_C18_03292019_Ali.raw";

            ISpectrumReader reader = new ThermoRawSpectrumReader();

            reader.Init(path);

            //for (int i = reader.GetFirstScan(); i < reader.GetLastScan(); i++)
            int             i           = 342;
            RidgeLineFinder coeffMatrix = new RidgeLineFinder(1.0, 2, 1, 2);

            {
                if (reader.GetMSnOrder(i) < 2)
                {
                    ISpectrum    spectrum = reader.GetSpectrum(i);
                    List <IPeak> peaks    = spectrum.GetPeaks();

                    double[] signal = peaks.Select(p => p.GetIntensity()).ToArray();
                    SortedDictionary <double, List <double> > matrix =
                        new SortedDictionary <double, List <double> >();
                    for (double a = 1; a <= 120; a += 6)
                    {
                        double[] processed = CWT.Transform(signal, a);
                        matrix[a] = processed.ToList();
                    }

                    List <RidgeLine> lines = coeffMatrix.Find(spectrum.GetPeaks().Select(p => p.GetMZ()).ToList(),
                                                              matrix);
                    Console.WriteLine(lines.Count);
                    Console.WriteLine(peaks.Count);
                    foreach (RidgeLine line in lines)
                    {
                        Console.WriteLine(line.Pos);
                    }
                }

                //break;
            }

            Console.WriteLine($"Execution Time: {watch.ElapsedMilliseconds} ms");
            //Console.Read();
        }
Beispiel #5
0
        public void test2()
        {
            string path = @"C:\Users\Rui Zhang\Downloads\Serum_1_C18_03292019_Ali.raw";

            ISpectrumReader reader = new ThermoRawSpectrumReader();

            reader.Init(path);
            RidgeLineFinder coeffMatrix = new RidgeLineFinder(1.0, 2, 1, 2);
            IProcess        processer   = new PeakPickingCWT(coeffMatrix);

            //for (int i = reader.GetFirstScan(); i < reader.GetLastScan(); i++)
            int i = 342;
            {
                if (reader.GetMSnOrder(i) < 2)
                {
                    ISpectrum spectrum = reader.GetSpectrum(i);
                    spectrum = processer.Process(spectrum);
                    foreach (var peak in spectrum.GetPeaks())
                    {
                        Console.WriteLine(peak.GetMZ().ToString() + ": " + peak.GetIntensity().ToString());
                    }
                }
            }
        }