Skip to content

feat: add Bruker .d file support and built-in IM centroiding to PeakPickerIM - #9022

Merged
timosachsenberg merged 4 commits into
developfrom
claude/add-d-support-peakpickerim-tAq6T
Mar 28, 2026
Merged

timosachsenberg merged 4 commits into
developfrom
claude/add-d-support-peakpickerim-tAq6T

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Mar 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Bruker .d direct input: PeakPickerIM now accepts Bruker TimsTOF .d directories directly, eliminating the need to convert to mzML via FileConverter first. Uses FRAME export mode by default to get raw per-peak IM data. Guarded by WITH_OPENTIMS.
  • Built-in Sage IM centroiding: Exposes bruker:ms1_centroid_mz_ppm and bruker:ms1_centroid_im_pct parameters that trigger BrukerTimsFile's built-in IM-dimension centroiding (Sage algorithm, Lazear 2023) directly on the raw gridded TOF data during .d loading. When enabled, this is faster than PeakPickerIM's post-hoc algorithms and the tool skips the redundant PeakPickerIM step.
  • Bruker configuration options: Adds a bruker: parameter subsection with export_mode, calibration_tolerance, and calibrate options, following the same pattern as FileConverter.

New parameters (.d input only, requires WITH_OPENTIMS)

Parameter Default Description
bruker:export_mode frame Export mode (auto, spectrum, frame)
bruker:calibration_tolerance 0.0 m/z recalibration tolerance in Da
bruker:calibrate false Enable m/z recalibration
bruker:ms1_centroid_mz_ppm 0.0 IM-centroiding m/z tolerance in ppm (suggested: 5.0)
bruker:ms1_centroid_im_pct 0.0 IM-centroiding IM tolerance in percent (suggested: 3.0)

Test plan

  • Build with WITH_OPENTIMS=ON and verify compilation
  • Run PeakPickerIM on a .d directory with default settings (no built-in centroiding) and verify mzML output matches the mzML-input workflow
  • Run with bruker:ms1_centroid_mz_ppm=5.0 bruker:ms1_centroid_im_pct=3.0 and verify the built-in centroiding path is taken (check log output)
  • Verify existing mzML input paths (inmemory and lowmemory) are unaffected
  • Build with WITH_OPENTIMS=OFF and verify .d format is not offered

https://claude.ai/code/session_01ExrNnWRF9ETqJLmkMpHspr

Summary by CodeRabbit

  • New Features

    • Peak picking now supports Bruker TimsTOF .d directories alongside mzML inputs.
    • New Bruker-specific options for export mode, calibration tolerance/behavior, and MS1 centroiding control.
    • Automatic input-format detection now considers MS1 spectra for format decision and can take a faster path for native Bruker data when centroiding is applied.
  • Bug Fixes / UX

    • Improved error handling for parallel peak-picking with clearer warnings and errors for incompatible ion-mobility formats and required per-peak IM arrays.

claude added 2 commits March 27, 2026 12:00
Allow PeakPickerIM to directly read Bruker TimsTOF .d directories
via BrukerTimsFile, eliminating the need for prior conversion to mzML.
Uses FRAME export mode by default to get raw per-peak IM data.
Includes bruker subsection options (export_mode, calibration_tolerance,
calibrate) guarded by WITH_OPENTIMS.

https://claude.ai/code/session_01ExrNnWRF9ETqJLmkMpHspr
Add bruker:ms1_centroid_mz_ppm and bruker:ms1_centroid_im_pct parameters
to the PeakPickerIM TOPP tool. When both are set > 0, BrukerTimsFile
performs IM-dimension centroiding directly on the raw gridded TOF data
using the Sage algorithm (Lazear 2023), which is faster than the
PeakPickerIM algorithms. The tool detects this and skips the subsequent
PeakPickerIM step since the data is already IM_CENTROIDED.

https://claude.ai/code/session_01ExrNnWRF9ETqJLmkMpHspr
@timosachsenberg timosachsenberg changed the title feat: add Bruker .d file support to PeakPickerIM TOPP tool feat: add Bruker .d file support and built-in IM centroiding to PeakPickerIM Mar 27, 2026
@coderabbitai

coderabbitai Bot commented Mar 27, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

