Example #1
0
        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");
            }
        }
Example #2
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();
        }