Skip to content

refactor: split IMFormat into IMFormat + IMPeakType (data layout vs processing state) - #9007

Merged
timosachsenberg merged 14 commits into
developfrom
refactor/imformat-two-enum
Mar 26, 2026
Merged

timosachsenberg merged 14 commits into
developfrom
refactor/imformat-two-enum

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Mar 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Splits the IMFormat enum into two orthogonal enums:

  • IMFormat (data layout): NONE, IM_PEAK, IM_SPECTRUM, MIXED, UNKNOWN
  • IMPeakType (IM processing state): IM_PROFILE, IM_CENTROIDED, UNKNOWN

This separates "where is IM data stored?" from "has IM been centroided in the IM dimension?", analogous to how SpectrumSettings::SpectrumType (PROFILE/CENTROID) is separate from m/z data layout.

Key changes

  • New enum + storage: IMPeakType added to IMTypes.h, stored on SpectrumSettings alongside IMFormat
  • PeakPickerIM: Checks IMPeakType::IM_CENTROIDED to reject re-picking; sets IM_CENTROIDED on output
  • MzML I/O: CV term MS:1003441 maps to IMPeakType::IM_CENTROIDED; raw IM data defaults to IM_PROFILE
  • BrukerTimsFile: Sets IM_PROFILE on raw TIMS frames, IM_CENTROIDED on internally centroided MS1
  • Biosaur2: Skips internal centroidPASEFData_() when input is IM_CENTROIDED (avoids redundant re-centroiding)
  • Feature finders: Log IM peak type at startup for transparency
  • pyOpenMS: IMPeakType enum, getter/setter, string conversions exposed

Bug fix

Previously, algorithms checking == IMFormat::IM_PEAK (Biosaur2, FeatureFinders) would silently skip data that had been centroided by PeakPickerIM (which set IMFormat::CENTROIDED). Now centroided IM data retains IMFormat::IM_PEAK (correct layout) and is processed correctly.

Design principle

Only IM_CENTROIDED is special. UNKNOWN and IM_PROFILE are both treated as raw/profile data by consumers (safe default).

Test plan

  • IMTypes_test -- all sections pass (new IMPeakType tests + updated IMFormat tests)
  • MSSpectrum_test -- getter/setter tests pass
  • PeakPickerIM_test -- passes
  • Full library compiles cleanly
  • Zero IMFormat::CENTROIDED references remain
  • CI full test suite

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Enhanced ion mobility data classification: spectra can now explicitly indicate whether IM data is in profile or centroided form through new metadata.
  • Bug Fixes

    • Improved handling of pre-centroided ion mobility datasets: algorithms now correctly detect and skip redundant centroiding steps for already-centroided IM data.
    • Fixed file format handlers to properly preserve ion mobility peak type information during import/export operations.
  • Refactor

    • Refined ion mobility metadata representation for more precise data state tracking across processing pipelines.

timosachsenberg and others added 10 commits March 26, 2026 11:42
Add new IMPeakType enum (IM_PROFILE, IM_CENTROIDED, UNKNOWN) to separate
IM processing state from data layout. Store on SpectrumSettings alongside
existing IMFormat. Mark IMFormat::CENTROIDED as deprecated.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Move centroided-rejection check from IMFormat switch to IMPeakType check.
Output marking now uses setIMPeakType(IM_CENTROIDED). Remove CENTROIDED
branches from TOPP tool (both high-memory and streaming paths).

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
All consumers have been migrated to IMPeakType::IM_CENTROIDED.
Remove the deprecated CENTROIDED value from IMFormat enum.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Add IMPeakType nanobind enum, getter/setter on MSSpectrum, string
conversion static methods and __static_* wrappers. Update stale pxd.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Check IMPeakType before calling centroidPASEFData_(). When input
has been pre-processed by PeakPickerIM (IM_CENTROIDED), skip the
internal PASEF/TIMS centroiding step. UNKNOWN and IM_PROFILE
proceed to centroiding as before (safe default).

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
MzMLHandler sets IMPeakType::IM_PROFILE on spectra with IM float
data arrays when no MS:1003441 (centroided) CV term is present.
BrukerTimsFile sets IM_PROFILE on all raw TIMS frames and
IM_CENTROIDED on internally centroided MS1 frames.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Mar 26, 2026 •

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 656c4535-a43d-4e4b-9c5b-6ee386c52516