TOPPPeakPickerIM was extended to accept Bruker TimsTOF .d directories (guarded by WITH_OPENTIMS), map new Bruker CLI options into a BrukerTimsFile::Config, detect input type at runtime, load .d via BrukerTimsFile::load(), and route IM-aware peak-picking or passthrough while preserving existing mzML and low-memory paths.

Changes

Cohort / File(s) Summary
Core TOPP tool
src/topp/PeakPickerIM.cpp
Add conditional Bruker support (WITH_OPENTIMS): accept .d inputs, add Bruker CLI subsection and getBrukerConfig_(), detect input type with FileHandler::getType(), load .d via BrukerTimsFile::load(), branch IM-format handling (built-in centroiding passthrough, IM_SPECTRUM error, or parallel PeakPickerIM processing), limit IM-format detection to MS1, and improve per-spectrum exception capture in parallel loop.

Sequence Diagram

sequenceDiagram
    participant CLI as User/CLI
    participant FH as FileHandler
    participant BTF as BrukerTimsFile
    participant IM as IMFormatDetector
    participant PP as PeakPickerIM
    participant MF as MzMLFile

    CLI->>FH: getType(input_file)
    alt Bruker .d input (WITH_OPENTIMS)
        FH-->>CLI: BRUKER_TDF
        CLI->>BTF: load(filepath, config)
        BTF-->>CLI: Experiment (exp)
        CLI->>IM: determineIMFormat(exp, ms_level=1)
        IM-->>CLI: IM format
        alt IM present && centroiding not done
            CLI->>PP: run peak-picking (parallel per-spectrum)
            PP-->>CLI: processed exp
            CLI->>MF: store(output_file)
        else IM absent
            CLI-->>CLI: warn & passthrough store
            CLI->>MF: store(output_file)
        else IM_SPECTRUM
            CLI-->>CLI: error ILLEGAL_PARAMETERS (require per-peak IM_PEAK)
        end
    else non-Bruker (mzML)
        FH-->>CLI: mzML
        CLI->>CLI: existing mzML or low-memory load + PeakPickerIM path
        CLI->>MF: store(output_file)
    end
Loading

Possibly related PRs

Suggested reviewers

  • cbielow

Poem

🐰 I hopped through folders, .d and mzML bright,
Bruker flags tucked in, parsed by moonlight.
Drift times checked, peaks picked in a spin,
Parallel paws racing — results tucked within. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% 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 pull request title accurately and concisely summarizes the two main changes: adding Bruker .d file support and built-in IM centroiding to PeakPickerIM, which align directly with the changeset's primary objectives.

✏️ 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 claude/add-d-support-peakpickerim-tAq6T

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: 3

