public void TestGetScanLabelData(string rawFileName, int scanStart, int scanEnd)
        {
            var expectedData = new Dictionary<string, Dictionary<int, string>>();

            var noMatch = "  0                                                        ";

            var file1Data = new Dictionary<int, string>
            {
                {1513, noMatch + "+ c ESI Full ms [400.00-2000.00]"},
                {1514, noMatch + "+ c d Full ms2 [email protected] [230.00-1780.00]"}
            };
            expectedData.Add("Shew_246a_LCQa_15Oct04_Andro_0904-2_4-20", file1Data);

            var file2Data = new Dictionary<int, string>
            {
                {16121, "833  712.813   2.9E+5 22100.000 5705.175 159099.000        0  FTMS + p NSI Full ms [350.0000-1550.0000]"},
                {16122, noMatch + "ITMS + c NSI r d Full ms2 [email protected] [106.0000-817.0000]"},
                {16123, noMatch + "ITMS + c NSI r d Full ms2 [email protected] [143.0000-1627.0000]"},
                {16124, noMatch + "ITMS + c NSI r d Full ms2 [email protected] [208.0000-2000.0000]"},
                {16125, noMatch + "ITMS + c NSI r d Full ms2 [email protected] [120.0000-1627.0000]"},
                {16126, noMatch + "ITMS + c NSI r d sa Full ms2 [email protected]@cid20.00 [120.0000-1627.0000]"},
                {16127, noMatch + "ITMS + c NSI r d sa Full ms2 [email protected]@hcd20.00 [120.0000-1627.0000]"},
                {16128, noMatch + "ITMS + c NSI r d Full ms2 [email protected] [225.0000-1682.0000]"},
                {16129, noMatch + "ITMS + c NSI r d Full ms2 [email protected] [266.0000-1986.0000]"},
                {16130, noMatch + "ITMS + c NSI r d Full ms2 [email protected] [110.0000-853.0000]"},
                {16131, noMatch + "ITMS + c NSI r d Full ms2 [email protected] [120.0000-1986.0000]"},
                {16132, noMatch + "ITMS + c NSI r d Full ms2 [email protected] [120.0000-853.0000]"},
                {16133, noMatch + "ITMS + c NSI r d sa Full ms2 [email protected]@cid20.00 [120.0000-853.0000]"},
                {16134, noMatch + "ITMS + c NSI r d sa Full ms2 [email protected]@hcd20.00 [120.0000-853.0000]"},
                {16135, noMatch + "ITMS + c NSI r d sa Full ms2 [email protected]@cid20.00 [120.0000-1986.0000]"},
                {16136, noMatch + "ITMS + c NSI r d sa Full ms2 [email protected]@hcd20.00 [120.0000-1986.0000]"},
                {16137, noMatch + "ITMS + c NSI r d Full ms2 [email protected] [336.0000-2000.0000]"},
                {16138, noMatch + "ITMS + c NSI r d Full ms2 [email protected] [235.0000-1760.0000]"},
                {16139, noMatch + "ITMS + c NSI r d Full ms2 [email protected] [120.0000-1760.0000]"},
                {16140, noMatch + "ITMS + c NSI r d sa Full ms2 [email protected]@cid20.00 [120.0000-1760.0000]"},
                {16141, noMatch + "ITMS + c NSI r d sa Full ms2 [email protected]@hcd20.00 [120.0000-1760.0000]"},
                {16142, "928  740.322   2.1E+5 28700.000 3257.063 93482.960        0  FTMS + p NSI Full ms [350.0000-1550.0000]"}
            };
            expectedData.Add("HCC-38_ETciD_EThcD_4xdil_20uL_3hr_3_08Jan16_Pippin_15-08-53", file2Data);

            var dataFile = GetRawDataFile(rawFileName);

            using (var reader = new XRawFileIO(dataFile.FullName))
            {
                Console.WriteLine("Scan label data for {0}", dataFile.Name);
                Console.WriteLine("{0} {1,3} {2,8} {3,-8} {4,-8} {5,-8} {6,-8} {7,-8}  {8}",
                                  "Scan", "Count", "Mass", "Intensity",
                                  "Resolution", "Baseline", "Noise", "Charge", "ScanFilter");

                for (var scanNumber = scanStart; scanNumber <= scanEnd; scanNumber++)
                {

                    // List of mass, intensity, resolution, baseline intensity, noise floor, and charge for each data point
                    udtFTLabelInfoType[] ftLabelData;

                    var dataPointsRead = reader.GetScanLabelData(scanNumber, out ftLabelData);

                    if (dataPointsRead == -1)
                        Assert.AreEqual(0, ftLabelData.Length, "Data count mismatch vs. function return value");
                    else
                        Assert.AreEqual(dataPointsRead, ftLabelData.Length, "Data count mismatch vs. function return value");

                    clsScanInfo scanInfo;
                    var success = reader.GetScanInfo(scanNumber, out scanInfo);

                    Assert.IsTrue(success, "GetScanInfo returned false for scan {0}", scanStart);

                    if (ftLabelData.Length == 0 && scanInfo.IsFTMS)
                    {
                        Assert.Fail("GetScanLabelData returned no data for FTMS scan " + scanNumber);
                    }

                    string scanSummary;

                    if (ftLabelData.Length == 0)
                    {
                        scanSummary = string.Format("{0} {1,3} {2,8} {3,8} {4,8} {5,8} {6,8} {7,8}  {8}",
                                scanNumber, ftLabelData.Length,
                                string.Empty,
                                string.Empty,
                                string.Empty,
                                string.Empty,
                                string.Empty,
                                string.Empty,
                                scanInfo.FilterText);

                    }
                    else
                    {
                        var midPoint = (int)(ftLabelData.Length / 2f);

                        scanSummary = string.Format("{0} {1,3} {2,8} {3,8} {4,8} {5,8} {6,8} {7,8}  {8}",
                                scanNumber, ftLabelData.Length,
                                ftLabelData[midPoint].Mass.ToString("0.000"),
                                ftLabelData[midPoint].Intensity.ToString("0.0E+0"),
                                ftLabelData[midPoint].Resolution.ToString("0.000"),
                                ftLabelData[midPoint].Baseline.ToString("0.000"),
                                ftLabelData[midPoint].Noise.ToString("0.000"),
                                ftLabelData[midPoint].Charge.ToString("0"),
                                scanInfo.FilterText);
                    }

                    Dictionary<int, string> expectedDataThisFile;
                    if (!expectedData.TryGetValue(Path.GetFileNameWithoutExtension(dataFile.Name), out expectedDataThisFile))
                    {
                        Assert.Fail("Dataset {0} not found in dictionary expectedData", dataFile.Name);
                    }

                    string expectedScanSummary;
                    if (expectedDataThisFile.TryGetValue(scanNumber, out expectedScanSummary))
                    {
                        Assert.AreEqual(scanNumber + " " + expectedScanSummary, scanSummary,
                                        "Scan summary mismatch, scan " + scanNumber);
                    }

                    Console.WriteLine(scanSummary);
                }
            }
        }
        private static void TestReader(string rawFilePath, bool centroid = false, bool testSumming = false, int scanStart = 0, int scanEnd = 0)
        {
            try {
                if (!File.Exists(rawFilePath)) {
                    Console.WriteLine("File not found, skipping: " + rawFilePath);
                    return;
                }

                using (var oReader = new XRawFileIO(rawFilePath))
                {

                    foreach(var method in oReader.FileInfo.InstMethods) {
                        Console.WriteLine(method);
                    }

                    var iNumScans = oReader.GetNumScans();

                    var strCollisionEnergies = string.Empty;

                    ShowMethod(oReader);

                    var scanStep = 1;

                    if (scanStart < 1)
                        scanStart = 1;
                    if (scanEnd < 1) {
                        scanEnd = iNumScans;
                        scanStep = 21;
                    } else {
                        if (scanEnd < scanStart) {
                            scanEnd = scanStart;
                        }
                    }

                    for (var iScanNum = scanStart; iScanNum <= scanEnd; iScanNum += scanStep) {
                        clsScanInfo oScanInfo;

                        var bSuccess = oReader.GetScanInfo(iScanNum, out oScanInfo);
                        if (bSuccess) {
                            Console.Write("Scan " + iScanNum + " at " + oScanInfo.RetentionTime.ToString("0.00") + " minutes: " + oScanInfo.FilterText);
                            var lstCollisionEnergies = oReader.GetCollisionEnergy(iScanNum);

                            if (lstCollisionEnergies.Count == 0) {
                                strCollisionEnergies = string.Empty;
                            } else if (lstCollisionEnergies.Count >= 1) {
                                strCollisionEnergies = lstCollisionEnergies[0].ToString("0.0");

                                if (lstCollisionEnergies.Count > 1) {
                                    for (var intIndex = 1; intIndex <= lstCollisionEnergies.Count - 1; intIndex++) {
                                        strCollisionEnergies += ", " + lstCollisionEnergies[intIndex].ToString("0.0");
                                    }
                                }
                            }

                            if (string.IsNullOrEmpty(strCollisionEnergies)) {
                                Console.WriteLine();
                            } else {
                                Console.WriteLine("; CE " + strCollisionEnergies);
                            }

                            string monoMZ;
                            string chargeState;
                            string isolationWidth;

                            if (oScanInfo.TryGetScanEvent("Monoisotopic M/Z:", out monoMZ, false)) {
                                Console.WriteLine("Monoisotopic M/Z: " + monoMZ);
                            }

                            if (oScanInfo.TryGetScanEvent("Charge State", out chargeState, true))
                            {
                                Console.WriteLine("Charge State: " + chargeState);
                            }

                            if (oScanInfo.TryGetScanEvent("MS2 Isolation Width", out isolationWidth, true))
                            {
                                Console.WriteLine("MS2 Isolation Width: " + isolationWidth);
                            }

                            if (iScanNum % 50 == 0 || scanEnd - scanStart <= 50) {
                                // Get the data for scan iScanNum

                                Console.WriteLine();
                                Console.WriteLine("Spectrum for scan " + iScanNum);

                                double[] dblMzList;
                                double[] dblIntensityList;
                                var intDataCount = oReader.GetScanData(iScanNum, out dblMzList, out dblIntensityList, 0, centroid);

                                var mzDisplayStepSize = 50;
                                if (centroid) {
                                    mzDisplayStepSize = 1;
                                }

                                for (var iDataPoint = 0; iDataPoint <= dblMzList.Length - 1; iDataPoint += mzDisplayStepSize) {
                                    Console.WriteLine("  " + dblMzList[iDataPoint].ToString("0.000") + " mz   " + dblIntensityList[iDataPoint].ToString("0"));
                                }
                                Console.WriteLine();

                                const int scansToSum = 15;

                                if (iScanNum + scansToSum < iNumScans & testSumming) {
                                    // Get the data for scan iScanNum through iScanNum + 15

                                    double[,] dblMassIntensityPairs;
                                    var dataCount = oReader.GetScanDataSumScans(iScanNum, iScanNum + scansToSum, out dblMassIntensityPairs, 0, centroid);

                                    Console.WriteLine("Summed spectrum, scans " + iScanNum + " through " + (iScanNum + scansToSum));

                                    for (var iDataPoint = 0; iDataPoint <= dblMassIntensityPairs.GetLength(1) - 1; iDataPoint += 50) {
                                        Console.WriteLine("  " + dblMassIntensityPairs[0, iDataPoint].ToString("0.000") + " mz   " + dblMassIntensityPairs[1, iDataPoint].ToString("0"));
                                    }

                                    Console.WriteLine();
                                }

                                if (oScanInfo.IsFTMS) {
                                    udtFTLabelInfoType[] ftLabelData;

                                    var dataCount = oReader.GetScanLabelData(iScanNum, out ftLabelData);

                                    Console.WriteLine();
                                    Console.WriteLine("{0,12}{1,12}{2,12}{3,12}{4,12}{5,12}", "Mass", "Intensity", "Resolution", "Baseline", "Noise", "Charge");

                                    for (var iDataPoint = 0; iDataPoint <= dataCount - 1; iDataPoint += 50) {
                                        Console.WriteLine("{0,12}{1,12}{2,12}{3,12}{4,12}{5,12}", ftLabelData[iDataPoint].Mass.ToString("0.000"), ftLabelData[iDataPoint].Intensity.ToString("0"), ftLabelData[iDataPoint].Resolution.ToString("0"), ftLabelData[iDataPoint].Baseline.ToString("0.0"), ftLabelData[iDataPoint].Noise.ToString("0"), ftLabelData[iDataPoint].Charge.ToString("0"));
                                    }

                                    udtMassPrecisionInfoType[] ftPrecisionData;

                                    dataCount = oReader.GetScanPrecisionData(iScanNum, out ftPrecisionData);

                                    Console.WriteLine();
                                    Console.WriteLine("{0,12}{1,12}{2,12}{3,12}{4,12}", "Mass", "Intensity", "AccuracyMMU", "AccuracyPPM", "Resolution");

                                    for (var iDataPoint = 0; iDataPoint <= dataCount - 1; iDataPoint += 50) {
                                        Console.WriteLine("{0,12}{1,12}{2,12}{3,12}{4,12}", ftPrecisionData[iDataPoint].Mass.ToString("0.000"), ftPrecisionData[iDataPoint].Intensity.ToString("0"), ftPrecisionData[iDataPoint].AccuracyMMU.ToString("0.000"), ftPrecisionData[iDataPoint].AccuracyPPM.ToString("0.000"), ftPrecisionData[iDataPoint].Resolution.ToString("0"));
                                    }
                                }

                            }

                        }
                    }

                }

            } catch (Exception ex) {
                Console.WriteLine("Error in sub TestReader: " + ex.Message);
            }
        }