📥 Commits

Reviewing files that changed from the base of the PR and between 8ea602e and 89cdfb5.

📒 Files selected for processing (2)
  • src/openms/include/OpenMS/IONMOBILITY/IMTypes.h
  • src/openms/include/OpenMS/METADATA/SpectrumSettings.h

📝 Walkthrough

Walkthrough

This PR replaces IMFormat::CENTROIDED with a new IMPeakType enum that explicitly represents ion mobility data processing state (profile or centroided). It adds metadata accessors to SpectrumSettings, implements enum-to-string conversions in IMTypes, updates I/O handlers and algorithms to set/check the new type, and exports all functionality to Python bindings.

Changes

Cohort / File(s) Summary
Core IM Type System
src/openms/include/OpenMS/IONMOBILITY/IMTypes.h, src/openms/source/IONMOBILITY/IMTypes.cpp
Removed CENTROIDED from IMFormat enum; added new IMPeakType enum with IM_PROFILE, IM_CENTROIDED, UNKNOWN states; implemented toIMPeakType() and imPeakTypeToString() conversion functions and NamesOfIMPeakType lookup table.
Spectrum Metadata
src/openms/include/OpenMS/METADATA/SpectrumSettings.h, src/openms/source/METADATA/SpectrumSettings.cpp
Added setIMPeakType(IMPeakType) and getIMPeakType() const methods plus protected im_peak_type_ member to store IM peak classification.
I/O and File Format Handling
src/openms/source/FORMAT/BrukerTimsFile.cpp, src/openms/source/FORMAT/HANDLERS/MzMLHandler.cpp
Updated to set IMPeakType metadata when reading/writing IM data; MzMLHandler now maps centroid frame CV param to IMPeakType::IM_CENTROIDED instead of deprecated IMFormat::CENTROIDED.
Feature Detection Algorithms
src/openms/source/FEATUREFINDER/Biosaur2Algorithm.cpp, src/openms/source/FEATUREFINDER/FeatureFinderAlgorithmMetaboIdent.cpp, src/openms/source/FEATUREFINDER/FeatureFinderIdentificationAlgorithm.cpp
Added IM peak-type detection and logging; Biosaur2Algorithm now skips centroiding when data is already centroided based on IMPeakType::IM_CENTROIDED check.
IM Centroiding
src/openms/source/PROCESSING/CENTROIDING/PeakPickerIM.cpp
Updated validation to reject IMPeakType::IM_CENTROIDED input; output spectra now explicitly set IMPeakType::IM_CENTROIDED instead of IMFormat::CENTROIDED.
TOPP Tool
src/topp/PeakPickerIM.cpp
Removed validation check that rejected IMFormat::CENTROIDED input, allowing pre-centroided data to pass through.
Python Bindings
src/pyOpenMS/bindings/bind_kernel.cpp, src/pyOpenMS/bindings/bind_misc.cpp, src/pyOpenMS/bindings/bind_spectrum.cpp
Exposed new IMPeakType enum; added MSSpectrum.setIMPeakType() and getIMPeakType() methods; added IMTypes.toIMPeakType() and imPeakTypeToString() static methods.
Tests
src/tests/class_tests/openms/source/IMTypes_test.cpp, src/tests/class_tests/openms/source/MSSpectrum_test.cpp, src/pyOpenMS/tests/unittests/test_api_missing_enums.py
Added coverage for IMPeakType string conversions, getter/setter functionality, and backward-compatibility validation.

Possibly related PRs

  • PR #9007: Implements the same code-level changes removing IMFormat::CENTROIDED and introducing IMPeakType enum across the same files and modules.
  • PR #8427: Introduced the earlier IMFormat::CENTROIDED approach that this PR replaces with the new IMPeakType design.
  • PR #7453: Introduced initial IM/FAIMS handling functionality that this PR extends with more explicit peak-type classification.

Suggested labels

enhancement, Review effort [1-5]: 3

Suggested reviewers

  • singjc
  • alhigaylan
  • cbielow
  • poshul