🤖 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/topp/PeakPickerIM.cpp`:
- Around line 34-35: Update the short descriptions in PeakPickerIM.cpp to match
the build guard: change the `@brief`, the tool summary string, and the "in" help
text so they no longer claim unconditional Bruker .d support but state that .d
(directory) input is available only when built with WITH_OPENTIMS; locate and
edit the `@brief` block and the tool's summary/help strings (the short
description, the tool summary variable, and the "in" parameter help) so they
explicitly mention conditional/OPENTIMS-only support and that .d is a directory
input when OPENTIMS is disabled.
- Around line 268-276: The BRUKER_TDF branch always calls
BrukerTimsFile::load(...) and therefore ignores the processOption "lowmemory",
which forces full in-memory PeakMap creation; modify the BRUKER_TDF handling in
PeakPickerIM.cpp to detect processOption/process_opt == "lowmemory" before
calling BrukerTimsFile::load and either (a) abort with a clear error message
rejecting the combination (preferred) or (b) emit a clear warning that Bruker .d
input is in-memory-only and proceed, then document the behavior; apply the same
guard/behavior to the other Bruker .d handling site (the second BRUKER_TDF
branch later in the file) so both paths consistently handle "lowmemory".
- Around line 278-286: The new branch should require IMFormat::IM_PEAK before
calling the IM peak-picking routines: replace the current check against
IMFormat::NONE with a validation that im_format == IMFormat::IM_PEAK (and treat
any other format, including IM_SPECTRUM, as unsupported), log a warning, write
the input unchanged via MzMLFile().store(output_file, exp) and return
EXECUTION_OK; update the logic around IMTypes::determineIMFormat(exp, 1) and the
subsequent calls to pickIM* (and keep doLowMemAlgorithm() behavior intact) so
that only IM_PEAK is passed into the pickIM* functions.
🪄 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: 39baf165-f8f0-4d9e-bf26-c2511d27d08d

📥 Commits

Reviewing files that changed from the base of the PR and between d360fc6 and 71adab1.

📒 Files selected for processing (1)
  • src/topp/PeakPickerIM.cpp

Comment thread src/topp/PeakPickerIM.cpp Resolved
Comment thread src/topp/PeakPickerIM.cpp
Comment on lines +268 to +276
if (in_type == FileTypes::BRUKER_TDF)
{
// Load .d file using BrukerTimsFile (FRAME mode by default for raw per-peak IM data)
auto bruker_config = getBrukerConfig_();
BrukerTimsFile tims_file;
tims_file.setLogType(log_type_);

PeakMap exp;
tims_file.load(input_file, exp, bruker_config);

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.

⚠️ Potential issue | 🟠 Major

Don't silently ignore processOption=lowmemory for .d input.

This branch returns before the later process_opt split and always calls BrukerTimsFile::load(...), so lowmemory still materializes the full PeakMap. Either reject that combination or warn clearly that Bruker input is in-memory only for now.

🚫 Suggested guard
     if (in_type == FileTypes::BRUKER_TDF)
     {
+      if (process_opt == "lowmemory")
+      {
+        OPENMS_LOG_ERROR << "Error: processOption 'lowmemory' is currently unsupported for Bruker .d input.\n";
+        return ILLEGAL_PARAMETERS;
+      }
+
       // Load .d file using BrukerTimsFile (FRAME mode by default for raw per-peak IM data)
       auto bruker_config = getBrukerConfig_();
       BrukerTimsFile tims_file;

Also applies to: 309-310

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

In `@src/topp/PeakPickerIM.cpp` around lines 268 - 276, The BRUKER_TDF branch
always calls BrukerTimsFile::load(...) and therefore ignores the processOption
"lowmemory", which forces full in-memory PeakMap creation; modify the BRUKER_TDF
handling in PeakPickerIM.cpp to detect processOption/process_opt == "lowmemory"
before calling BrukerTimsFile::load and either (a) abort with a clear error
message rejecting the combination (preferred) or (b) emit a clear warning that
Bruker .d input is in-memory-only and proceed, then document the behavior; apply
the same guard/behavior to the other Bruker .d handling site (the second
BRUKER_TDF branch later in the file) so both paths consistently handle
"lowmemory".

Comment thread src/topp/PeakPickerIM.cpp
Comment on lines +278 to +286
// Check MS1 spectra for IM format
IMFormat im_format = IMTypes::determineIMFormat(exp, 1);
if (im_format == IMFormat::NONE)
{
OPENMS_LOG_WARN << "Warning: Input file does not contain ion mobility data. "
<< "No peak picking will be performed." << std::endl;
MzMLFile().store(output_file, exp);
return EXECUTION_OK;
}

@coderabbitai coderabbitai Bot Mar 27, 2026 •

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.

⚠️ Potential issue | 🟠 Major

Require IM_PEAK before running the picker.

doLowMemAlgorithm() already rejects IM_SPECTRUM, but this new branch only checks NONE. That means any other non-IM_PEAK format can still fall through into pickIM*, which expects per-peak IM arrays.

🧪 Suggested validation
       IMFormat im_format = IMTypes::determineIMFormat(exp, 1);
       if (im_format == IMFormat::NONE)
       {
         OPENMS_LOG_WARN << "Warning: Input file does not contain ion mobility data. "
                         << "No peak picking will be performed." << std::endl;
         MzMLFile().store(output_file, exp);
         return EXECUTION_OK;
       }
+      if (im_format != IMFormat::IM_PEAK)
+      {
+        OPENMS_LOG_ERROR << "Error: PeakPickerIM requires per-peak ion mobility data. "
+                         << "Use bruker:export_mode=frame for Bruker .d input.\n";
+        return ILLEGAL_PARAMETERS;
+      }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Check MS1 spectra for IM format
IMFormat im_format = IMTypes::determineIMFormat(exp, 1);
if (im_format == IMFormat::NONE)
{
OPENMS_LOG_WARN << "Warning: Input file does not contain ion mobility data. "
<< "No peak picking will be performed." << std::endl;
MzMLFile().store(output_file, exp);
return EXECUTION_OK;
}
// Check MS1 spectra for IM format
IMFormat im_format = IMTypes::determineIMFormat(exp, 1);
if (im_format == IMFormat::NONE)
{
OPENMS_LOG_WARN << "Warning: Input file does not contain ion mobility data. "
<< "No peak picking will be performed." << std::endl;
MzMLFile().store(output_file, exp);
return EXECUTION_OK;
}
if (im_format != IMFormat::IM_PEAK)
{
OPENMS_LOG_ERROR << "Error: PeakPickerIM requires per-peak ion mobility data. "
<< "Use bruker:export_mode=frame for Bruker .d input.\n";
return ILLEGAL_PARAMETERS;
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/topp/PeakPickerIM.cpp` around lines 278 - 286, The new branch should
require IMFormat::IM_PEAK before calling the IM peak-picking routines: replace
the current check against IMFormat::NONE with a validation that im_format ==
IMFormat::IM_PEAK (and treat any other format, including IM_SPECTRUM, as
unsupported), log a warning, write the input unchanged via
MzMLFile().store(output_file, exp) and return EXECUTION_OK; update the logic
around IMTypes::determineIMFormat(exp, 1) and the subsequent calls to pickIM*
(and keep doLowMemAlgorithm() behavior intact) so that only IM_PEAK is passed
into the pickIM* functions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Does the low mem annotate it properly during reading?

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.

