private void FindFeatures(IEnumerable <Point> pointList) { var featureBlobList = FeatureDetection.DoWatershedAlgorithm(pointList); var featureBlobStatList = featureBlobList.Select(featureBlob => featureBlob.Statistics).ToList(); _featureList = featureBlobStatList.Select(featureBlobStatistics => new Feature(featureBlobStatistics)).ToList(); }
public IDictionary <int, IEnumerable <FeatureBlob> > GetFeatures(IEnumerable <int> targetBinList, double tolerance, UIMFData.FrameType frameType, DataReader.ToleranceType toleranceType) { var resultDictionary = new Dictionary <int, IEnumerable <FeatureBlob> >(); Parallel.ForEach(targetBinList, m_parallelOptions, targetBin => { // Grab a UIMF Util object from the stack m_uimfUtilStack.TryPop(out var uimfUtil); var targetMz = uimfUtil.GetMzFromBin(targetBin); // Do Feature Finding var intensityBlock = uimfUtil.GetXic(targetMz, tolerance, frameType, toleranceType); var pointList = WaterShedMapUtil.BuildWatershedMap(intensityBlock); m_smoother.Smooth(ref pointList); var featureList = FeatureDetection.DoWatershedAlgorithm(pointList); // Add result to dictionary resultDictionary.Add(targetBin, featureList); // Push the UIMF Util object back onto the stack when we are done with it m_uimfUtilStack.Push(uimfUtil); }); return(resultDictionary); }
public void TestDoWaterShedAlgorithmByBin() { var fileLocation = @"\\proto-2\UnitTest_Files\MultidimensionalFeatureFinding\BSA_10ugml_IMS6_TOF03_CID_27Aug12_Frodo_Collision_Energy_Collapsed.UIMF"; var uimfUtil = new UimfUtil(fileLocation); var smoother = new SavitzkyGolaySmoother(5, 2); var bin = 73009; var intensityPointList = uimfUtil.GetXic(bin, UIMFData.FrameType.MS1); var pointList = WaterShedMapUtil.BuildWatershedMap(intensityPointList).ToList(); var preSmoothedFeatureList = FeatureDetection.DoWatershedAlgorithm(pointList).ToList(); Console.WriteLine(DateTime.Now + "\tBefore Smoothing:\tNumPoints = " + pointList.Count + "\tNumFeatures = " + preSmoothedFeatureList.Count); foreach (var featureBlob in preSmoothedFeatureList) { var mostIntensePoint = featureBlob.PointList.First(); Console.WriteLine("Num Points = " + featureBlob.PointList.Count + "\tLC = " + mostIntensePoint.ScanLc + "\tIMS = " + mostIntensePoint.ScanIms + "\tIntensity = " + mostIntensePoint.Intensity); } Console.WriteLine("******************************************************"); var newPointList = WaterShedMapUtil.BuildWatershedMap(intensityPointList); smoother.Smooth(ref newPointList); var smoothedFeatureList = FeatureDetection.DoWatershedAlgorithm(newPointList).ToList(); Console.WriteLine(DateTime.Now + "\tAfter Smoothing:\tNumPoints = " + newPointList.Count() + "\tNumFeatures = " + smoothedFeatureList.Count); foreach (var featureBlob in smoothedFeatureList) { var mostIntensePoint = featureBlob.PointList.First(); Console.WriteLine("Num Points = " + featureBlob.PointList.Count + "\tLC = " + mostIntensePoint.ScanLc + "\tIMS = " + mostIntensePoint.ScanIms + "\tIntensity = " + mostIntensePoint.Intensity); } }
public IDictionary <double, IEnumerable <FeatureBlobStatistics> > GetFeatureStatistics(IEnumerable <double> targetMzList, double tolerance, DataReader.FrameType frameType, DataReader.ToleranceType toleranceType) { var resultDictionary = new Dictionary <double, IEnumerable <FeatureBlobStatistics> >(); Parallel.ForEach(targetMzList, m_parallelOptions, targetMz => { // Grab a UIMF Util object from the stack UimfUtil uimfUtil; m_uimfUtilStack.TryPop(out uimfUtil); // Do Feature Finding var intensityBlock = uimfUtil.GetXic(targetMz, tolerance, frameType, toleranceType); var pointList = WaterShedMapUtil.BuildWatershedMap(intensityBlock); m_smoother.Smooth(ref pointList); var featureList = FeatureDetection.DoWatershedAlgorithm(pointList); // Add result to dictionary resultDictionary.Add(targetMz, featureList.Select(featureBlob => featureBlob.CalculateStatistics()).ToArray()); // Push the UIMF Util object back onto the stack when we are done with it m_uimfUtilStack.Push(uimfUtil); }); return(resultDictionary); }
private void FindFeatures(double[,] intensityBlock) { var pointList = WaterShedMapUtil.BuildWatershedMap(intensityBlock); var featureBlobList = FeatureDetection.DoWatershedAlgorithm(pointList); var featureBlobStatList = featureBlobList.Select(featureBlob => featureBlob.Statistics).ToList(); _featureList = featureBlobStatList.Select(featureBlobStatistics => new Feature(featureBlobStatistics)).ToList(); }
public void TestDoWaterShedAlgorithmAllBins() { var fileLocation = @"\\proto-2\UnitTest_Files\MultidimensionalFeatureFinding\BSA_10ugml_IMS6_TOF03_CID_27Aug12_Frodo_Collision_Energy_Collapsed.UIMF"; var uimfUtil = new UimfUtil(fileLocation); // ReSharper disable once UnusedVariable var numberOfBins = uimfUtil.GetNumberOfBins(); var smoother = new SavitzkyGolaySmoother(5, 2); for (var i = 73009; i <= 84000; i++) { var mz = uimfUtil.GetMzFromBin(i); var intensityPointList = uimfUtil.GetXic(mz, 25, UIMFData.FrameType.MS1, DataReader.ToleranceType.PPM); //List<IntensityPoint> intensityPointList = uimfUtil.GetXic(i, DataReader.FrameType.MS1); //SavitzkyGolaySmoother smoother = new SavitzkyGolaySmoother(9, 2); //smoother.Smooth(ref intensityBlock); //int boundX = intensityBlock.GetUpperBound(0); //int boundY = intensityBlock.GetUpperBound(1); //TextWriter smoothedWriter = new StreamWriter("smoothedRaw.csv"); //for (int j = 0; j < boundX; j++) //{ // StringBuilder row = new StringBuilder(); // for (int k = 0; k < boundY; k++) // { // row.Append(intensityBlock[j, k] + ","); // } // smoothedWriter.WriteLine(row.ToString()); //} //smoothedWriter.Close(); var pointList = WaterShedMapUtil.BuildWatershedMap(intensityPointList); smoother.Smooth(ref pointList); var featureList = FeatureDetection.DoWatershedAlgorithm(pointList); Console.WriteLine(DateTime.Now + "\tBin = " + i + "\tNumPoints = " + pointList.Count() + "\tNumFeatures = " + featureList.Count()); } }
public void TestFakeSaturatedPoints() { var intensityPointList = new List <IntensityPoint>(); for (var i = 0; i < 5; i++) { for (var j = 0; j < 5; j++) { var point = new IntensityPoint(i, j, 8925); intensityPointList.Add(point); } } var pointList = WaterShedMapUtil.BuildWatershedMap(intensityPointList).ToList(); var featureList = FeatureDetection.DoWatershedAlgorithm(pointList).ToList(); Console.WriteLine(DateTime.Now + "\tNumPoints = " + pointList.Count + "\tNumFeatures = " + featureList.Count); foreach (var featureBlob in featureList) { var mostIntensePoint = featureBlob.PointList.First(); Console.WriteLine("Num Points = " + featureBlob.PointList.Count + "\tLC = " + mostIntensePoint.ScanLc + "\tIMS = " + mostIntensePoint.ScanIms + "\tIntensity = " + mostIntensePoint.Intensity); } }
public void TestDoWaterShedAlgorithm() { var fileLocation = @"\\proto-2\UnitTest_Files\MultidimensionalFeatureFinding\BSA_10ugml_IMS6_TOF03_CID_27Aug12_Frodo_Collision_Energy_Collapsed.UIMF"; var uimfUtil = new UimfUtil(fileLocation); var targetMz = 582.32181703760114; double ppmTolerance = 25; var intensityBlock = uimfUtil.GetXicAsArray(targetMz, ppmTolerance, UIMFData.FrameType.MS1, DataReader.ToleranceType.PPM); var smoother = new SavitzkyGolaySmoother(11, 2); smoother.Smooth(ref intensityBlock); var pointList = WaterShedMapUtil.BuildWatershedMap(intensityBlock, 0, 0); var featureList = FeatureDetection.DoWatershedAlgorithm(pointList); foreach (var featureBlob in featureList) { var mostIntensePoint = featureBlob.PointList.First(); Console.WriteLine("Num Points = " + featureBlob.PointList.Count + "\tLC = " + mostIntensePoint.ScanLc + "\tIMS = " + mostIntensePoint.ScanIms + "\tIntensity = " + mostIntensePoint.Intensity); } Console.WriteLine("******************************************************"); var intensityPointList = uimfUtil.GetXic(targetMz, ppmTolerance, UIMFData.FrameType.MS1, DataReader.ToleranceType.PPM); var newPointList = WaterShedMapUtil.BuildWatershedMap(intensityPointList); smoother.Smooth(ref newPointList); var newFeatureList = FeatureDetection.DoWatershedAlgorithm(newPointList); foreach (var featureBlob in newFeatureList) { var mostIntensePoint = featureBlob.PointList.First(); Console.WriteLine("Num Points = " + featureBlob.PointList.Count + "\tLC = " + mostIntensePoint.ScanLc + "\tIMS = " + mostIntensePoint.ScanIms + "\tIntensity = " + mostIntensePoint.Intensity); } }
public void TestComputingApexProfiles() { var fileLocation = @"\\proto-2\UnitTest_Files\MultidimensionalFeatureFinding\BSA_10ugml_IMS6_TOF03_CID_27Aug12_Frodo_Collision_Energy_Collapsed.UIMF"; var uimfUtil = new UimfUtil(fileLocation); var smoother = new SavitzkyGolaySmoother(5, 2); var targetMz = 964.40334; double tolerance = 20; var intensityPointList = uimfUtil.GetXic(targetMz, tolerance, UIMFData.FrameType.MS1, DataReader.ToleranceType.PPM); var pointList = WaterShedMapUtil.BuildWatershedMap(intensityPointList); smoother.Smooth(ref pointList); var featureBlobs = FeatureDetection.DoWatershedAlgorithm(pointList); IEnumerable <FeatureBlobStatistics> featureBlobStatList = featureBlobs.Select(featureBlob => featureBlob.Statistics).ToList(); foreach (var f in featureBlobStatList) { Console.WriteLine( "LC: [{0},{1}], IMS: [{2},{3}], Apex: [{4},{5}] SumIntensities: {6}, NumPoints: {7}", f.ScanLcMin, f.ScanLcMax, f.ScanImsMin, f.ScanImsMax, f.ScanLcRep, f.ScanImsRep, f.SumIntensities, f.NumPoints ); Console.WriteLine("LC Apex profile"); Console.WriteLine(string.Join(",", f.LcApexPeakProfile)); Console.WriteLine("IMS Apex profile"); Console.WriteLine(string.Join(",", f.ImsApexPeakProfile)); } }
private void FindFeatures() { m_FeatureFinderBackgroundWorker.ReportProgress(0, "Finding 3-D Features for Precursor and Fragments"); var seqGraph = SequenceGraph.CreateGraph(m_aminoAcidSet, CurrentPeptide); // var scoringGraph = seqGraph.GetScoringGraph(0); // var precursorIon = scoringGraph.GetPrecursorIon(this.CurrentChargeState); // var monoMz = precursorIon.GetMz(); var sequence = new Sequence(CurrentPeptide, m_aminoAcidSet); var precursorIon = sequence.GetPrecursorIon(CurrentChargeState); var monoMz = precursorIon.GetMonoIsotopicMz(); var uimfPointList = UimfUtil.GetXic(monoMz, CurrentTolerance, UIMFData.FrameType.MS1, DataReader.ToleranceType.PPM); var watershedPointList = WaterShedMapUtil.BuildWatershedMap(uimfPointList); var smoother = new SavitzkyGolaySmoother(11, 2); smoother.Smooth(ref watershedPointList); FeatureList = FeatureDetection.DoWatershedAlgorithm(watershedPointList).ToList(); IsotopeFeaturesDictionary.Clear(); var precursorTargetList = CurrentChargeState == 2 ? new List <string> { "-1", "0.5", "1", "1.5", "2", "3" } : new List <string> { "-1", "1", "2", "3" }; foreach (var precursorTarget in precursorTargetList) { var targetMz = precursorIon.GetIsotopeMz(double.Parse(precursorTarget)); var isotopeUimfPointList = UimfUtil.GetXic(targetMz, CurrentTolerance, UIMFData.FrameType.MS1, DataReader.ToleranceType.PPM); var isotopeWatershedPointList = WaterShedMapUtil.BuildWatershedMap(isotopeUimfPointList); var isotopeFeatures = FeatureDetection.DoWatershedAlgorithm(isotopeWatershedPointList).ToList(); IsotopeFeaturesDictionary.Add(precursorTarget, isotopeFeatures); } LcSlicePlot = new PlotModel(); ImsSlicePlot = new PlotModel(); FragmentFeaturesDictionary.Clear(); // var sequence = new Sequence(this.CurrentPeptide, m_aminoAcidSet); var ionTypeDictionary = sequence.GetProductIons(m_ionTypeFactory.GetAllKnownIonTypes()); double fragmentCount = ionTypeDictionary.Count; var index = 0; foreach (var ionTypeKvp in ionTypeDictionary) { var ionTypeTuple = ionTypeKvp.Key; var ion = ionTypeKvp.Value; var fragmentMz = ion.GetMonoIsotopicMz(); uimfPointList = UimfUtil.GetXic(fragmentMz, CurrentTolerance, UIMFData.FrameType.MS2, DataReader.ToleranceType.PPM); watershedPointList = WaterShedMapUtil.BuildWatershedMap(uimfPointList); smoother.Smooth(ref watershedPointList); var fragmentFeatureBlobList = FeatureDetection.DoWatershedAlgorithm(watershedPointList).ToList(); FragmentFeaturesDictionary.Add(ionTypeTuple, fragmentFeatureBlobList); index++; var progress = (int)((index / fragmentCount) * 100); m_FeatureFinderBackgroundWorker.ReportProgress(progress); } OnPropertyChanged("FeatureList"); OnPropertyChanged("LcSlicePlot"); OnPropertyChanged("ImsSlicePlot"); }
public void TestFragmentCorrelation() { var fileLocation = @"\\proto-2\UnitTest_Files\MultidimensionalFeatureFinding\BSA_10ugml_IMS6_TOF03_CID_27Aug12_Frodo_Collision_Energy_Collapsed.UIMF"; var uimfUtil = new UimfUtil(fileLocation); var parentMz = 643.27094937; double ppmTolerance = 50; var parentIntensityBlock = uimfUtil.GetXicAsArray(parentMz, ppmTolerance, UIMFData.FrameType.MS1, DataReader.ToleranceType.PPM); var smoother = new SavitzkyGolaySmoother(5, 2); smoother.Smooth(ref parentIntensityBlock); // ReSharper disable RedundantArgumentDefaultValue var parentPointList = WaterShedMapUtil.BuildWatershedMap(parentIntensityBlock, 0, 0); // ReSharper restore RedundantArgumentDefaultValue var parentFeature = FeatureDetection.DoWatershedAlgorithm(parentPointList).First(); using (var fragmentReader = new StreamReader(@"\\proto-2\UnitTest_Files\MultidimensionalFeatureFinding\testFiles\fragments.csv")) { while (!fragmentReader.EndOfStream) { var dataLine = fragmentReader.ReadLine(); if (string.IsNullOrWhiteSpace(dataLine)) { continue; } var mzString = dataLine.Trim(); var targetMz = double.Parse(mzString); TextWriter unsmoothedWriter = new StreamWriter("unsmoothedRaw" + targetMz + ".csv"); var intensityBlock = uimfUtil.GetXicAsArray(targetMz, ppmTolerance, UIMFData.FrameType.MS2, DataReader.ToleranceType.PPM); var boundX = intensityBlock.GetUpperBound(0); var boundY = intensityBlock.GetUpperBound(1); for (var i = 0; i < boundX; i++) { var row = new StringBuilder(); for (var j = 0; j < boundY; j++) { row.Append(intensityBlock[i, j] + ","); } unsmoothedWriter.WriteLine(row.ToString()); } unsmoothedWriter.Close(); smoother.Smooth(ref intensityBlock); TextWriter smoothedWriter = new StreamWriter("smoothedRaw" + targetMz + ".csv"); for (var i = 0; i < boundX; i++) { var row = new StringBuilder(); for (var j = 0; j < boundY; j++) { row.Append(intensityBlock[i, j] + ","); } smoothedWriter.WriteLine(row.ToString()); } smoothedWriter.Close(); // ReSharper disable RedundantArgumentDefaultValue var pointList = WaterShedMapUtil.BuildWatershedMap(intensityBlock, 0, 0); // ReSharper restore RedundantArgumentDefaultValue var featureList = FeatureDetection.DoWatershedAlgorithm(pointList); featureList = featureList.Where(x => x.PointList.Count > 50).OrderByDescending(x => x.PointList.Count); Console.WriteLine("******************************************************"); Console.WriteLine("targetMz = " + targetMz); foreach (var featureBlob in featureList) { // ReSharper disable once UnusedVariable var rSquared = FeatureCorrelator.CorrelateFeatures(parentFeature, featureBlob); //Point mostIntensePoint = featureBlob.PointList.OrderByDescending(x => x.Intensity).First(); //Console.WriteLine("Num Points = " + featureBlob.PointList.Count + "\tLC = " + mostIntensePoint.ScanLc + "\tIMS = " + mostIntensePoint.ScanIms + "\tIntensity = " + mostIntensePoint.Intensity + "\tRSquared = " + rSquared); } } } }
public void TestDoWaterShedAlgorithmPrecursorAndFragments() { var fileLocation = @"\\proto-2\UnitTest_Files\MultidimensionalFeatureFinding\BSA_10ugml_IMS6_TOF03_CID_27Aug12_Frodo_Collision_Energy_Collapsed.UIMF"; var uimfUtil = new UimfUtil(fileLocation); var parentMz = 643.27094937; double ppmTolerance = 50; var parentIntensityBlock = uimfUtil.GetXicAsArray(parentMz, ppmTolerance, UIMFData.FrameType.MS1, DataReader.ToleranceType.PPM); var smoother = new SavitzkyGolaySmoother(5, 2); smoother.Smooth(ref parentIntensityBlock); // ReSharper disable RedundantArgumentDefaultValue var parentPointList = WaterShedMapUtil.BuildWatershedMap(parentIntensityBlock, 0, 0); // ReSharper restore RedundantArgumentDefaultValue var parentFeature = FeatureDetection.DoWatershedAlgorithm(parentPointList).First(); var statistics = parentFeature.Statistics; var scanLcMin = statistics.ScanLcMin; var scanLcMax = statistics.ScanLcMax; var scanImsMin = statistics.ScanImsMin; var scanImsMax = statistics.ScanImsMax; using (var fragmentReader = new StreamReader(@"\\proto-2\UnitTest_Files\MultidimensionalFeatureFinding\testFiles\OneFragment.csv")) { while (!fragmentReader.EndOfStream) { var dataLine = fragmentReader.ReadLine(); if (string.IsNullOrWhiteSpace(dataLine)) { continue; } var mzString = dataLine.Trim(); var targetMz = double.Parse(mzString); TextWriter unsmoothedWriter = new StreamWriter("unsmoothedRaw" + targetMz + ".csv"); var intensityBlock = uimfUtil.GetXicAsArray(targetMz, ppmTolerance, UIMFData.FrameType.MS2, scanLcMin, scanLcMax, scanImsMin, scanImsMax, DataReader.ToleranceType.PPM); var boundX = intensityBlock.GetUpperBound(0); var boundY = intensityBlock.GetUpperBound(1); for (var i = 0; i < boundX; i++) { var row = new StringBuilder(); for (var j = 0; j < boundY; j++) { row.Append(intensityBlock[i, j] + ","); } unsmoothedWriter.WriteLine(row.ToString()); } unsmoothedWriter.Close(); smoother.Smooth(ref intensityBlock); TextWriter smoothedWriter = new StreamWriter("smoothedRaw" + targetMz + ".csv"); for (var i = 0; i < boundX; i++) { var row = new StringBuilder(); for (var j = 0; j < boundY; j++) { row.Append(intensityBlock[i, j] + ","); } smoothedWriter.WriteLine(row.ToString()); } smoothedWriter.Close(); var pointList = WaterShedMapUtil.BuildWatershedMap(intensityBlock, scanLcMin, scanImsMin).ToList(); var featureList = FeatureDetection.DoWatershedAlgorithm(pointList).ToList(); Assert.AreEqual(430, pointList.Count); Assert.AreEqual(37, featureList.Count); Console.WriteLine("******************************************************"); Console.WriteLine("targetMz = " + targetMz); for (var i = 0; i < featureList.Count; i++) { var featureBlob = featureList[i]; var mostIntensePoint = featureBlob.PointList.OrderByDescending(x => x.Intensity).First(); Console.WriteLine("Num Points = " + featureBlob.PointList.Count + "\tLC = " + mostIntensePoint.ScanLc + "\tIMS = " + mostIntensePoint.ScanIms + "\tIntensity = " + mostIntensePoint.Intensity); if (i != 1) { continue; } // Num Points = 34 LC = 138 IMS = 122 Intensity = 79.5697959183673 Assert.AreEqual(34, featureBlob.PointList.Count); Assert.AreEqual(138, mostIntensePoint.ScanLc); Assert.AreEqual(122, mostIntensePoint.ScanIms); Assert.AreEqual(79.569796, mostIntensePoint.Intensity, 0.0001); } } } }
public void TestDoWaterShedAlgorithmOutput() { var fileLocation = @"\\proto-2\UnitTest_Files\MultidimensionalFeatureFinding\BSA_10ugml_IMS6_TOF03_CID_27Aug12_Frodo_Collision_Energy_Collapsed.UIMF"; var uimfUtil = new UimfUtil(fileLocation); var targetMz = 643.27094937; double ppmTolerance = 50; TextWriter unsmoothedWriter = new StreamWriter("unsmoothedRaw.csv"); var intensityBlock = uimfUtil.GetXicAsArray(targetMz, ppmTolerance, UIMFData.FrameType.MS1, DataReader.ToleranceType.PPM); var boundX = intensityBlock.GetUpperBound(0); var boundY = intensityBlock.GetUpperBound(1); for (var i = 0; i < boundX; i++) { var row = new StringBuilder(); for (var j = 0; j < boundY; j++) { row.Append(intensityBlock[i, j] + ","); } unsmoothedWriter.WriteLine(row.ToString()); } unsmoothedWriter.Close(); var smoother = new SavitzkyGolaySmoother(5, 2); smoother.Smooth(ref intensityBlock); TextWriter smoothedWriter = new StreamWriter("smoothedRaw.csv"); for (var i = 0; i < boundX; i++) { var row = new StringBuilder(); for (var j = 0; j < boundY; j++) { row.Append(intensityBlock[i, j] + ","); } smoothedWriter.WriteLine(row.ToString()); } smoothedWriter.Close(); var pointList = WaterShedMapUtil.BuildWatershedMap(intensityBlock, 0, 0); var featureList = FeatureDetection.DoWatershedAlgorithm(pointList).ToList(); Console.WriteLine(featureList.Count); var sortedFeatureList = featureList.OrderByDescending(x => x.PointList.Count); TextWriter intensityWriter = new StreamWriter("intensities.csv"); foreach (var featureBlob in sortedFeatureList) { var mostIntensePoint = featureBlob.PointList.First(); Console.WriteLine("Num Points = " + featureBlob.PointList.Count + "\tLC = " + mostIntensePoint.ScanLc + "\tIMS = " + mostIntensePoint.ScanIms + "\tIntensity = " + mostIntensePoint.Intensity); intensityWriter.WriteLine(mostIntensePoint.Intensity.ToString(CultureInfo.InvariantCulture)); } }
public void TestDoWaterShedAlgorithmPrecursorAndFragments() { var fileLocation = @"\\proto-2\UnitTest_Files\MultidimensionalFeatureFinding\BSA_10ugml_IMS6_TOF03_CID_27Aug12_Frodo_Collision_Energy_Collapsed.UIMF"; var uimfUtil = new UimfUtil(fileLocation); var parentMz = 643.27094937; double ppmTolerance = 50; var parentIntensityBlock = uimfUtil.GetXicAsArray(parentMz, ppmTolerance, DataReader.FrameType.MS1, DataReader.ToleranceType.PPM); var smoother = new SavitzkyGolaySmoother(5, 2); smoother.Smooth(ref parentIntensityBlock); var parentPointList = WaterShedMapUtil.BuildWatershedMap(parentIntensityBlock, 0, 0); var parentFeature = FeatureDetection.DoWatershedAlgorithm(parentPointList).First(); var statistics = parentFeature.Statistics; var scanLcMin = statistics.ScanLcMin; var scanLcMax = statistics.ScanLcMax; var scanImsMin = statistics.ScanImsMin; var scanImsMax = statistics.ScanImsMax; using (TextReader fragmentReader = new StreamReader(@"..\..\..\testFiles\OneFragment.csv")) { var line = ""; while ((line = fragmentReader.ReadLine()) != null) { var mzString = line.Trim(); var targetMz = double.Parse(mzString); TextWriter unsmoothedWriter = new StreamWriter("unsmoothedRaw" + targetMz + ".csv"); var intensityBlock = uimfUtil.GetXicAsArray(targetMz, ppmTolerance, DataReader.FrameType.MS2, scanLcMin, scanLcMax, scanImsMin, scanImsMax, DataReader.ToleranceType.PPM); var boundX = intensityBlock.GetUpperBound(0); var boundY = intensityBlock.GetUpperBound(1); for (var i = 0; i < boundX; i++) { var row = new StringBuilder(); for (var j = 0; j < boundY; j++) { row.Append(intensityBlock[i, j] + ","); } unsmoothedWriter.WriteLine(row.ToString()); } unsmoothedWriter.Close(); smoother.Smooth(ref intensityBlock); TextWriter smoothedWriter = new StreamWriter("smoothedRaw" + targetMz + ".csv"); for (var i = 0; i < boundX; i++) { var row = new StringBuilder(); for (var j = 0; j < boundY; j++) { row.Append(intensityBlock[i, j] + ","); } smoothedWriter.WriteLine(row.ToString()); } smoothedWriter.Close(); var pointList = WaterShedMapUtil.BuildWatershedMap(intensityBlock, scanLcMin, scanImsMin); var featureList = FeatureDetection.DoWatershedAlgorithm(pointList); Console.WriteLine("******************************************************"); Console.WriteLine("targetMz = " + targetMz); foreach (var featureBlob in featureList) { var mostIntensePoint = featureBlob.PointList.OrderByDescending(x => x.Intensity).First(); Console.WriteLine("Num Points = " + featureBlob.PointList.Count + "\tLC = " + mostIntensePoint.ScanLc + "\tIMS = " + mostIntensePoint.ScanIms + "\tIntensity = " + mostIntensePoint.Intensity); } } } }