Poem

🐰 A hop toward clarity, a bound so swift,
Peak types now shine—profile or centroided drift,
No more ambiguous formats in the IM way,
With explicit state tracking, data flows clear as day! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 21.05% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main refactoring: splitting IMFormat into two orthogonal enums (IMFormat for data layout and IMPeakType for processing state), which is the core change across all modified files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/imformat-two-enum

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/topp/PeakPickerIM.cpp (1)

247-274: ⚠️ Potential issue | 🟠 Major

Move IM format validation out of the OpenMP parallel loop.

The in-memory path (lines 247–280) checks only for IMFormat::NONE before entering the #pragma omp parallel for region, then defers validation of unsupported formats to validateIMFormatForPicking() called inside each worker thread. That method throws Exception::InvalidValue for centroided, UNKNOWN, or unsupported formats—causing hard termination from within the parallel region instead of clean error reporting. The low-memory path (lines 195–206) validates IM_SPECTRUM and MIXED formats upfront with OPENMS_LOG_ERROR and return ILLEGAL_PARAMETERS. Apply the same validation before the parallel loop in the in-memory path.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/topp/PeakPickerIM.cpp` around lines 247 - 274, The in-memory branch
currently defers IM format validation to validateIMFormatForPicking() inside
each thread, which can throw inside the OpenMP loop; move the validation out of
the parallel region by calling IMTypes::determineIMFormat(exp) (already present)
and then perform the same check used in the low-memory path: if im_format is
neither IMFormat::IM_SPECTRUM nor IMFormat::MIXED, log an OPENMS_LOG_ERROR with
a clear message and return ILLEGAL_PARAMETERS before entering the `#pragma` omp
parallel for so picker.pickIMTraces, picker.pickIMCluster, and
picker.pickIMElutionProfiles are only called when the format is supported and no
exceptions are thrown inside worker threads.
src/openms/source/PROCESSING/CENTROIDING/PeakPickerIM.cpp (1)

969-976: ⚠️ Potential issue | 🟠 Major

Also stamp the output layout as IMFormat::IM_PEAK.

These paths only update IMPeakType. If the incoming metadata is still IMFormat::UNKNOWN, the centroided result stays UNKNOWN after the settings copy/in-place rewrite even though the output still stores per-peak IM data. That leaves the new layout/state split inconsistent and can still trip callers that read getIMFormat() directly.

🩹 Proposed fix
       removeAllFloatDataArraysExcept(centroided_frame, Constants::UserParam::ION_MOBILITY_CENTROID);
+      centroided_frame.setIMFormat(IMFormat::IM_PEAK);
       centroided_frame.setIMPeakType(IMPeakType::IM_CENTROIDED);
       spectrum.getFloatDataArrays()[im_data_index].setName(Constants::UserParam::ION_MOBILITY_CENTROID);
+      spectrum.setIMFormat(IMFormat::IM_PEAK);
       spectrum.setIMPeakType(IMPeakType::IM_CENTROIDED);
       removeAllFloatDataArraysExcept(spectrum, Constants::UserParam::ION_MOBILITY_CENTROID);
       input.getFloatDataArrays()[im_data_index].setName(Constants::UserParam::ION_MOBILITY_CENTROID);
+      input.setIMFormat(IMFormat::IM_PEAK);
       input.setIMPeakType(IMPeakType::IM_CENTROIDED);
       removeAllFloatDataArraysExcept(input, Constants::UserParam::ION_MOBILITY_CENTROID);