🧩 Analysis chain

Let me check the IMFormat enum values and IMTypes::determineIMFormat implementation to give you a precise answer.


🏁 Script executed:

#!/bin/bash
# Find IMFormat enum definition
rg -n "enum.*IMFormat|IMFormat" --type=cpp --type=h -C3 | head -80

# Find IMTypes::determineIMFormat implementation
ast-grep --pattern 'IMFormat IMTypes::determineIMFormat($$$)'

# Also look at the header
fd "IMTypes.h" --exec cat {}

Length of output: 10283


@timosachsenberg, there are actually two subtle discrepancies between doLowMemAlgorithm's FormatDetector and the in-memory/Bruker paths:

1. No MS-level filter in FormatDetector

FormatDetector calls IMTypes::determineIMFormat(s) on the first spectrum it encounters, regardless of MS level. The in-memory and Bruker branches both call IMTypes::determineIMFormat(exp, 1) which explicitly filters to MS1 spectra. So if the first spectrum in the file is an MS2 with a single drift-time annotation (IM_SPECTRUM), the low-mem path will incorrectly reject the file even though the MS1 frames may be valid IM_PEAK data.

2. UNKNOWN format silently falls through

The IMFormat enum has a fourth value — UNKNOWN — beyond NONE, IM_PEAK, and IM_SPECTRUM. In the low-mem path, UNKNOWN would pass both guards (IM_SPECTRUM and NONE checks) and proceed to pickIM*, which is likely unintended.


So to answer your question: the low-mem path does not fully annotate/detect the format consistently with the in-memory path. To make all three paths (low-mem, in-memory, Bruker) consistent, the FormatDetector should ideally peek at MS1 spectra only, and all paths should guard against UNKNOWN as well. The minimal fix for the Bruker branch (the original comment) still stands — add the IM_SPECTRUM / IM_PEAK guard — but the low-mem FormatDetector has an analogous MS-level filtering gap worth addressing too.


