Repository navigation
Feature/tims calibration tiered - #8999
Conversation
Introduces a three-tier calibration strategy for BrukerTimsFile: Bruker SDK → rational function (TimsCalibration table) → linear. The rational function model is the first open-source implementation to use per-frame calibration from the TimsCalibration table. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
6-task plan covering: Config enums, RationalScan2ImConverter header/impl, unit tests (TDD), tiered fallback wiring, and verification. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…ation to Config Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Implements the RationalScan2ImConverter class that reads per-frame calibration coefficients from the Bruker TimsCalibration table and applies the rational function model (ModelType=2) for scan-to-1/K0 conversion. Includes forward, inverse, and batch conversion methods, singularity guards, and a factory function that reads from SQLite. Also registers the new source file in sources.cmake. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Adds 5 test sections covering forward conversion, round-trip via inverse_convert, per-frame calibration dispatch, description output, and singularity edge cases. Also links opentims_cpp and sqlite3 to the test target for header access, adds missing ProteinIdentification.h include to fix a pre-existing incomplete type error. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…tional > linear) openTimsDataHandle() now implements a three-tier strategy controlled by Config::TimsCalibrationStrategy: attempt Bruker SDK (with optional pressure compensation), fall back to rational model from TimsCalibration table, then fall back to linear (GlobalMetadata). Both load() and transform() pass the caller's Config through to the handle factory. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
📝 WalkthroughWalkthroughThis PR introduces a tiered calibration strategy system for TIMS (Trapped Ion Mobility Spectrometry) conversions, enabling users to select between Bruker SDK, rational-function-based, and linear calibration methods. A new Changes
Sequence Diagram(s)sequenceDiagram
participant Client as Client Code
participant Handle as openTimsDataHandle()
participant SDK as BrukerScan2ImFactory
participant DB as SQLite DB
participant Rational as RationalConverter
participant Linear as LinearConverter
Client->>Handle: load/transform(path, config)
Handle->>Handle: Determine calibration strategy
alt AUTO or BRUKER_SDK strategy
Handle->>SDK: Attempt SDK initialization
alt SDK success
SDK->>Handle: Replace with SDK converter
Handle->>Handle: Log SDK mode
else SDK failure
Handle->>Handle: If BRUKER_SDK, throw; else debug log
end
end
alt AUTO or RATIONAL strategy
Handle->>DB: tryCreateRationalConverter(path)
DB->>DB: Read TimsCalibration table
alt Valid rational data
DB->>Rational: Create converter with coefficients
Rational->>Handle: Return RationalConverter
Handle->>Handle: Replace with Rational converter
else Invalid/missing data
alt RATIONAL strategy
DB->>Handle: throw FileNotReadable
else AUTO strategy
DB->>Handle: Return nullptr, continue
end
end
end
alt No strategy succeeded
Handle->>Linear: Use linear converter
Handle->>Handle: Log linear (GlobalMetadata)
end
Handle->>Client: Return configured TimsDataHandle
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 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: 1
🧹 Nitpick comments (1)
src/openms/source/FORMAT/RationalScan2ImConverter.cpp (1)
47-67: Singularity guards use exact zero comparison.The guards check
== 0.0rather than a tolerance-based near-zero check. This works for the tested edge cases but could miss values very close to zero (e.g.,1e-15) that would still cause numeric instability.Given that:
- These conditions are "physically unreachable" as documented
- The tests verify
std::isfiniteoutput for known edge cases- Real calibration data should never produce near-zero denominators
This is acceptable for the current use case. Consider adding a tolerance-based check if numeric issues are observed in practice.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/FORMAT/RationalScan2ImConverter.cpp` around lines 47 - 67, The singularity guards in RationalScan2ImConverter::applyFormula and ::invertFormula use exact comparisons (e.g., V == 0.0, denom == 0.0, inner_denom == 0.0, slope_denom == 0.0); change these to tolerance-based near-zero checks (e.g., fabs(x) < eps) and replace the value with the small fallback (1e-10) when within that tolerance. Add a local constexpr double eps (e.g., 1e-12) near the start of each function or as a static constant and use it to test V, denom, inner_denom and slope_denom before substituting the guard value.
🤖 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/FORMAT/RationalScan2ImConverter.h`:
- Around line 1-4: Add the missing $Maintainer:$ marker to the header preamble
in RationalScan2ImConverter.h: update the file preamble (above the `#pragma` once
and the existing copyright lines) to include a line containing the
`$Maintainer:$` token so the header complies with the coding guidelines and
identifies the maintainer for the RationalScan2ImConverter declarations.
---
Nitpick comments:
In `@src/openms/source/FORMAT/RationalScan2ImConverter.cpp`:
- Around line 47-67: The singularity guards in
RationalScan2ImConverter::applyFormula and ::invertFormula use exact comparisons
(e.g., V == 0.0, denom == 0.0, inner_denom == 0.0, slope_denom == 0.0); change
these to tolerance-based near-zero checks (e.g., fabs(x) < eps) and replace the
value with the small fallback (1e-10) when within that tolerance. Add a local
constexpr double eps (e.g., 1e-12) near the start of each function or as a
static constant and use it to test V, denom, inner_denom and slope_denom before
substituting the guard value.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e26213ff-e98a-494d-9990-40ba75dfadd6
📒 Files selected for processing (8)
src/openms/include/OpenMS/FORMAT/BrukerTimsFile.hsrc/openms/include/OpenMS/FORMAT/RationalScan2ImConverter.hsrc/openms/include/OpenMS/FORMAT/sources.cmakesrc/openms/source/FORMAT/BrukerTimsFile.cppsrc/openms/source/FORMAT/RationalScan2ImConverter.cppsrc/openms/source/FORMAT/sources.cmakesrc/tests/class_tests/openms/CMakeLists.txtsrc/tests/class_tests/openms/source/BrukerTimsFile_test.cpp
| // Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin | ||
| // SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| #pragma once |
There was a problem hiding this comment.
Add $Maintainer:$ marker to header preamble.
Per coding guidelines, every header file must include the $Maintainer:$ marker in the preamble. This helps identify code ownership for future maintenance.
📝 Suggested fix
// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
// SPDX-License-Identifier: BSD-3-Clause
+//
+// --------------------------------------------------------------------------
+// $Maintainer: Timo Sachsenberg $
+// $Authors: Timo Sachsenberg $
+// --------------------------------------------------------------------------
`#pragma` onceAs per coding guidelines: "Include file preamble with Copyright notice and $Maintainer:$ marker in every header file".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/openms/include/OpenMS/FORMAT/RationalScan2ImConverter.h` around lines 1 -
4, Add the missing $Maintainer:$ marker to the header preamble in
RationalScan2ImConverter.h: update the file preamble (above the `#pragma` once and
the existing copyright lines) to include a line containing the `$Maintainer:$`
token so the header complies with the coding guidelines and identifies the
maintainer for the RationalScan2ImConverter declarations.
Add missing entries for: - #8991: Arrow/Parquet made required dependency; WITH_PARQUET CMake option removed - #8993: BREAKING IMFormat enum rename (CONCATENATED→IM_PEAK, MULTIPLE_SPECTRA→IM_SPECTRUM) - #8997: Fix TOPPView performance regression when right-clicking in large mzML - #8999: BrukerTimsFile tiered scan→1/K0 calibration with RationalScan2ImConverter Co-authored-by: Copilot <[email protected]>
Add missing entries for: - #8991: Arrow/Parquet made required dependency; WITH_PARQUET CMake option removed - #8993: BREAKING IMFormat enum rename (CONCATENATED→IM_PEAK, MULTIPLE_SPECTRA→IM_SPECTRUM) - #8997: Fix TOPPView performance regression when right-clicking in large mzML - #8999: BrukerTimsFile tiered scan→1/K0 calibration with RationalScan2ImConverter Co-authored-by: GitHub Copilot <[email protected]> Co-authored-by: Copilot <[email protected]>
Description
Checklist
How can I get additional information on failed tests during CI
Click to expand
If your PR is failing you can check outIf you click in the column that lists the failed tests you will get detailed error messages.
Advanced commands (admins / reviewer only)
Click to expand
/reformat(experimental) applies the clang-format style changes as additional commit. Note: your branch must have a different name (e.g., yourrepo:feature/XYZ) than the receiving branch (e.g., OpenMS:develop). Otherwise, reformat fails to push.rebuild jenkinswill retrigger Jenkins-based CI buildsSummary by CodeRabbit