Also applies to: 1221-1226, 1316-1321

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/PROCESSING/CENTROIDING/PeakPickerIM.cpp` around lines 969 -
976, The centroiding path currently only sets the IM peak type (via
centroided_frame.setIMPeakType(IMPeakType::IM_CENTROIDED)) but does not update
the container layout/format, leaving getIMFormat() as IMFormat::UNKNOWN; after
copying SpectrumSettings into centroided_frame and before moving it back into
spectrum, also set the IM format to IMFormat::IM_PEAK (e.g.,
centroided_frame.setIMFormat(IMFormat::IM_PEAK)) so the per-peak IM layout/state
is consistent; apply the same change in the other centroiding branches that
mirror this logic (the similar blocks around the other centroiding paths that
set IMPeakType).
🧹 Nitpick comments (3)
src/pyOpenMS/bindings/bind_kernel.cpp (1)

153-167: Keep new IMTypes.h bindings in bind_misc.cpp.

Lines 153-167 add another symbol from OpenMS/IONMOBILITY/IMTypes.h to bind_kernel.cpp. Since the conversion helpers for IMPeakType already live in bind_misc.cpp, moving the enum there keeps the IMTypes API together instead of deepening the current split.

As per coding guidelines, "Choose binding files based on C++ header module path: KERNEL/* → bind_kernel.cpp, MSSpectrum.h → bind_spectrum.cpp, MSChromatogram.h → bind_chromatogram.cpp, MSExperiment.h → bind_experiment.cpp, FORMAT/* → bind_format.cpp, ANALYSIS/* → bind_analysis.cpp, CHEMISTRY/* → bind_chemistry.cpp, METADATA/* → bind_metadata.cpp, PROCESSING/* → bind_processing.cpp, FEATUREFINDER/* → bind_featurefinder.cpp, DATASTRUCTURES/MATH/CONCEPT/* → bind_datastructures.cpp, ML/* → bind_ml.cpp, all others → bind_misc.cpp"

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/pyOpenMS/bindings/bind_kernel.cpp` around lines 153 - 167, The IMPeakType
enum binding added to bind_kernel.cpp should be moved into bind_misc.cpp so the
IMTypes.h API and its conversion helpers remain together; remove the
nb::enum_<OpenMS::IMPeakType> block from bind_kernel.cpp and re-add the same
enum registration in bind_misc.cpp alongside the existing conversion helpers for
IMPeakType, ensuring you import or include OpenMS/IONMOBILITY/IMTypes.h where
needed and call .value(...)/.export_values() exactly as before so the binding
API remains identical.
src/tests/class_tests/openms/source/IMTypes_test.cpp (1)

168-178: Make this test fixture explicit with one real IM peak.

Right now the assertion is based on an empty spectrum + empty IM array. Adding one peak and one IM value makes the behavior under test unambiguous.