🧠 Learnings used
Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8975
File: src/openms/source/FORMAT/BrukerTimsFile.cpp:559-568
Timestamp: 2026-03-24T08:16:16.811Z
Learning: In OpenMS BrukerTimsFile.cpp (WITH_OPENTIMS), the correct PSI-MS CV term for Bruker TimsTOF TDF nativeID format is MS:1002818 ("Bruker TDF nativeID format"), not MS:1000776 ("scan number only nativeID format"). The mandated nativeID string pattern for MS:1002818 is `frame=<FRAME_ID> scan=<SCAN_ID>`. The SourceFile metadata call should use setNativeIDTypeAccession("MS:1002818") and setNativeIDType("Bruker TDF nativeID format").

Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-03-01T16:48:31.781Z
Learning: Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification) and follow established error handling patterns using OpenMS logging mechanisms

Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-25T11:21:29.196Z
Learning: Applies to src/topp/*.cpp : New TOPP tools must be registered in `src/topp/executables.cmake` and `src/openms/source/APPLICATIONS/ToolHandler.cpp`

Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: src/pyOpenMS/CLAUDE.md:0-0
Timestamp: 2026-03-25T11:20:31.622Z
Learning: Applies to src/pyOpenMS/bindings/bind_*.cpp : 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

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: jpfeuffer
Repo: OpenMS/OpenMS PR: 8857
File: src/pyOpenMS/bindings/bind_spectrum.cpp:194-219
Timestamp: 2026-03-09T21:20:14.308Z
Learning: In pyOpenMS nanobind bindings under src/pyOpenMS/bindings/*.cpp, when implementing get_peaks_struct methods for MSSpectrum, MSChromatogram, and Mobilogram, use the nb::object self_obj pattern: the lambda takes nb::object self_obj, casts it to the concrete class reference inside (e.g., auto& self = nb::cast<OpenMS::MSSpectrum&>(self_obj);), and passes self_obj as the owner to the nb::ndarray constructor instead of nb::find(self). This ensures correct lifetime management, consistent with the _get_peaks_view pattern.

Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-03-01T16:48:31.781Z
Learning: Be mindful of memory usage when processing large datasets, consider algorithmic complexity for data processing operations, and use appropriate OpenMS containers and algorithms

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.

Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8177
File: src/openms/source/FORMAT/HANDLERS/MzMLHandler.cpp:5069-5074
Timestamp: 2025-12-04T16:25:07.026Z
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: CR
Repo: OpenMS/OpenMS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-25T11:21:29.196Z
Learning: Applies to src/topp/*.cpp : Document TOPP tools and add them to `doc/doxygen/public/TOPP.doxygen` where applicable

Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-03-01T16:48:31.781Z
Learning: Applies to src/openms/include/OpenMS/**/*.h : Add Doxygen comments for new public methods and classes, and update relevant documentation when modifying existing functionality

Learnt from: timosachsenberg
Repo: OpenMS/OpenMS PR: 8841
File: src/topp/MascotAdapterOnline.cpp:143-145
Timestamp: 2026-03-06T11:18:36.359Z
Learning: In OpenMS, for MascotAdapterOnline.cpp and similar TOPP tools, paths created with File::getTempDirectory() + File::getUniqueName() are ASCII-only. Wrapping them with std::filesystem::path for Unicode/non-ASCII safety is unnecessary and should not be flagged during code reviews. Apply this guidance to all TOPP tools under src/topp. If a non-ASCII path handling is actually needed elsewhere, handle it explicitly there.

@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 (3)
src/topp/PeakPickerIM.cpp (3)

304-313: ⚠️ Potential issue | 🟠 Major

Still unresolved: require IM_PEAK before calling pickIM*.

After the NONE check, other layouts can still fall through into the picker, which expects per-peak IM arrays here.

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

In `@src/topp/PeakPickerIM.cpp` around lines 304 - 313, The code only checks for
IMFormat::NONE but must require IMFormat::IM_PEAK before invoking the IM
peak-picking routines; update the logic around IMTypes::determineIMFormat(exp,
1) to explicitly verify im_format == IMFormat::IM_PEAK (not just != NONE) and,
if not IM_PEAK, log the same warning, write output with
MzMLFile().store(output_file, exp) and return EXECUTION_OK so pickIM*
(pickIMPeak / other pickIM* functions) never run on layouts without per-peak IM
arrays.

34-35: ⚠️ Potential issue | 🟡 Minor

Still unresolved: the short descriptions over-promise .d support.

These strings still read as unconditional “Bruker .d file” support, but .d input is only available in WITH_OPENTIMS builds and the input is a directory, not a file.

Also applies to: 76-82

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

