WaveletCentroidingAlgorithm implements MSDKCentroidingAlgorithm { @Override public @Nonnull MsScan centroidScan(@Nonnull MsScan inputScan) { SimpleMsScan newScan = MsScanUtil.clone(inputScan, false); double[] mzBuffer = inputScan.getMzValues(); float[] intensityBuffer = inputScan.getIntensityValues(); int numOfDataPoints = inputScan.getNumberOfDataPoints(); if (numOfDataPoints == 0) { newScan.setDataPoints(mzBuffer, intensityBuffer, 0); return newScan; } float[] cwtDataPoints = performCWT(intensityBuffer, numOfDataPoints, scaleLevel, waveletWindow); int newNumOfDataPoints = extractMzPeaks(cwtDataPoints, mzBuffer, intensityBuffer); newScan.setDataPoints(mzBuffer, intensityBuffer, newNumOfDataPoints); return newScan; } WaveletCentroidingAlgorithm(@Nonnull Integer scaleLevel, @Nonnull Double waveletWindow); @Override @Nonnull MsScan centroidScan(@Nonnull MsScan inputScan);  }
@Test public void testOrbitrap() throws Exception { File inputFile = new File(this.getClass().getClassLoader().getResource("profile_orbitrap.mzML").toURI()); Assert.assertTrue(inputFile.canRead()); MzMLFileImportMethod importer = new MzMLFileImportMethod(inputFile); RawDataFile rawFile = importer.execute(); Assert.assertNotNull(rawFile); Assert.assertEquals(1.0, importer.getFinishedPercentage(), 0.0001); List<MsScan> scans = rawFile.getScans(); Assert.assertNotNull(scans); MsScan lastScan = scans.get(scans.size() - 1); WaveletCentroidingAlgorithm centroider = new WaveletCentroidingAlgorithm(5, 0.05); final MsScan centroidedScan = centroider.centroidScan(lastScan); double mzBuffer[] = centroidedScan.getMzValues(); float intensityBuffer[] = centroidedScan.getIntensityValues(); int numOfDataPoints = centroidedScan.getNumberOfDataPoints(); Assert.assertTrue(numOfDataPoints > 50); Integer basePeak = MsSpectrumUtil.getBasePeakIndex(intensityBuffer, numOfDataPoints); Assert.assertEquals(3.53683E7f, intensityBuffer[basePeak], 1E5); Assert.assertEquals(281.2476185, mzBuffer[basePeak], 0.000001); rawFile.dispose(); }