Proposed test setup tweak
 START_SECTION(determineIMFormat returns IM_PEAK for centroided IM data)
 {
   MSSpectrum s;
+  Peak1D p;
+  p.setMZ(500.0);
+  p.setIntensity(100.0);
+  s.push_back(p);
   MSSpectrum::FloatDataArray fda;
   fda.setName("Ion Mobility");
+  fda.push_back(1.0f);
   s.getFloatDataArrays().push_back(fda);
   s.setIMPeakType(IMPeakType::IM_CENTROIDED);
   TEST_EQUAL(IMTypes::determineIMFormat(s), IMFormat::IM_PEAK)
 }
 END_SECTION
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/tests/class_tests/openms/source/IMTypes_test.cpp` around lines 168 - 178,
The test uses an empty MSSpectrum and empty IM float array which makes
determineIMFormat's behavior ambiguous; modify the fixture to add a real peak
and a matching IM value: create a Peak1 (e.g., MSSpectrum::PeakType with m/z and
intensity) and push it into the MSSpectrum via push_back, then add a single
float IM value into the FloatDataArray obtained from s.getFloatDataArrays() (or
use fda.push_back(value) before pushing fda into the spectrum), keep the call to
s.setIMPeakType(IMPeakType::IM_CENTROIDED) and assert
IMTypes::determineIMFormat(s) == IMFormat::IM_PEAK so the test is explicit about
having one centroided IM peak.
src/openms/include/OpenMS/IONMOBILITY/IMTypes.h (1)

77-84: Add full Doxygen blocks for the new public conversion helpers.

toIMPeakType and imPeakTypeToString are public header APIs, but the new comments stop short of the repo-standard @brief, @param[in], @return, and @throws documentation.

As per coding guidelines, "Document all method parameters with @param[in], @param[out], or @param[in,out] tags; use @brief as required first line; document return values with @return."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/include/OpenMS/IONMOBILITY/IMTypes.h` around lines 77 - 84, Add
full Doxygen blocks for the public conversion helpers: expand the brief
single-line comments above NamesOfIMPeakType, toIMPeakType, and
imPeakTypeToString into repo-standard Doxygen blocks that include `@brief`,
`@param`[in] for im_peak_type (for toIMPeakType) and im_peak_type (for
imPeakTypeToString), `@return` describing the returned value/reference, and
`@throws` describing the behavior when an invalid/unknown peak type string or enum
value is passed; reference the existing symbols NamesOfIMPeakType, toIMPeakType,
and imPeakTypeToString so the docs are clearly tied to those declarations.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/openms/include/OpenMS/METADATA/SpectrumSettings.h`:
- Around line 106-110: Add full Doxygen comments for the two new public
accessors: for void setIMPeakType(IMPeakType im_peak_type) add a `@brief`
describing that it sets the IM peak type and a `@param`[in] im_peak_type
describing the allowed values/semantics; for IMPeakType getIMPeakType() const
add a `@brief` describing that it returns the current IM peak type and a `@return`
describing what is returned. Ensure the first line uses `@brief`, use `@param`[in]
for the setter parameter name im_peak_type, and include `@return` on the getter so
the documentation matches the rest of SpectrumSettings' public API.
- Line 170: SpectrumSettings gained the member im_peak_type_ but equality and
hashing were not updated; update SpectrumSettings::operator== to include
comparison of im_peak_type_ (so two SpectrumSettings differ when im_peak_type_
differs) and update the std::hash<OpenMS::SpectrumSettings> specialization to
mix in the hash of im_peak_type_ (use the existing hash-combine pattern used
elsewhere in OpenMS to incorporate im_peak_type_ into the final size_t). Ensure
you reference the im_peak_type_ field in both places so
MSSpectrum/SpectrumSettings objects with different IM peak types no longer
compare or hash identically.

In `@src/openms/source/FEATUREFINDER/Biosaur2Algorithm.cpp`:
- Around line 259-286: The current loop over groups may break out early even if
no concrete IMPeakType was found; adjust the control flow in the groups ->
group_exp loops so you only stop scanning further groups after you actually log
a non-UNKNOWN IMPeakType. Concretely, in the outer loop that iterates over
groups (group_pair / group_exp) keep the any_im_array detection but introduce a
boolean like found_concrete (or reuse any_im_array differently) that is set only
when spec.getIMPeakType() yields a non-UNKNOWN and you call
imPeakTypeToString(...) and log it; only then break out of the outer loop —
otherwise continue to the next group to keep searching for a concrete
IMPeakType.
- Around line 1213-1234: The current loop sets im_already_centroided if any
spectrum in group_exp has IMPeakType::IM_CENTROIDED, which wrongly skips
centroiding for mixed groups; change the logic to set im_already_centroided true
only when all IM spectra in group_exp are IMPeakType::IM_CENTROIDED (e.g.,
assume true and mark false on seeing any spectrum where spec.getIMPeakType() !=
IMPeakType::IM_CENTROIDED or only consider spectra with IM data), so the
subsequent check that gates internal PASEF/TIMS centroiding uses a “all
centroided” guard rather than an “any centroided” one.

In `@src/openms/source/FORMAT/HANDLERS/MzMLHandler.cpp`:
- Around line 1288-1292: The fallback to set IM peak type to
IMPeakType::IM_PROFILE is being checked via spec_.containsIMData() before the
binary IM arrays are materialized, so containsIMData() returns false and IM
frames remain UNKNOWN; move this fallback logic to after
populateSpectraWithData_() where spec_ binary arrays exist, or alternatively
detect IM presence directly from bin_data_ in this location (e.g., check
bin_data_ for IM arrays) and only then call
spec_.setIMPeakType(IMPeakType::IM_PROFILE) when spec_.getIMPeakType() ==
IMPeakType::UNKNOWN; update references to containsIMData(), getIMPeakType(),
setIMPeakType(), populateSpectraWithData_(), and bin_data_ accordingly.

In `@src/pyOpenMS/bindings/bind_kernel.cpp`:
- Around line 157-167: The enum binding for OpenMS::IMPeakType is calling
.export_values(), which exports its members (including UNKNOWN) into the module
namespace and shadows the existing module-level UNKNOWN from IMFormat; remove
the .export_values() call on the nb::enum_<OpenMS::IMPeakType>(...) binding so
the enum remains scoped (access via pyopenms.IMPeakType.UNKNOWN) and do not
export its values into the parent module namespace; verify no other enum class
bindings use .export_values() for strongly typed enums.

In `@src/pyOpenMS/pxds/IMTypes.pxd`:
- Around line 18-38: The enums DriftTimeUnit, IMFormat, and IMPeakType declare
unscoped members (e.g., NONE, UNKNOWN) that collide; change each declaration
from "cdef enum EnumName:" to "cdef enum class EnumName:" so their enumerators
are scoped and no longer conflict (update DriftTimeUnit, IMFormat, IMPeakType
declarations accordingly and recompile to verify).

---

Outside diff comments:
In `@src/openms/source/PROCESSING/CENTROIDING/PeakPickerIM.cpp`:
- Around line 969-976: The centroiding path currently only sets the IM peak type
(via centroided_frame.setIMPeakType(IMPeakType::IM_CENTROIDED)) but does not
update the container layout/format, leaving getIMFormat() as IMFormat::UNKNOWN;
after copying SpectrumSettings into centroided_frame and before moving it back
into spectrum, also set the IM format to IMFormat::IM_PEAK (e.g.,
centroided_frame.setIMFormat(IMFormat::IM_PEAK)) so the per-peak IM layout/state
is consistent; apply the same change in the other centroiding branches that
mirror this logic (the similar blocks around the other centroiding paths that
set IMPeakType).

In `@src/topp/PeakPickerIM.cpp`:
- Around line 247-274: The in-memory branch currently defers IM format
validation to validateIMFormatForPicking() inside each thread, which can throw
inside the OpenMP loop; move the validation out of the parallel region by
calling IMTypes::determineIMFormat(exp) (already present) and then perform the
same check used in the low-memory path: if im_format is neither
IMFormat::IM_SPECTRUM nor IMFormat::MIXED, log an OPENMS_LOG_ERROR with a clear
message and return ILLEGAL_PARAMETERS before entering the `#pragma` omp parallel
for so picker.pickIMTraces, picker.pickIMCluster, and
picker.pickIMElutionProfiles are only called when the format is supported and no
exceptions are thrown inside worker threads.