In `@src/topp/PeakPickerIM.cpp` around lines 34 - 35, Update the short
descriptions in PeakPickerIM.cpp to avoid implying unconditional Bruker .d file
support: change occurrences of the `@brief` and other summary strings that say
“Bruker .d file” to indicate “Bruker .d directories (available only when built
with WITH_OPENTIMS)” and clarify input is a directory, not a file; ensure both
the header/brief text and any other short summary strings in the file use this
conditional wording so the docs match actual WITH_OPENTIMS build behavior.

280-287: ⚠️ Potential issue | 🟠 Major

Still unresolved: processOption=lowmemory is ignored for .d input.

This branch always materializes the full PeakMap before process_opt has any effect, so large Bruker runs silently fall back to in-memory processing.

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

In `@src/topp/PeakPickerIM.cpp` around lines 280 - 287, The BRUKER_TDF branch
unconditionally builds a full PeakMap via PeakMap exp and
tims_file.load(input_file, exp, ...) which ignores process_opt (e.g.,
processOption=lowmemory); change the flow to check process_opt before
materializing PeakMap and, when lowmemory is requested, use the BrukerTimsFile
streaming/on-disk API instead of tims_file.load (for example call a non-loading
open/iterate method on BrukerTimsFile or a load overload that takes process
options) so you never construct PeakMap exp in that case; keep the existing
getBrukerConfig_(), BrukerTimsFile tims_file, and
tims_file.setLogType(log_type_) usage but replace tims_file.load(input_file,
exp, bruker_config) with the low-memory code path when process_opt indicates
lowmemory.
🤖 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/topp/PeakPickerIM.cpp`:
- Around line 304-313: The code only checks for IMFormat::NONE but must require
IMFormat::IM_PEAK before invoking the IM peak-picking routines; update the logic
around IMTypes::determineIMFormat(exp, 1) to explicitly verify im_format ==
IMFormat::IM_PEAK (not just != NONE) and, if not IM_PEAK, log the same warning,
write output with MzMLFile().store(output_file, exp) and return EXECUTION_OK so
pickIM* (pickIMPeak / other pickIM* functions) never run on layouts without
per-peak IM arrays.
- Around line 34-35: Update the short descriptions in PeakPickerIM.cpp to avoid
implying unconditional Bruker .d file support: change occurrences of the `@brief`
and other summary strings that say “Bruker .d file” to indicate “Bruker .d
directories (available only when built with WITH_OPENTIMS)” and clarify input is
a directory, not a file; ensure both the header/brief text and any other short
summary strings in the file use this conditional wording so the docs match
actual WITH_OPENTIMS build behavior.
- Around line 280-287: The BRUKER_TDF branch unconditionally builds a full
PeakMap via PeakMap exp and tims_file.load(input_file, exp, ...) which ignores
process_opt (e.g., processOption=lowmemory); change the flow to check
process_opt before materializing PeakMap and, when lowmemory is requested, use
the BrukerTimsFile streaming/on-disk API instead of tims_file.load (for example
call a non-loading open/iterate method on BrukerTimsFile or a load overload that
takes process options) so you never construct PeakMap exp in that case; keep the
existing getBrukerConfig_(), BrukerTimsFile tims_file, and
tims_file.setLogType(log_type_) usage but replace tims_file.load(input_file,
exp, bruker_config) with the low-memory code path when process_opt indicates
lowmemory.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 89ab8664-7c75-4c61-94ec-cd82ccbe82e7

📥 Commits

Reviewing files that changed from the base of the PR and between 71adab1 and 181d667.

📒 Files selected for processing (1)
  • src/topp/PeakPickerIM.cpp

- Remove 'spectrum' from bruker:export_mode valid strings (produces
  IM_SPECTRUM format incompatible with PeakPickerIM)
- Add IM_SPECTRUM format rejection with clear error message
- Warn when lowmemory option is ignored for .d input

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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/topp/PeakPickerIM.cpp (1)

148-150: Unreachable code: spectrum branch can never execute.

Since setValidStrings_ at line 108 only allows {"auto", "frame"}, TOPPBase rejects "spectrum" before getBrukerConfig_() is called. The mapping at line 148 is dead code.

♻️ Suggested cleanup
     String mode = getStringOption_("bruker:export_mode");
-    if (mode == "spectrum") c.export_mode = BrukerTimsFile::Config::SPECTRUM;
-    else if (mode == "frame") c.export_mode = BrukerTimsFile::Config::FRAME;
+    if (mode == "frame") c.export_mode = BrukerTimsFile::Config::FRAME;
     else c.export_mode = BrukerTimsFile::Config::AUTO;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/topp/PeakPickerIM.cpp` around lines 148 - 150, The "spectrum" branch in
