Repository navigation
feat: add Bruker .d file support and built-in IM centroiding to PeakPickerIM - #9022
Conversation
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
📝 WalkthroughWalkthroughTOPPPeakPickerIM was extended to accept Bruker TimsTOF Changes
Sequence DiagramsequenceDiagram
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
Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
src/topp/PeakPickerIM.cpp
| 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); |
There was a problem hiding this comment.
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".
| // 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; | ||
| } |
There was a problem hiding this comment.
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.
| // 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.
There was a problem hiding this comment.
Does the low mem annotate it properly during reading?
There was a problem hiding this comment.
🧩 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.
There was a problem hiding this comment.
♻️ Duplicate comments (3)
src/topp/PeakPickerIM.cpp (3)
304-313:⚠️ Potential issue | 🟠 MajorStill unresolved: require
IM_PEAKbefore callingpickIM*.After the
NONEcheck, 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 | 🟡 MinorStill unresolved: the short descriptions over-promise
.dsupport.These strings still read as unconditional “Bruker .d file” support, but
.dinput is only available inWITH_OPENTIMSbuilds 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 | 🟠 MajorStill unresolved:
processOption=lowmemoryis ignored for.dinput.This branch always materializes the full
PeakMapbeforeprocess_opthas 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
📒 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]>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/topp/PeakPickerIM.cpp (1)
148-150: Unreachable code:spectrumbranch can never execute.Since
setValidStrings_at line 108 only allows{"auto", "frame"},TOPPBaserejects"spectrum"beforegetBrukerConfig_()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
📒 Files selected for processing (1)
src/topp/PeakPickerIM.cpp
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]>
There was a problem hiding this comment.
♻️ Duplicate comments (1)
src/topp/PeakPickerIM.cpp (1)
34-35:⚠️ Potential issue | 🟡 MinorKeep the top-level text aligned with the build guard.
The
@brief, tool summary, andinhelp still read like unconditional Bruker.dfile support, butsetValidFormats_()only exposes.dunderWITH_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\ninstead ofstd::endlin 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::endlfor 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
📒 Files selected for processing (1)
src/topp/PeakPickerIM.cpp
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]>
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
left a comment
There was a problem hiding this comment.
Great feature! Happy to see raw file format support. we can use single cell experiments to compare peak picked mzML of ppIM vs brukers
| "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 " |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
yes these are the defaults. can you open an issue that list what needs better documentation? will do asap
Summary
.ddirect input: PeakPickerIM now accepts Bruker TimsTOF.ddirectories 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 byWITH_OPENTIMS.bruker:ms1_centroid_mz_ppmandbruker:ms1_centroid_im_pctparameters that trigger BrukerTimsFile's built-in IM-dimension centroiding (Sage algorithm, Lazear 2023) directly on the raw gridded TOF data during.dloading. When enabled, this is faster than PeakPickerIM's post-hoc algorithms and the tool skips the redundant PeakPickerIM step.bruker:parameter subsection withexport_mode,calibration_tolerance, andcalibrateoptions, following the same pattern as FileConverter.New parameters (
.dinput only, requiresWITH_OPENTIMS)bruker:export_modeframeauto,spectrum,frame)bruker:calibration_tolerance0.0bruker:calibratefalsebruker:ms1_centroid_mz_ppm0.0bruker:ms1_centroid_im_pct0.0Test plan
WITH_OPENTIMS=ONand verify compilation.ddirectory with default settings (no built-in centroiding) and verify mzML output matches the mzML-input workflowbruker:ms1_centroid_mz_ppm=5.0 bruker:ms1_centroid_im_pct=3.0and verify the built-in centroiding path is taken (check log output)WITH_OPENTIMS=OFFand verify.dformat is not offeredhttps://claude.ai/code/session_01ExrNnWRF9ETqJLmkMpHspr
Summary by CodeRabbit
New Features
Bug Fixes / UX