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 test4() { double[] t = 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 }; //{ // 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,1452,1424,1418,1306,1335,1299,1391,1423,1609,1449,1385,1417,1400,1457,1504,1395,1628,1481,1430,1302,1468,1411,1423,1421,1424,1411,1454,1492,1514,1531,1340,1388,1360,1412,1531,1379,1397,1392,1475,1450,1484,1448,1513,1321,1408,1558,1623,1537,1515,1562,1434,1470,1470,1473 //}; double[] y = CWT.Transform(t, 2.0); foreach (double v in y) { Console.WriteLine(v); } }
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(); }
public void test3() { int n = 20; double[] t = new double[n]; for (int i = 0; i < n; i++) { t[i] = i - (n - 1) / 2.0; } double[] y = CWT.Transform(t, 1.0); foreach (double v in y) { Console.WriteLine(v); } }