getBrukerConfig_ is unreachable because setValidStrings_ only allows
{"auto","frame"}, so remove the dead branch: in the function that sets
c.export_mode (getBrukerConfig_) delete the if (mode == "spectrum") ... case and
simplify to if (mode == "frame") c.export_mode = BrukerTimsFile::Config::FRAME;
else c.export_mode = BrukerTimsFile::Config::AUTO; (or alternatively, if you
intend to support "spectrum", add "spectrum" to setValidStrings_ and TOPP option
validation instead of keeping the dead SPECTRUM mapping).
🤖 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/topp/PeakPickerIM.cpp`:
- Around line 106-108: The help text for the 'bruker:export_mode' option in
registerStringOption_ mentions a non-existent 'spectrum' mode; update the help
string in PeakPickerIM.cpp (the registerStringOption_ call for
"bruker:export_mode") to remove the "'spectrum' forces per-precursor MS2 spectra
(DDA-style)," clause so the description only documents supported modes (e.g.,
auto and frame) consistent with setValidStrings_.

---

Nitpick comments:
In `@src/topp/PeakPickerIM.cpp`:
- Around line 148-150: The "spectrum" branch in getBrukerConfig_ is unreachable
because setValidStrings_ only allows {"auto","frame"}, so remove the dead
branch: in the function that sets c.export_mode (getBrukerConfig_) delete the if
(mode == "spectrum") ... case and simplify to if (mode == "frame") c.export_mode
= BrukerTimsFile::Config::FRAME; else c.export_mode =
BrukerTimsFile::Config::AUTO; (or alternatively, if you intend to support
"spectrum", add "spectrum" to setValidStrings_ and TOPP option validation
instead of keeping the dead SPECTRUM mapping).
🪄 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: cfbbc04f-d3c1-4c92-80d8-20f768d3c3cf

📥 Commits

Reviewing files that changed from the base of the PR and between 181d667 and f3925fc.

📒 Files selected for processing (1)
  • src/topp/PeakPickerIM.cpp

Comment thread src/topp/PeakPickerIM.cpp Resolved
Address CodeRabbit review feedback and fix pre-existing issues:
- Remove unavailable 'spectrum' export mode from help text and dead code path
- Fix FormatDetector to filter by MS1 level only (consistent with in-memory paths)
- Add missing IM_SPECTRUM rejection to in-memory mzML path
- Unify error messages across all three code paths (Bruker, in-memory, low-memory)
- Wrap OMP parallel loops in try/catch to prevent std::terminate on picker exceptions

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/topp/PeakPickerIM.cpp (1)

34-35: ⚠️ Potential issue | 🟡 Minor

Keep the top-level text aligned with the build guard.

The @brief, tool summary, and in help still read like unconditional Bruker .d file support, but setValidFormats_() only exposes .d under WITH_OPENTIMS, and the input is a directory here.

Also applies to: 76-82

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

In `@src/topp/PeakPickerIM.cpp` around lines 34 - 35, The tool help text in
PeakPickerIM.cpp (e.g., the top-level `@brief`, the tool summary and the "in"
option help) incorrectly reads as if Bruker .d directory input is always
supported while setValidFormats_() only adds ".d" under the WITH_OPENTIMS build
guard; update those help strings (inside the PeakPickerIM class where
registerOptionsAndFlags_()/setValidFormats_() set descriptions) to either wrap
the Bruker/.d wording in the same `#ifdef` WITH_OPENTIMS guard or change the text
to say ".d directories supported when built with WITH_OPENTIMS" and clarify that
the input may be a directory, and apply the same fix to the other occurrences
around the 76-82 region.
🧹 Nitpick comments (1)
src/topp/PeakPickerIM.cpp (1)

240-241: Use \n instead of std::endl in the new log lines.

These paths do not need an extra flush, and the repo style already prefers plain newlines for logging.