---

Nitpick comments:
In `@src/openms/include/OpenMS/IONMOBILITY/IMTypes.h`:
- Around line 77-84: Add full Doxygen blocks for the public conversion helpers:
expand the brief single-line comments above NamesOfIMPeakType, toIMPeakType, and
imPeakTypeToString into repo-standard Doxygen blocks that include `@brief`,
`@param`[in] for im_peak_type (for toIMPeakType) and im_peak_type (for
imPeakTypeToString), `@return` describing the returned value/reference, and
`@throws` describing the behavior when an invalid/unknown peak type string or enum
value is passed; reference the existing symbols NamesOfIMPeakType, toIMPeakType,
and imPeakTypeToString so the docs are clearly tied to those declarations.

In `@src/pyOpenMS/bindings/bind_kernel.cpp`:
- Around line 153-167: The IMPeakType enum binding added to bind_kernel.cpp
should be moved into bind_misc.cpp so the IMTypes.h API and its conversion
helpers remain together; remove the nb::enum_<OpenMS::IMPeakType> block from
bind_kernel.cpp and re-add the same enum registration in bind_misc.cpp alongside
the existing conversion helpers for IMPeakType, ensuring you import or include
OpenMS/IONMOBILITY/IMTypes.h where needed and call .value(...)/.export_values()
exactly as before so the binding API remains identical.

In `@src/tests/class_tests/openms/source/IMTypes_test.cpp`:
- Around line 168-178: The test uses an empty MSSpectrum and empty IM float
array which makes determineIMFormat's behavior ambiguous; modify the fixture to
add a real peak and a matching IM value: create a Peak1 (e.g.,
MSSpectrum::PeakType with m/z and intensity) and push it into the MSSpectrum via
push_back, then add a single float IM value into the FloatDataArray obtained
from s.getFloatDataArrays() (or use fda.push_back(value) before pushing fda into
the spectrum), keep the call to s.setIMPeakType(IMPeakType::IM_CENTROIDED) and
assert IMTypes::determineIMFormat(s) == IMFormat::IM_PEAK so the test is
explicit about having one centroided IM peak.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 34d29cfb-6b74-477c-bae7-7be8f0aa7c01

