Repository navigation
feat: PeakPickerIM ion mobility centroding - #8427
Conversation
Co-authored-by: Timo Sachsenberg <[email protected]>
- Change "The OpenMS Team" to "OpenMS Inc." in copyright line - Fix overly long separator line to match standard format 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
- Replace std::cerr/cout with OPENMS_LOG_* macros throughout file - Remove misleading TODOs and add clarifying comments: - Empty mobilogram traces: explain they occur when no peaks found in FWHM window - getIntensity() vs computeIntensitySum(): explain FWHM indices requirement - sortByPosition()/updateRanges(): confirm both are needed, remove "maybe" TODOs - Optimize sorting: remove redundant isSorted() check before sortByPosition() (sortByPosition already checks internally, saves O(n) in common unsorted case) - Add explanatory comments for IM data flow and sorting requirements 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (1)
src/openms/source/PROCESSING/CENTROIDING/PeakPickerIM.cpp (1)
327-360: Make FloatDataArray access incomputeCentroids_robust to ordering changes.
computeCentroids_assumes that:
picked_trace.getFloatDataArrays()[0]contains IM FWHM, andraw_trace.getFloatDataArrays()[0]contains raw m/z values.This is brittle if additional arrays are added or the ordering changes. You already search by name in
extractIonMobilityTraces(“FWHM_ppm”, “raw_mz”); doing the same here would make this code future‑proof:
- Find the FWHM array in
picked_traceby name (e.g."IM FWHM"or whateverPeakPickerHiResuses) instead of index 0, and checksize() == picked_trace.size().- Find the raw m/z array in
raw_traceby name"raw_mz"instead of index 0, and checksize() == raw_trace.size().If lookup fails or sizes mismatch, log a warning and
continuerather than proceeding with wrong alignment. This also resolves the earlier “fragile FloatDataArray ordering” concern.
🧹 Nitpick comments (2)
src/openms/include/OpenMS/PROCESSING/CENTROIDING/PeakPickerIM.h (1)
15-37: Clarify required IMFormat in public API Doxygen.The header docs describe the IM data layout but don’t state explicitly that the algorithms expect raw, concatenated IM data (and will reject CENTROIDED/MULTIPLE_SPECTRA/MIXED via
validateIMFormatForPicking). Adding a short note to the class or each public method that onlyIMFormat::CONCATENATEDis supported would make misuse harder and aligns the API contract with the implementation inPeakPickerIM.cpp.Also applies to: 46-56, 64-103
src/topp/PeakPickerIM.cpp (1)
200-225: Mirror MULTIPLE_SPECTRA/MIXED handling in the in‑memory path.In the in‑memory path,
IMTypes::determineIMFormat(exp)only branches onCENTROIDEDandNONE;MULTIPLE_SPECTRAandMIXEDfall through and later trigger a generic exception fromvalidateIMFormatForPicking. To keep behavior consistent withdoLowMemAlgorithmand provide clearer errors, consider:- IMFormat im_format = IMTypes::determineIMFormat(exp); - if (im_format == IMFormat::CENTROIDED) + IMFormat im_format = IMTypes::determineIMFormat(exp); + if (im_format == IMFormat::CENTROIDED) { OPENMS_LOG_ERROR << "Error: Input file contains ion mobility data that is already centroided. " << "PeakPickerIM expects raw (concatenated) IM data. " << "Re-picking already centroided data is not supported." << std::endl; return ILLEGAL_PARAMETERS; } + if (im_format == IMFormat::MULTIPLE_SPECTRA) + { + OPENMS_LOG_ERROR << "Error: Input file contains ion mobility data in MULTIPLE_SPECTRA format " + << "(one spectrum per IM frame). PeakPickerIM expects raw (concatenated) IM data " + << "where each spectrum contains an ion mobility float data array. " + << "This format is not supported." << std::endl; + return ILLEGAL_PARAMETERS; + } + if (im_format == IMFormat::MIXED) + { + OPENMS_LOG_ERROR << "Error: Input file contains mixed ion mobility formats " + << "(both CONCATENATED and MULTIPLE_SPECTRA). PeakPickerIM expects raw (concatenated) IM data " + << "where each spectrum contains an ion mobility float data array. " + << "Mixed formats are not supported." << std::endl; + return ILLEGAL_PARAMETERS; + } if (im_format == IMFormat::NONE)This keeps both processing modes aligned and avoids deep, less informative exceptions for unsupported formats.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/openms/include/OpenMS/PROCESSING/CENTROIDING/PeakPickerIM.h(1 hunks)src/openms/source/PROCESSING/CENTROIDING/PeakPickerIM.cpp(1 hunks)src/tests/class_tests/openms/source/PeakPickerIM_test.cpp(1 hunks)src/topp/PeakPickerIM.cpp(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/tests/class_tests/openms/source/PeakPickerIM_test.cpp
🧰 Additional context used
📓 Path-based instructions (2)
src/openms/**/*.{cpp,h,hpp,cc,cxx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
src/openms/**/*.{cpp,h,hpp,cc,cxx}: Follow the existing C++ coding conventions in the codebase
Use the established naming patterns for classes, methods, and variables
Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Follow the established error handling patterns
Utilize OpenMS logging mechanisms
Be mindful of memory usage when processing large datasets
Consider algorithmic complexity for data processing operations
Use appropriate OpenMS containers and algorithms
Files:
src/openms/include/OpenMS/PROCESSING/CENTROIDING/PeakPickerIM.hsrc/openms/source/PROCESSING/CENTROIDING/PeakPickerIM.cpp
src/openms/include/OpenMS/**/*.h
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Add Doxygen comments for new public methods and classes
Files:
src/openms/include/OpenMS/PROCESSING/CENTROIDING/PeakPickerIM.h
🧠 Learnings (16)
📓 Common learnings
Learnt from: jcharkow
Repo: OpenMS/OpenMS PR: 8188
File: src/topp/OpenSwathWorkflow.cpp:1118-1123
Timestamp: 2025-08-29T19:09:45.997Z
Learning: In OpenMS OpenSwathWorkflow, the use_ms1_ion_mobility parameter should be respected when applying estimated MS1 ion mobility extraction windows. The apply_window calls for MS1 ion mobility should check both pasef AND use_ms1_ion_mobility to avoid re-enabling disabled functionality.
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8177
File: src/openms/source/FORMAT/HANDLERS/MzMLHandler.cpp:5069-5074
Timestamp: 2025-12-04T16:25:06.988Z
Learning: In OpenMS mzML writing, PSI-MS term MS:1003441 "ion mobility centroid frame" is a spectrum-level cvParam. It should be written at spectrum level (not scan level).
Learnt from: jpfeuffer
Repo: OpenMS/OpenMS PR: 7970
File: src/pyOpenMS/addons/MSSpectrum.pyx:24-28
Timestamp: 2025-04-07T21:16:06.557Z
Learning: In OpenMS, the proper way to access ion mobility data in MSSpectrum is to use the `getIMData()` method, which returns a tuple with (position, unit). The position corresponds to the index in the FloatDataArrays where the ion mobility data is stored. Always use this method rather than assuming the first FloatDataArray contains ion mobility data.
Learnt from: jpfeuffer
Repo: OpenMS/OpenMS PR: 7970
File: src/pyOpenMS/addons/MSSpectrum.pyx:24-28
Timestamp: 2025-04-07T21:16:06.557Z
Learning: In OpenMS, the proper way to access ion mobility data in MSSpectrum is to use the `getIMData()` method, which returns a tuple with (position, unit). The position corresponds to the index in the FloatDataArrays where the ion mobility data is stored. Always use this method rather than assuming the first FloatDataArray contains ion mobility data.
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Applied to files:
src/openms/include/OpenMS/PROCESSING/CENTROIDING/PeakPickerIM.hsrc/topp/PeakPickerIM.cppsrc/openms/source/PROCESSING/CENTROIDING/PeakPickerIM.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/include/OpenMS/**/*.h : Add Doxygen comments for new public methods and classes
Applied to files:
src/openms/include/OpenMS/PROCESSING/CENTROIDING/PeakPickerIM.hsrc/topp/PeakPickerIM.cppsrc/openms/source/PROCESSING/CENTROIDING/PeakPickerIM.cpp
📚 Learning: 2025-12-04T16:25:06.988Z
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8177
File: src/openms/source/FORMAT/HANDLERS/MzMLHandler.cpp:5069-5074
Timestamp: 2025-12-04T16:25:06.988Z
Learning: In OpenMS mzML writing, PSI-MS term MS:1003441 "ion mobility centroid frame" is a spectrum-level cvParam. It should be written at spectrum level (not scan level).
Applied to files:
src/openms/include/OpenMS/PROCESSING/CENTROIDING/PeakPickerIM.hsrc/topp/PeakPickerIM.cppsrc/openms/source/PROCESSING/CENTROIDING/PeakPickerIM.cpp
📚 Learning: 2025-04-07T21:16:06.557Z
Learnt from: jpfeuffer
Repo: OpenMS/OpenMS PR: 7970
File: src/pyOpenMS/addons/MSSpectrum.pyx:24-28
Timestamp: 2025-04-07T21:16:06.557Z
Learning: In OpenMS, the proper way to access ion mobility data in MSSpectrum is to use the `getIMData()` method, which returns a tuple with (position, unit). The position corresponds to the index in the FloatDataArrays where the ion mobility data is stored. Always use this method rather than assuming the first FloatDataArray contains ion mobility data.
Applied to files:
src/openms/include/OpenMS/PROCESSING/CENTROIDING/PeakPickerIM.hsrc/openms/source/PROCESSING/CENTROIDING/PeakPickerIM.cpp
📚 Learning: 2025-09-03T12:58:20.032Z
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8177
File: src/tests/topp/CMakeLists.txt:1857-1865
Timestamp: 2025-09-03T12:58:20.032Z
Learning: OpenMS tests: When adding new TOPP tests in src/tests/topp/CMakeLists.txt that compare outputs via FuzzyDiff, always add set_tests_properties("<tool>_<n>_out<m>" PROPERTIES DEPENDS "<tool>_<n>") to avoid flakiness under parallel CTest runs.
Applied to files:
src/topp/PeakPickerIM.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Be mindful of memory usage when processing large datasets
Applied to files:
src/topp/PeakPickerIM.cppsrc/openms/source/PROCESSING/CENTROIDING/PeakPickerIM.cpp
📚 Learning: 2025-08-29T19:09:45.997Z
Learnt from: jcharkow
Repo: OpenMS/OpenMS PR: 8188
File: src/topp/OpenSwathWorkflow.cpp:1118-1123
Timestamp: 2025-08-29T19:09:45.997Z
Learning: In OpenMS OpenSwathWorkflow, the use_ms1_ion_mobility parameter should be respected when applying estimated MS1 ion mobility extraction windows. The apply_window calls for MS1 ion mobility should check both pasef AND use_ms1_ion_mobility to avoid re-enabling disabled functionality.
Applied to files:
src/topp/PeakPickerIM.cppsrc/openms/source/PROCESSING/CENTROIDING/PeakPickerIM.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Consider algorithmic complexity for data processing operations
Applied to files:
src/openms/source/PROCESSING/CENTROIDING/PeakPickerIM.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Utilize OpenMS logging mechanisms
Applied to files:
src/openms/source/PROCESSING/CENTROIDING/PeakPickerIM.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Follow the established error handling patterns
Applied to files:
src/openms/source/PROCESSING/CENTROIDING/PeakPickerIM.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use appropriate OpenMS containers and algorithms
Applied to files:
src/openms/source/PROCESSING/CENTROIDING/PeakPickerIM.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/tests/class_tests/openms/**/*.cpp : Write unit tests for new functionality
Applied to files:
src/openms/source/PROCESSING/CENTROIDING/PeakPickerIM.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use the established naming patterns for classes, methods, and variables
Applied to files:
src/openms/source/PROCESSING/CENTROIDING/PeakPickerIM.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/tests/class_tests/openms/*Test.cpp : Follow naming convention: `ClassNameTest.cpp` for `ClassName`
Applied to files:
src/openms/source/PROCESSING/CENTROIDING/PeakPickerIM.cpp
📚 Learning: 2025-08-14T10:19:54.371Z
Learnt from: jpfeuffer
Repo: OpenMS/OpenMS PR: 8167
File: src/topp/Digestor.cpp:200-226
Timestamp: 2025-08-14T10:19:54.371Z
Learning: In OpenMS (C++ bioinformatics framework), use boost random libraries instead of std library random distributions for cross-platform reproducible random number generation, as std library distributions are not reproducible across platforms.
Applied to files:
src/openms/source/PROCESSING/CENTROIDING/PeakPickerIM.cpp
🧬 Code graph analysis (2)
src/openms/include/OpenMS/PROCESSING/CENTROIDING/PeakPickerIM.h (1)
src/openms/source/PROCESSING/CENTROIDING/PeakPickerIM.cpp (19)
PeakPickerIM(677-694)pickIMTraces(747-970)pickIMTraces(747-747)pickIMCluster(972-1198)pickIMCluster(972-972)pickIMElutionProfiles(1200-1288)pickIMElutionProfiles(1200-1200)updateMembers_(695-708)updateMembers_(695-695)computeOptimalSamplingRate(41-137)computeOptimalSamplingRate(41-41)sumFrame_(158-192)sumFrame_(158-161)ppmBounds(140-149)ppmBounds(140-140)extractIonMobilityTraces(200-299)extractIonMobilityTraces(200-202)computeCentroids_(302-661)computeCentroids_(302-303)
src/topp/PeakPickerIM.cpp (2)
src/openms/include/OpenMS/PROCESSING/SMOOTHING/GaussFilterAlgorithm.h (1)
OpenMS(21-362)src/openms/source/IONMOBILITY/IMTypes.cpp (4)
determineIMFormat(64-93)determineIMFormat(64-64)determineIMFormat(95-126)determineIMFormat(95-95)
🪛 GitHub Check: CodeFactor
src/openms/source/PROCESSING/CENTROIDING/PeakPickerIM.cpp
[notice] 972-1199: src/openms/source/PROCESSING/CENTROIDING/PeakPickerIM.cpp#L972-L1199
Complex Method
[notice] 621-621: src/openms/source/PROCESSING/CENTROIDING/PeakPickerIM.cpp#L621
Redundant blank line at the end of a code block should be deleted. (whitespace/blank_line)
[notice] 302-662: src/openms/source/PROCESSING/CENTROIDING/PeakPickerIM.cpp#L302-L662
Complex Method
[notice] 707-707: src/openms/source/PROCESSING/CENTROIDING/PeakPickerIM.cpp#L707
Redundant blank line at the end of a code block should be deleted. (whitespace/blank_line)
[notice] 1175-1175: src/openms/source/PROCESSING/CENTROIDING/PeakPickerIM.cpp#L1175
Redundant blank line at the end of a code block should be deleted. (whitespace/blank_line)
🔇 Additional comments (1)
src/topp/PeakPickerIM.cpp (1)
125-185: Low‑memory IMFormat validation now matches requested behavior.The low‑memory path correctly rejects
IMFormat::CENTROIDED,IMFormat::MULTIPLE_SPECTRA, andIMFormat::MIXEDwith clearOPENMS_LOG_ERRORmessages and returnsILLEGAL_PARAMETERS, whileIMFormat::NONEis passed through unchanged. This satisfies the PR request to fail fast with user‑friendly diagnostics for unsupported IM formats in streaming mode.
This pull request introduces a new ion mobility peak picking tool,
PeakPickerIM, and adds support for new ion mobility data formats and APIs in the OpenMS library. It also includes improvements to peak picking and elution peak detection algorithms, especially for edge cases in ion mobility data. The most important changes are grouped below by theme.New Ion Mobility Peak Picking Tool
PeakPickerIM, a new peak picking algorithm for ion mobility data with three methods: mobilogram-based, clustering, and elution profile-based picking. Supports both in-memory and low-memory streaming modes. (CHANGELOG,src/openms/include/OpenMS/PROCESSING/CENTROIDING/PeakPickerIM.h,src/openms/include/OpenMS/PROCESSING/CENTROIDING/sources.cmake,src/openms/source/APPLICATIONS/ToolHandler.cpp) [1] [2] [3] [4]Ion Mobility Data Format Support and API Enhancements
CENTROIDEDandUNKNOWNin theIMFormatenum. Added documentation clarifying usage and behavior. (CHANGELOG,src/openms/include/OpenMS/IONMOBILITY/IMTypes.h) [1] [2]setIMFormat()andgetIMFormat()API toMSSpectrum/SpectrumSettingsfor per-spectrum ion mobility format tracking. Updated constructors and members for default initialization. (CHANGELOG,src/openms/include/OpenMS/METADATA/SpectrumSettings.h) [1] [2] [3] [4] [5]Meta Value and Data Array Improvements
ION_MOBILITYfor raw data andION_MOBILITY_CENTROIDfor centroided output. Improved documentation for usage in algorithms. (src/openms/include/OpenMS/CONCEPT/Constants.h)MetaInfoInterfaceAPI: clarified behavior ofaddMetaValues(), used default constructors, and ensured pointer initialization. (src/openms/include/OpenMS/METADATA/MetaInfoInterface.h) [1] [2] [3]Peak Picking and Elution Peak Detection Robustness
src/openms/source/FEATUREFINDER/ElutionPeakDetection.cpp) [1] [2]src/openms/source/FEATUREFINDER/ElutionPeakDetection.cpp) [1] [2] [3] [4]Miscellaneous
src/openms/include/OpenMS/METADATA/SpectrumSettings.h,src/openms/include/OpenMS/PROCESSING/SMOOTHING/GaussFilterAlgorithm.h) [1] [2]## DescriptionChecklist
How can I get additional information on failed tests during CI
Click to expand
If your PR is failing you can check outIf you click in the column that lists the failed tests you will get detailed error messages.
Advanced commands (admins / reviewer only)
Click to expand
/reformat(experimental) applies the clang-format style changes as additional commit. Note: your branch must have a different name (e.g., yourrepo:feature/XYZ) than the receiving branch (e.g., OpenMS:develop). Otherwise, reformat fails to push.rebuild jenkinswill retrigger Jenkins-based CI buildsSummary by CodeRabbit
New Features
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.