As per coding guidelines "Avoid std::endl for performance; prefer \n".

Also applies to: 282-283, 299-302, 319-321, 371-372

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

In `@src/topp/PeakPickerIM.cpp` around lines 240 - 241, The new logging uses
std::endl which forces a flush; replace all occurrences of std::endl in the
PeakPickerIM logging lines with "\n" (e.g., change OPENMS_LOG_ERROR << "..."<<
std::endl; to OPENMS_LOG_ERROR << "...\n";) for the reported messages (the
IM_SPECTRUM/IM_PEAK error and the other log lines referenced around the
PeakPickerIM code paths) so they use plain newlines and follow the repo style;
update each OPENMS_LOG_* statement in the PeakPickerIM.cpp blocks (including the
lines near the current diff and the other occurrences mentioned) accordingly.
🤖 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/topp/PeakPickerIM.cpp`:
- Around line 34-35: The tool help text in PeakPickerIM.cpp (e.g., the top-level
`@brief`, the tool summary and the "in" option help) incorrectly reads as if
Bruker .d directory input is always supported while setValidFormats_() only adds
".d" under the WITH_OPENTIMS build guard; update those help strings (inside the
PeakPickerIM class where registerOptionsAndFlags_()/setValidFormats_() set
descriptions) to either wrap the Bruker/.d wording in the same `#ifdef`
WITH_OPENTIMS guard or change the text to say ".d directories supported when
built with WITH_OPENTIMS" and clarify that the input may be a directory, and
apply the same fix to the other occurrences around the 76-82 region.

---

Nitpick comments:
In `@src/topp/PeakPickerIM.cpp`:
- Around line 240-241: The new logging uses std::endl which forces a flush;
replace all occurrences of std::endl in the PeakPickerIM logging lines with "\n"
(e.g., change OPENMS_LOG_ERROR << "..."<< std::endl; to OPENMS_LOG_ERROR <<
"...\n";) for the reported messages (the IM_SPECTRUM/IM_PEAK error and the other
log lines referenced around the PeakPickerIM code paths) so they use plain
newlines and follow the repo style; update each OPENMS_LOG_* statement in the
PeakPickerIM.cpp blocks (including the lines near the current diff and the other
occurrences mentioned) accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 63e3447e-0299-4369-ae1a-4551bb7bfb04

📥 Commits

Reviewing files that changed from the base of the PR and between f3925fc and 317b976.

📒 Files selected for processing (1)
  • src/topp/PeakPickerIM.cpp

@timosachsenberg
timosachsenberg merged commit b88276d into develop Mar 28, 2026
40 of 41 checks passed
@timosachsenberg
timosachsenberg deleted the claude/add-d-support-peakpickerim-tAq6T branch March 28, 2026 20:43
github-actions Bot pushed a commit that referenced this pull request Mar 29, 2026
Add PeakPickerIM entry for PR #9022:
- Direct Bruker TimsTOF .d directory input support
- Built-in Sage IM centroiding parameters
- IM_SPECTRUM format rejection

Co-authored-by: Copilot <[email protected]>
timosachsenberg pushed a commit that referenced this pull request Mar 29, 2026
Add PeakPickerIM entry for PR #9022:
- Direct Bruker TimsTOF .d directory input support
- Built-in Sage IM centroiding parameters
- IM_SPECTRUM format rejection

Co-authored-by: GitHub Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>

@alhigaylan alhigaylan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Great feature! Happy to see raw file format support. we can use single cell experiments to compare peak picked mzML of ppIM vs brukers

Comment thread src/topp/PeakPickerIM.cpp
"When enabled, this replaces the PeakPickerIM algorithm for MS1 frames.", false, true);
setMinFloat_("bruker:ms1_centroid_mz_ppm", 0.0);
registerDoubleOption_("bruker:ms1_centroid_im_pct", "<float>", 0.0,
"MS1 frame IM-centroiding ion mobility tolerance in percent. Both this and ms1_centroid_mz_ppm "

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we need to do better in the documentation of these parameters. For example, ms1_centroid_im_pct -- what percent is it referring to.

Are the default parameters taken from Sage implementation?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes these are the defaults. can you open an issue that list what needs better documentation? will do asap

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.

3 participants