📥 Commits

Reviewing files that changed from the base of the PR and between aa7ecda and d308662.

📒 Files selected for processing (18)
  • src/openms/include/OpenMS/IONMOBILITY/IMTypes.h
  • src/openms/include/OpenMS/METADATA/SpectrumSettings.h
  • src/openms/source/FEATUREFINDER/Biosaur2Algorithm.cpp
  • src/openms/source/FEATUREFINDER/FeatureFinderAlgorithmMetaboIdent.cpp
  • src/openms/source/FEATUREFINDER/FeatureFinderIdentificationAlgorithm.cpp
  • src/openms/source/FORMAT/BrukerTimsFile.cpp
  • src/openms/source/FORMAT/HANDLERS/MzMLHandler.cpp
  • src/openms/source/IONMOBILITY/IMTypes.cpp
  • src/openms/source/METADATA/SpectrumSettings.cpp
  • src/openms/source/PROCESSING/CENTROIDING/PeakPickerIM.cpp
  • src/pyOpenMS/bindings/bind_kernel.cpp
  • src/pyOpenMS/bindings/bind_misc.cpp
  • src/pyOpenMS/bindings/bind_spectrum.cpp
  • src/pyOpenMS/pxds/IMTypes.pxd
  • src/pyOpenMS/tests/unittests/test_api_missing_enums.py
  • src/tests/class_tests/openms/source/IMTypes_test.cpp
  • src/tests/class_tests/openms/source/MSSpectrum_test.cpp
  • src/topp/PeakPickerIM.cpp

Comment thread src/pyOpenMS/bindings/bind_kernel.cpp Resolved
Comment thread src/pyOpenMS/pxds/IMTypes.pxd Resolved
- MzMLHandler: move IM_PROFILE annotation to after populateSpectraWithData_()
  so containsIMData() sees materialized float arrays
- PeakPickerIM: explicitly set IMFormat::IM_PEAK on output alongside
  IMPeakType::IM_CENTROIDED for consistent metadata
- Biosaur2: require ALL IM spectra centroided (not just any) before skipping
  internal PASEF/TIMS centroiding, to handle mixed groups correctly
- bind_kernel.cpp: remove .export_values() from IMPeakType to avoid
  UNKNOWN namespace collision with IMFormat.UNKNOWN

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
src/openms/source/FEATUREFINDER/Biosaur2Algorithm.cpp (1)

259-285: ⚠️ Potential issue | 🟡 Minor

Don’t stop scanning groups before a concrete IMPeakType is found.

Line 283 still breaks after the first group that merely has IM data. If that group only contains IMPeakType::UNKNOWN, later groups with IM_PROFILE or IM_CENTROIDED never get logged.

Minimal control-flow fix
-  // Log IM peak type if IM data is present.
-  for (const auto& group_pair : groups)
+  // Log the first concrete IM peak type if IM data is present.
+  bool logged_im_peak_type = false;
+  for (const auto& group_pair : groups)
   {
     const MSExperiment& group_exp = group_pair.second;
     bool any_im_array = false;
@@
     if (any_im_array)
     {
       for (const auto& spec : group_exp)
       {
         IMPeakType pt = spec.getIMPeakType();
         if (pt != IMPeakType::UNKNOWN)
         {
           OPENMS_LOG_INFO << "IM peak type: " << imPeakTypeToString(pt) << endl;
+          logged_im_peak_type = true;
           break;
         }
       }
-      break; // Only need to report once
+      if (logged_im_peak_type)
+      {
+        break; // Only need to report once
+      }
     }
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/FEATUREFINDER/Biosaur2Algorithm.cpp` around lines 259 -
285, The current loop over groups stops after the first group that has any IM
data (any_im_array) even if that group's IMPeakType is IMPeakType::UNKNOWN;
update the control flow in the grouping scan so you continue scanning subsequent
groups until you find a concrete IMPeakType (pt != IMPeakType::UNKNOWN) before
breaking. Concretely, in the loop over groups/group_pair/group_exp, remove the
unconditional outer break after checking any_im_array and only break out of both
loops when you log a non-UNKNOWN IMPeakType (i.e., when pt !=
IMPeakType::UNKNOWN after calling spec.getIMPeakType() and logging
imPeakTypeToString(pt)); keep the early break inside the inner loop to stop
scanning specs in that group once a concrete type is found.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@src/openms/source/FEATUREFINDER/Biosaur2Algorithm.cpp`:
- Around line 259-285: The current loop over groups stops after the first group
that has any IM data (any_im_array) even if that group's IMPeakType is
IMPeakType::UNKNOWN; update the control flow in the grouping scan so you
continue scanning subsequent groups until you find a concrete IMPeakType (pt !=
IMPeakType::UNKNOWN) before breaking. Concretely, in the loop over
groups/group_pair/group_exp, remove the unconditional outer break after checking
any_im_array and only break out of both loops when you log a non-UNKNOWN
IMPeakType (i.e., when pt != IMPeakType::UNKNOWN after calling
spec.getIMPeakType() and logging imPeakTypeToString(pt)); keep the early break
inside the inner loop to stop scanning specs in that group once a concrete type
is found.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 99809a28-5dc8-43b9-ad5a-acfa2d2900f9

📥 Commits

Reviewing files that changed from the base of the PR and between d308662 and 15327b1.

📒 Files selected for processing (4)
  • src/openms/source/FEATUREFINDER/Biosaur2Algorithm.cpp
  • src/openms/source/FORMAT/HANDLERS/MzMLHandler.cpp
  • src/openms/source/PROCESSING/CENTROIDING/PeakPickerIM.cpp
  • src/pyOpenMS/bindings/bind_kernel.cpp
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/pyOpenMS/bindings/bind_kernel.cpp
  • src/openms/source/PROCESSING/CENTROIDING/PeakPickerIM.cpp

…troiding

After centroidPASEFData_() completes, set IMPeakType::IM_CENTROIDED on
all IM_PEAK spectra so the skip logic is self-consistent and downstream
consumers see accurate metadata.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
timosachsenberg and others added 2 commits March 26, 2026 16:36
The pxd file was accidentally added. pyOpenMS uses nanobind bindings
(bind_kernel.cpp, bind_misc.cpp), not Cython pxd stubs.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Add @brief, @PARAM[in], @return, @throws tags to toIMPeakType(),
imPeakTypeToString(), setIMPeakType(), and getIMPeakType().

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@timosachsenberg
timosachsenberg merged commit 3f8956f into develop Mar 26, 2026
13 of 14 checks passed
@timosachsenberg
timosachsenberg deleted the refactor/imformat-two-enum branch March 26, 2026 15:43
github-actions Bot pushed a commit that referenced this pull request Mar 28, 2026
Add missing changelog entries for commits after the 2026-03-26 sync:
- #9019: OpenSwathWorkflow direct Bruker .d (TDF) file input
- #9018: IM_PEAK format checks in Resampler, FeatureFinderCentroided, FeatureFinderMultiplex, PeakPickerHiRes
- #9003: TMT 32-plex and 35-plex quantitation support
- #9007: IMPeakType enum added, IMFormat::CENTROIDED deprecated
- #9011: BREAKING IMFormat::MIXED removed; determineIMFormat requires ms_level

Co-authored-by: Copilot <[email protected]>
timosachsenberg pushed a commit that referenced this pull request Mar 28, 2026
Add missing changelog entries for commits after the 2026-03-26 sync:
- #9019: OpenSwathWorkflow direct Bruker .d (TDF) file input
- #9018: IM_PEAK format checks in Resampler, FeatureFinderCentroided, FeatureFinderMultiplex, PeakPickerHiRes
- #9003: TMT 32-plex and 35-plex quantitation support
- #9007: IMPeakType enum added, IMFormat::CENTROIDED deprecated
- #9011: BREAKING IMFormat::MIXED removed; determineIMFormat requires ms_level

Co-authored-by: GitHub Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant