Repository navigation
Add imaging mass spectrometry data structures (IonImage, MSImagingGeometry, MSImagingExperiment) - #9381
Conversation
Introduces a new OpenMS/IMAGING module so the rest of the imaging MS work (Phase 2: ImzMLFile, etc.) has an in-memory target to populate. - IonImage: dense W x H x D intensity grid with per-pixel validity mask and the m/z window the image was extracted from. - MSImagingGeometry: pixel list and (x,y,z) -> spectrum_index lookup, with image dimensions and pixel-size metadata. Coordinates are zero-based; bit-packed into a 21/21/21 uint64 key for the lookup, with out-of-range and duplicate insertions rejected up-front. - MSImagingExperiment: owns an MSExperiment and an MSImagingGeometry, exposes pixel-based spectrum access, sum-based ion-image extraction reusing MSSpectrum::MZBegin/MZEnd, and a basic validate() check. Registered via existing sources.cmake pattern (peer to IONMOBILITY) and covered by three class tests under src/tests/class_tests/openms/source.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds three 2D imaging classes: MSImagingGeometry (pixel grid + mapping), IonImage (dense 2D intensity grid with validity mask), and MSImagingExperiment (owns experiment+geometry and extracts ion images by m/z ppm window). Includes unit tests and CMake build wiring. ChangesImaging Data Types and Operations
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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
🧹 Nitpick comments (6)
src/openms/include/OpenMS/IMAGING/IonImage.h (1)
33-68: ⚡ Quick winAlign public method docs with required Doxygen tag structure.
Public APIs here should use full Doxygen blocks including
@param[in]and@returntags (and@throwswhere applicable) to match the project documentation contract.As per coding guidelines "Method documentation must include
@brief, parameter documentation with[in],[out], or[in,out]direction tags,@returnfor return values,@throwsfor exceptions".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/openms/include/OpenMS/IMAGING/IonImage.h` around lines 33 - 68, Update the Doxygen comments for all public methods in IonImage (resize, getWidth, getHeight, getDepth, hasPixel, getIntensity (both overloads), setIntensity (both overloads), setMzRange, getMzRange, getData, getValidity) to use full Doxygen blocks that include `@brief`, `@param`[in]/@param[out] (with directions for x,y,z,width,height,depth,intensity,range where applicable), `@return` for non-void functions, and `@throws` for methods that can throw (e.g., getIntensity, setIntensity should document Exception::IndexOverflow); ensure each method’s comment documents parameter directions and the return value consistently with the project guideline.src/openms/include/OpenMS/IMAGING/MSImagingGeometry.h (1)
41-84: ⚡ Quick winComplete Doxygen contract tags for public API methods.
Most public declarations here have brief comments but are missing required
@paramdirection tags and@returntags, and exception-bearing APIs should keep explicit@throwstags in full Doxygen method blocks for consistency with project docs policy.As per coding guidelines "Method documentation must include
@brief, parameter documentation with[in],[out], or[in,out]direction tags,@returnfor return values,@throwsfor exceptions".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/openms/include/OpenMS/IMAGING/MSImagingGeometry.h` around lines 41 - 84, The Doxygen comments for the public API methods (setDimensions, getWidth, getHeight, getDepth, setPixelSize, getPixelSizeX, getPixelSizeY, getPixelSizeZ, getPixelSizeUnit, both addPixel overloads, hasPixel, getSpectrumIndex, getPixels, getNumberOfPixels, clear) are missing formal `@param` direction tags and `@return` tags and some exception-bearing APIs need explicit `@throws` blocks; update each method's Doxygen to include a `@brief`, add `@param` entries with [in] or [out] (e.g., parameters x, y, z, width, height, depth, unit, spectrum_index), add `@return` for non-void accessors (getWidth/getHeight/getDepth/getPixelSizeX/.../getSpectrumIndex/getNumberOfPixels/getPixels/getPixelSizeUnit), and ensure `@throws` Exception::InvalidValue or Exception::ElementNotFound are present where noted (both addPixel overloads and getSpectrumIndex), keeping wording consistent with project docs policy.src/openms/include/OpenMS/IMAGING/MSImagingExperiment.h (1)
31-87: ⚡ Quick winBring public API docs to full Doxygen spec.
Please expand method docs with explicit
@param[in],@return, and complete exception docs where relevant; current comments are clear but not in the required full format for exported header APIs.As per coding guidelines "Method documentation must include
@brief, parameter documentation with[in],[out], or[in,out]direction tags,@returnfor return values,@throwsfor exceptions".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/openms/include/OpenMS/IMAGING/MSImagingExperiment.h` around lines 31 - 87, Update the Doxygen comments for all public methods in MSImagingExperiment to the full API spec: add `@brief` where missing and for each method include explicit `@param`[in] (or [out]/[in,out]) tags for parameters (e.g., getSpectrum(UInt x, UInt y, UInt z = 0), hasPixel(UInt x, UInt y, UInt z), extractIonImage(double mz, double tolerance_ppm), setMSExperiment(MSExperiment exp), setGeometry(MSImagingGeometry geom)), add `@return` describing the returned object for getters (getMSExperiment, getGeometry, getNumberOfPixels, getNumberOfSpectra, getSpectrum, extractIonImage), and expand `@throws` to list specific exceptions and the conditions that trigger them (e.g., getSpectrum and const getSpectrum: Exception::ElementNotFound if pixel missing; extractIonImage: Exception::InvalidValue and Exception::IndexOverflow with exact preconditions; validate: Exception::InvalidValue). Ensure parameter directions use [in]/[out]/[in,out] and that the brief/params/return/throws formatting matches project Doxygen guidelines.src/tests/class_tests/openms/source/MSImagingExperiment_test.cpp (3)
36-53: ⚡ Quick winAdd test coverage for 3D imaging functionality.
The fixture and all tests operate only in 2D (z=0 or omitted). Since the PR summary explicitly states "All structures support 3D (z-axis) volumetric imaging," add at least one test that verifies 3D functionality by setting depth > 1, adding pixels with z != 0, and exercising
hasPixel,getSpectrum, andextractIonImagewith 3D coordinates.🧪 Suggested 3D test fixture
Consider adding a helper that creates a simple 3D fixture:
// Add after makeFixture(): // 2x2x2 grid with one spectrum per z-layer for testing 3D operations. MSImagingExperiment makeFixture3D() { MSExperiment exp; exp.addSpectrum(makeSpec({{500.0, 50.0}})); // z=0 exp.addSpectrum(makeSpec({{500.0, 75.0}})); // z=1 MSImagingGeometry geom; geom.setDimensions(2, 2, 2); geom.addPixel(0, 0, 0, 0); // x=0, y=0, z=0, spectrum=0 geom.addPixel(0, 0, 1, 1); // x=0, y=0, z=1, spectrum=1 MSImagingExperiment mie; mie.setMSExperiment(std::move(exp)); mie.setGeometry(std::move(geom)); return mie; }Then add a test section:
START_SECTION((3D imaging operations)) { MSImagingExperiment mie = makeFixture3D(); TEST_EQUAL(mie.getGeometry().getDepth(), 2u) TEST_EQUAL(mie.hasPixel(0, 0, 1), true) TEST_EQUAL(mie.getSpectrum(0, 0, 1).size(), 1u) IonImage img = mie.extractIonImage(500.0, 100.0); TEST_EQUAL(img.getDepth(), 2u) TEST_EQUAL(img.hasPixel(0, 0, 0), true) TEST_EQUAL(img.hasPixel(0, 0, 1), true) TEST_REAL_SIMILAR(img.getIntensity(0, 0, 0), 50.0) TEST_REAL_SIMILAR(img.getIntensity(0, 0, 1), 75.0) } END_SECTION🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/tests/class_tests/openms/source/MSImagingExperiment_test.cpp` around lines 36 - 53, Tests currently only cover 2D use; add a 3D fixture and test to exercise z-axis behavior. Create a new helper (e.g., makeFixture3D) that builds an MSExperiment with two spectra (one per z-layer), set MSImagingGeometry dimensions with depth>1 (e.g., setDimensions(2,2,2)), add pixels including z!=0 via MSImagingGeometry::addPixel, then add a START_SECTION that uses MSImagingExperiment::hasPixel, getSpectrum(x,y,z) and extractIonImage(...) to assert depth, pixel presence, and per-z intensities (use getDepth/getIntensity or equivalent) to verify 3D extraction works.
169-193: 💤 Low valueConsider adding edge-case tests for
extractIonImage.The current test covers the typical use case well. To increase robustness, consider adding tests for edge cases such as:
- Extracting from an empty
MSImagingExperiment(zero spectra/pixels)- Using zero or very small tolerance values
- Using an m/z far outside the range of all spectra
- Verifying behavior when all pixels have zero intensity in the window
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/tests/class_tests/openms/source/MSImagingExperiment_test.cpp` around lines 169 - 193, Add unit tests exercising extractIonImage on edge cases: create an empty MSImagingExperiment (use makeFixture or a new helper) and assert extractIonImage(...) returns an IonImage with zero width/height or no pixels and sensible mz range; call extractIonImage with tolerance_ppm = 0 and a very small tolerance and assert only exact-matching mzs contribute (use hasPixel/getIntensity to verify); call extractIonImage with an mz far outside any spectrum and assert all pixels are absent or zero intensity; and add a case where all spectra have zero intensity inside the window and verify getIntensity returns 0 for present pixels and getMzRange reflects the requested window. Ensure tests reference extractIonImage, MSImagingExperiment, IonImage, hasPixel, getIntensity and getMzRange to locate code under test.
1-210: 💤 Low valueAdd inline comments to meet coding guideline.
The file has very few inline comments. As per coding guidelines, code comments should comprise at least ~5% of the code (~10-11 lines for this file). Consider adding brief comments explaining the test setup and expected behavior, particularly for:
- The makeFixture() helper (explaining the 2x2 grid layout and missing pixel)
- The extractIonImage test (explaining the ppm calculation and expected intensity aggregation)
- The validate test (explaining what makes the fixture consistent vs. inconsistent)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/tests/class_tests/openms/source/MSImagingExperiment_test.cpp` around lines 1 - 210, Add inline comments (~10–11 lines total, ~5% of file) explaining test setup and expectations: annotate makeFixture() to state it builds a 2x2 grid with pixel (1,1) intentionally missing and which spectra map to which pixels; in the extractIonImage test (reference extractIonImage) add a brief note showing the ppm calculation (200 ppm @ 500 Da → dm = 0.1 → window [499.9, 500.1]) and why intensities are 30.0, 0.0, and 100.0 for the respective pixels; in the validate test (reference validate) comment that the fixture is consistent, then explain that adding a pixel with spectrum index 999 maps to a non-existent spectrum and should throw Exception::InvalidValue. Keep comments short, inline, and focused on intent so they meet the coding-guideline coverage target.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/openms/source/IMAGING/MSImagingExperiment.cpp`:
- Around line 73-80: MSImagingExperiment::extractIonImage must validate inputs
before computing dm/mz range: check that mz and tolerance_ppm are finite (not
NaN/inf), that mz > 0 and tolerance_ppm >= 0; if any check fails, throw a clear
std::invalid_argument (or similar) describing the bad parameter(s) instead of
proceeding to compute dm/mz_lo/mz_hi and calling image.setMzRange; add these
checks at the top of extractIonImage to prevent inverted/invalid windows.
- Around line 63-71: Guard the spectrum index returned by
geometry_.getSpectrumIndex(x, y, z) before using it to access experiment_ in
both MSImagingExperiment::getSpectrum overloads: compute the index into a
variable, check that it is less than experiment_.size() (or use
experiment_.empty() and size checks), and if out of range throw a descriptive
exception (e.g., std::out_of_range with context including x,y,z and the index)
instead of performing unchecked operator[] access; update both the non-const and
const getSpectrum methods to perform the same check and then return
experiment_.at(index) or experiment_[index] after validation.
In `@src/openms/source/IMAGING/MSImagingGeometry.cpp`:
- Around line 76-97: In MSImagingGeometry::addPixel, add explicit bounds checks
against the configured geometry dimensions (width_, height_, depth_) before
computing packKey_ or inserting into lookup_/pixels_; if x >= width_ or y >=
height_ or z >= depth_ (or if any dimension is zero/unspecified as appropriate)
throw Exception::InvalidValue with a clear message like "Pixel coordinate
outside configured geometry bounds" and include
String(x)+","+String(y)+","+String(z) to match existing error formatting; keep
the existing duplicate and bit-pack checks and only proceed to call packKey_,
lookup_.emplace and pixels_.push_back when the coordinate passes the bounds
check.
---
Nitpick comments:
In `@src/openms/include/OpenMS/IMAGING/IonImage.h`:
- Around line 33-68: Update the Doxygen comments for all public methods in
IonImage (resize, getWidth, getHeight, getDepth, hasPixel, getIntensity (both
overloads), setIntensity (both overloads), setMzRange, getMzRange, getData,
getValidity) to use full Doxygen blocks that include `@brief`,
`@param`[in]/@param[out] (with directions for
x,y,z,width,height,depth,intensity,range where applicable), `@return` for non-void
functions, and `@throws` for methods that can throw (e.g., getIntensity,
setIntensity should document Exception::IndexOverflow); ensure each method’s
comment documents parameter directions and the return value consistently with
the project guideline.
In `@src/openms/include/OpenMS/IMAGING/MSImagingExperiment.h`:
- Around line 31-87: Update the Doxygen comments for all public methods in
MSImagingExperiment to the full API spec: add `@brief` where missing and for each
method include explicit `@param`[in] (or [out]/[in,out]) tags for parameters
(e.g., getSpectrum(UInt x, UInt y, UInt z = 0), hasPixel(UInt x, UInt y, UInt
z), extractIonImage(double mz, double tolerance_ppm),
setMSExperiment(MSExperiment exp), setGeometry(MSImagingGeometry geom)), add
`@return` describing the returned object for getters (getMSExperiment,
getGeometry, getNumberOfPixels, getNumberOfSpectra, getSpectrum,
extractIonImage), and expand `@throws` to list specific exceptions and the
conditions that trigger them (e.g., getSpectrum and const getSpectrum:
Exception::ElementNotFound if pixel missing; extractIonImage:
Exception::InvalidValue and Exception::IndexOverflow with exact preconditions;
validate: Exception::InvalidValue). Ensure parameter directions use
[in]/[out]/[in,out] and that the brief/params/return/throws formatting matches
project Doxygen guidelines.
In `@src/openms/include/OpenMS/IMAGING/MSImagingGeometry.h`:
- Around line 41-84: The Doxygen comments for the public API methods
(setDimensions, getWidth, getHeight, getDepth, setPixelSize, getPixelSizeX,
getPixelSizeY, getPixelSizeZ, getPixelSizeUnit, both addPixel overloads,
hasPixel, getSpectrumIndex, getPixels, getNumberOfPixels, clear) are missing
formal `@param` direction tags and `@return` tags and some exception-bearing APIs
need explicit `@throws` blocks; update each method's Doxygen to include a `@brief`,
add `@param` entries with [in] or [out] (e.g., parameters x, y, z, width, height,
depth, unit, spectrum_index), add `@return` for non-void accessors
(getWidth/getHeight/getDepth/getPixelSizeX/.../getSpectrumIndex/getNumberOfPixels/getPixels/getPixelSizeUnit),
and ensure `@throws` Exception::InvalidValue or Exception::ElementNotFound are
present where noted (both addPixel overloads and getSpectrumIndex), keeping
wording consistent with project docs policy.
In `@src/tests/class_tests/openms/source/MSImagingExperiment_test.cpp`:
- Around line 36-53: Tests currently only cover 2D use; add a 3D fixture and
test to exercise z-axis behavior. Create a new helper (e.g., makeFixture3D) that
builds an MSExperiment with two spectra (one per z-layer), set MSImagingGeometry
dimensions with depth>1 (e.g., setDimensions(2,2,2)), add pixels including z!=0
via MSImagingGeometry::addPixel, then add a START_SECTION that uses
MSImagingExperiment::hasPixel, getSpectrum(x,y,z) and extractIonImage(...) to
assert depth, pixel presence, and per-z intensities (use getDepth/getIntensity
or equivalent) to verify 3D extraction works.
- Around line 169-193: Add unit tests exercising extractIonImage on edge cases:
create an empty MSImagingExperiment (use makeFixture or a new helper) and assert
extractIonImage(...) returns an IonImage with zero width/height or no pixels and
sensible mz range; call extractIonImage with tolerance_ppm = 0 and a very small
tolerance and assert only exact-matching mzs contribute (use
hasPixel/getIntensity to verify); call extractIonImage with an mz far outside
any spectrum and assert all pixels are absent or zero intensity; and add a case
where all spectra have zero intensity inside the window and verify getIntensity
returns 0 for present pixels and getMzRange reflects the requested window.
Ensure tests reference extractIonImage, MSImagingExperiment, IonImage, hasPixel,
getIntensity and getMzRange to locate code under test.
- Around line 1-210: Add inline comments (~10–11 lines total, ~5% of file)
explaining test setup and expectations: annotate makeFixture() to state it
builds a 2x2 grid with pixel (1,1) intentionally missing and which spectra map
to which pixels; in the extractIonImage test (reference extractIonImage) add a
brief note showing the ppm calculation (200 ppm @ 500 Da → dm = 0.1 → window
[499.9, 500.1]) and why intensities are 30.0, 0.0, and 100.0 for the respective
pixels; in the validate test (reference validate) comment that the fixture is
consistent, then explain that adding a pixel with spectrum index 999 maps to a
non-existent spectrum and should throw Exception::InvalidValue. Keep comments
short, inline, and focused on intent so they meet the coding-guideline coverage
target.
🪄 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: 0048c992-19d3-4c68-b322-e246b2f2ff1f
📒 Files selected for processing (13)
src/openms/include/OpenMS/IMAGING/IonImage.hsrc/openms/include/OpenMS/IMAGING/MSImagingExperiment.hsrc/openms/include/OpenMS/IMAGING/MSImagingGeometry.hsrc/openms/include/OpenMS/IMAGING/sources.cmakesrc/openms/includes.cmakesrc/openms/source/IMAGING/IonImage.cppsrc/openms/source/IMAGING/MSImagingExperiment.cppsrc/openms/source/IMAGING/MSImagingGeometry.cppsrc/openms/source/IMAGING/sources.cmakesrc/tests/class_tests/openms/executables.cmakesrc/tests/class_tests/openms/source/IonImage_test.cppsrc/tests/class_tests/openms/source/MSImagingExperiment_test.cppsrc/tests/class_tests/openms/source/MSImagingGeometry_test.cpp
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/tests/class_tests/openms/source/MSImagingGeometry_test.cpp (1)
91-91: ⚡ Quick winConsider testing the maximum valid coordinate.
The test verifies that coordinates ≥ 2²¹ throw
InvalidValue, but doesn't test the boundary value (2²¹ - 1) which should succeed. Adding a test case withaddPixel((1u << 21) - 1, 0, 0)would verify the boundary is correctly handled.✅ Suggested boundary test addition
// bit-pack overflow + g.addPixel((1u << 21) - 1, 0, 0); // max valid coordinate should succeed TEST_EXCEPTION(Exception::InvalidValue, g.addPixel(1u << 21, 0, 0))🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/tests/class_tests/openms/source/MSImagingGeometry_test.cpp` at line 91, Add a boundary test to verify the maximum valid coordinate is accepted: call g.addPixel((1u << 21) - 1, 0, 0) and assert it does not throw (i.e., remove TEST_EXCEPTION wrapper for that call or use a non-exception assertion). Keep the existing TEST_EXCEPTION(Exception::InvalidValue, g.addPixel(1u << 21, 0, 0)) as-is, and place the new successful call (using g.addPixel((1u << 21) - 1, 0, 0)) before or after it in MSImagingGeometry_test.cpp so the boundary behavior for g.addPixel is explicitly validated.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/tests/class_tests/openms/source/MSImagingGeometry_test.cpp`:
- Line 91: Add a boundary test to verify the maximum valid coordinate is
accepted: call g.addPixel((1u << 21) - 1, 0, 0) and assert it does not throw
(i.e., remove TEST_EXCEPTION wrapper for that call or use a non-exception
assertion). Keep the existing TEST_EXCEPTION(Exception::InvalidValue,
g.addPixel(1u << 21, 0, 0)) as-is, and place the new successful call (using
g.addPixel((1u << 21) - 1, 0, 0)) before or after it in
MSImagingGeometry_test.cpp so the boundary behavior for g.addPixel is explicitly
validated.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ef2e2673-e2dd-4d87-998c-5b7daa94b496
📒 Files selected for processing (9)
src/openms/include/OpenMS/IMAGING/IonImage.hsrc/openms/include/OpenMS/IMAGING/MSImagingExperiment.hsrc/openms/include/OpenMS/IMAGING/MSImagingGeometry.hsrc/openms/source/IMAGING/IonImage.cppsrc/openms/source/IMAGING/MSImagingExperiment.cppsrc/openms/source/IMAGING/MSImagingGeometry.cppsrc/tests/class_tests/openms/source/IonImage_test.cppsrc/tests/class_tests/openms/source/MSImagingExperiment_test.cppsrc/tests/class_tests/openms/source/MSImagingGeometry_test.cpp
🚧 Files skipped from review as they are similar to previous changes (8)
- src/openms/include/OpenMS/IMAGING/MSImagingGeometry.h
- src/openms/source/IMAGING/MSImagingGeometry.cpp
- src/openms/include/OpenMS/IMAGING/MSImagingExperiment.h
- src/openms/source/IMAGING/IonImage.cpp
- src/tests/class_tests/openms/source/IonImage_test.cpp
- src/tests/class_tests/openms/source/MSImagingExperiment_test.cpp
- src/openms/source/IMAGING/MSImagingExperiment.cpp
- src/openms/include/OpenMS/IMAGING/IonImage.h
imzML's "position z" exists for 3D stacks but the spec has no z extent and no z pixel size CV term; in practice each tissue section is its own acquisition. Modeling 3D as an internal dimension was overkill for the common (and CV-supported) case. - IonImage, MSImagingGeometry, MSImagingExperiment: 2D-only API. - MSImagingGeometry::Pixel drops `z`. - Bit-pack key is now y<<32 | x; no axis-range limit needed. - 3D / serial-section experiments are intended to be modeled as a collection of MSImagingExperiment objects (one per section).
There was a problem hiding this comment.
Actionable comments posted: 3
♻️ Duplicate comments (3)
src/openms/source/IMAGING/MSImagingGeometry.cpp (1)
54-66:⚠️ Potential issue | 🟠 Major | ⚡ Quick winReject coordinates outside configured geometry in
addPixel.
addPixelaccepts(x,y)even when outsidewidth_/height_, which creates invalid geometry state and defers failure to downstream consumers.💡 Suggested fix
void MSImagingGeometry::addPixel(UInt x, UInt y, Size spectrum_index) { + if (x >= width_ || y >= height_) + { + throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, + "Pixel coordinate outside configured geometry bounds", + String(x) + "," + String(y)); + } const UInt64 key = packKey_(x, y); if (lookup_.find(key) != lookup_.end()) { throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Duplicate pixel coordinate", String(x) + "," + String(y)); } lookup_.emplace(key, pixels_.size()); pixels_.push_back(Pixel{x, y, spectrum_index}); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/openms/source/IMAGING/MSImagingGeometry.cpp` around lines 54 - 66, MSImagingGeometry::addPixel currently allows coordinates outside the configured geometry (width_/height_); update addPixel to validate x and y against width_ and height_ before packing the key and inserting: if x >= width_ or y >= height_ (or width_/height_ are zero/invalid) throw Exception::InvalidValue with a clear message referencing the invalid coordinate, and only then proceed to check lookup_ for duplicates and emplace into lookup_ and pixels_. Ensure you reference packKey_, lookup_, and pixels_ in the fix so the order of operations is correct.src/openms/source/IMAGING/MSImagingExperiment.cpp (2)
73-77:⚠️ Potential issue | 🟠 Major | ⚡ Quick winValidate
mzandtolerance_ppmbefore window construction.Reject non-finite or negative inputs before computing
dm,mz_lo, andmz_hito prevent invalid extraction windows.💡 Suggested fix
+#include <cmath> + IonImage MSImagingExperiment::extractIonImage(double mz, double tolerance_ppm) const { + if (!std::isfinite(mz) || !std::isfinite(tolerance_ppm) || mz < 0.0 || tolerance_ppm < 0.0) + { + throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, + "mz and tolerance_ppm must be finite and non-negative", + "mz=" + String(mz) + ", tolerance_ppm=" + String(tolerance_ppm)); + } const double dm = mz * tolerance_ppm * 1e-6; const double mz_lo = mz - dm; const double mz_hi = mz + dm;🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/openms/source/IMAGING/MSImagingExperiment.cpp` around lines 73 - 77, In MSImagingExperiment::extractIonImage, validate inputs before computing dm, mz_lo, and mz_hi: check that mz and tolerance_ppm are finite (e.g., std::isfinite) and that tolerance_ppm is non-negative (>= 0); if the check fails, reject the call by throwing a clear invalid-argument/illegal-argument exception with a descriptive message referencing the invalid parameter(s) instead of proceeding to compute dm/mz_lo/mz_hi and building the window.
63-71:⚠️ Potential issue | 🔴 Critical | ⚡ Quick winGuard spectrum index bounds in both
getSpectrumoverloads.Direct indexing with
experiment_[geometry_.getSpectrumIndex(x, y)]can access out-of-range when geometry references an invalid spectrum index.💡 Suggested fix
MSSpectrum& MSImagingExperiment::getSpectrum(UInt x, UInt y) { - return experiment_[geometry_.getSpectrumIndex(x, y)]; + const Size idx = geometry_.getSpectrumIndex(x, y); + if (idx >= experiment_.getNrSpectra()) + { + throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, + "Pixel references missing spectrum", + String(idx)); + } + return experiment_[idx]; } const MSSpectrum& MSImagingExperiment::getSpectrum(UInt x, UInt y) const { - return experiment_[geometry_.getSpectrumIndex(x, y)]; + const Size idx = geometry_.getSpectrumIndex(x, y); + if (idx >= experiment_.getNrSpectra()) + { + throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, + "Pixel references missing spectrum", + String(idx)); + } + return experiment_[idx]; }#!/bin/bash set -euo pipefail echo "Verify unchecked index use in getSpectrum overloads:" rg -nP 'MSImagingExperiment::getSpectrum\(UInt x, UInt y\)' src/openms/source/IMAGING/MSImagingExperiment.cpp -A8 -B2 echo echo "Inspect index-based access APIs in MSExperiment declarations:" fd -i 'MSExperiment.h' src/openms/include --exec rg -nP 'operator\[\]|at\(' {}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/openms/source/IMAGING/MSImagingExperiment.cpp` around lines 63 - 71, The two getSpectrum overloads perform unchecked indexing via experiment_[geometry_.getSpectrumIndex(x, y)] which can access out-of-range elements; update both MSImagingExperiment::getSpectrum(UInt x, UInt y) and the const overload to first compute UInt idx = geometry_.getSpectrumIndex(x, y), validate it against experiment_.size() (or use experiment_.at(idx) which throws), and if invalid throw/return a clear error (e.g. throw an std::out_of_range or the project’s Exception with a descriptive message) instead of performing raw operator[] access so callers cannot hit undefined behavior.
🧹 Nitpick comments (2)
src/tests/class_tests/openms/source/MSImagingGeometry_test.cpp (1)
70-85: ⚡ Quick winAdd a regression test for out-of-bounds
addPixelcoordinates.Given dimensions are part of the public geometry contract, add a case that
addPixel(x,y,...)throws forx >= widthory >= height.As per coding guidelines: “
src/tests/class_tests/**/*_test.cpp: Write unit tests for new functionality and ensure existing tests pass before suggesting changes.”src/tests/class_tests/openms/source/MSImagingExperiment_test.cpp (1)
1-209: 💤 Low valueConsider adding more explanatory comments.
The test file has excellent coverage and clear test structure, but inline comments comprise less than 5% of the code. As per coding guidelines, code comments should comprise at least ~5%. While test files are somewhat self-documenting through section names, additional comments explaining the test fixture design, specific test value choices, and validation goals would improve maintainability.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/tests/class_tests/openms/source/MSImagingExperiment_test.cpp` around lines 1 - 209, Add short explanatory comments in the test around the fixture and key assertions: document makeSpec() (what peak pairs represent), annotate makeFixture() to explain the 2x2 grid layout and that pixel (1,1) is intentionally missing and how spectra are mapped to pixel indices, and add brief comments above the extractIonImage test explaining the 200 ppm -> ±0.1 Da window choice and expected combined intensities; also annotate the validate() test to state that the final step deliberately adds a pixel mapped to a non-existent spectrum to trigger Exception::InvalidValue. Refer to makeSpec, makeFixture, extractIonImage, getSpectrum, and validate when placing these comments.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/openms/include/OpenMS/IMAGING/IonImage.h`:
- Around line 18-68: Update the Doxygen for the exported IonImage API: add an
`@ingroup` and an expanded `@brief` to the class-level comment, and for each public
method/constructor (IonImage(), IonImage(UInt width, UInt height), resize(UInt
width, UInt height), getWidth(), getHeight(), hasPixel(UInt x, UInt y),
getIntensity(UInt x, UInt y), setIntensity(UInt x, UInt y, double intensity),
setMzRange(const RangeMZ& range), getMzRange(), getData(), getValidity()) add a
proper `@brief` plus `@param` entries with [in]/[out]/[in,out] directions, a `@return`
description where applicable, and `@throws` clauses for index/overflow cases (e.g.
getIntensity/setIntensity/hasPixel/resize mention Exception::IndexOverflow or
other relevant exceptions); ensure the docstrings describe behavior (e.g. pixels
invalid by default, setIntensity marks valid, getIntensity returns 0.0 if unset)
and reference the row-major indexing convention where useful.
In `@src/openms/include/OpenMS/IMAGING/MSImagingExperiment.h`:
- Around line 19-90: Add full Doxygen tags to the MSImagingExperiment class and
its public methods: add an `@ingroup` line on the class declaration for the
appropriate module, ensure the class has a `@brief` (already present) and then add
for each public method explicit method-level tags — e.g. for
getMSExperiment()/getGeometry() document `@brief`, `@return` and mark return as
[out] reference; for const overloads mark return as [out] const reference; for
setMSExperiment(MSExperiment exp)/setGeometry(MSImagingGeometry geom) add
`@brief`, `@param` [in] exp (or geom) describing ownership/copy semantics and
`@return` void; for getNumberOfPixels()/getNumberOfSpectra()/hasPixel(UInt x, UInt
y) add `@brief`, `@param` [in] x/y where relevant, `@return` description; for
getSpectrum(UInt x, UInt y) and its const overload add `@brief`, `@param` [in] x/y,
`@return` reference and precise `@throws` Exception::ElementNotFound; for
extractIonImage(double mz, double tolerance_ppm) add `@brief`, `@param` [in] mz and
`@param` [in] tolerance_ppm, `@return` IonImage and list `@throws`
Exception::InvalidValue and Exception::IndexOverflow with conditions; for
validate() add `@brief` and `@throws` Exception::InvalidValue; keep wording concise
and precise about ownership, input/output directions, and error conditions, and
apply these annotations to the exact symbols named above.
In `@src/openms/include/OpenMS/IMAGING/MSImagingGeometry.h`:
- Around line 19-77: Add the missing Doxygen tags to the new public API: add a
class-level `@ingroup` entry to MSImagingGeometry and update all public
method/struct comments to include full contracts—add `@param` entries with
directions ([in]/[out]/[in,out]) for parameters of setDimensions, setPixelSize,
addPixel, hasPixel, getSpectrumIndex; add `@return` for getters
(getWidth/getHeight/getPixelSizeX/getPixelSizeY/getPixelSizeUnit/getSpectrumIndex/getPixels/getNumberOfPixels)
and document returned types; and extend `@throws` to cover thrown exceptions
(e.g., Exception::InvalidValue for addPixel, Exception::ElementNotFound for
getSpectrumIndex). Also document the Pixel struct fields with `@brief` and
`@param/`@note as appropriate. Keep the symbols MSImagingGeometry, Pixel,
setDimensions, getWidth, getHeight, setPixelSize, getPixelSizeX, getPixelSizeY,
getPixelSizeUnit, addPixel, hasPixel, getSpectrumIndex, getPixels,
getNumberOfPixels, and clear to locate the changes.
---
Duplicate comments:
In `@src/openms/source/IMAGING/MSImagingExperiment.cpp`:
- Around line 73-77: In MSImagingExperiment::extractIonImage, validate inputs
before computing dm, mz_lo, and mz_hi: check that mz and tolerance_ppm are
finite (e.g., std::isfinite) and that tolerance_ppm is non-negative (>= 0); if
the check fails, reject the call by throwing a clear
invalid-argument/illegal-argument exception with a descriptive message
referencing the invalid parameter(s) instead of proceeding to compute
dm/mz_lo/mz_hi and building the window.
- Around line 63-71: The two getSpectrum overloads perform unchecked indexing
via experiment_[geometry_.getSpectrumIndex(x, y)] which can access out-of-range
elements; update both MSImagingExperiment::getSpectrum(UInt x, UInt y) and the
const overload to first compute UInt idx = geometry_.getSpectrumIndex(x, y),
validate it against experiment_.size() (or use experiment_.at(idx) which
throws), and if invalid throw/return a clear error (e.g. throw an
std::out_of_range or the project’s Exception with a descriptive message) instead
of performing raw operator[] access so callers cannot hit undefined behavior.
In `@src/openms/source/IMAGING/MSImagingGeometry.cpp`:
- Around line 54-66: MSImagingGeometry::addPixel currently allows coordinates
outside the configured geometry (width_/height_); update addPixel to validate x
and y against width_ and height_ before packing the key and inserting: if x >=
width_ or y >= height_ (or width_/height_ are zero/invalid) throw
Exception::InvalidValue with a clear message referencing the invalid coordinate,
and only then proceed to check lookup_ for duplicates and emplace into lookup_
and pixels_. Ensure you reference packKey_, lookup_, and pixels_ in the fix so
the order of operations is correct.
---
Nitpick comments:
In `@src/tests/class_tests/openms/source/MSImagingExperiment_test.cpp`:
- Around line 1-209: Add short explanatory comments in the test around the
fixture and key assertions: document makeSpec() (what peak pairs represent),
annotate makeFixture() to explain the 2x2 grid layout and that pixel (1,1) is
intentionally missing and how spectra are mapped to pixel indices, and add brief
comments above the extractIonImage test explaining the 200 ppm -> ±0.1 Da window
choice and expected combined intensities; also annotate the validate() test to
state that the final step deliberately adds a pixel mapped to a non-existent
spectrum to trigger Exception::InvalidValue. Refer to makeSpec, makeFixture,
extractIonImage, getSpectrum, and validate when placing these comments.
🪄 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: c92d5a53-bf66-46d8-9921-6d4fa4884c3c
📒 Files selected for processing (9)
src/openms/include/OpenMS/IMAGING/IonImage.hsrc/openms/include/OpenMS/IMAGING/MSImagingExperiment.hsrc/openms/include/OpenMS/IMAGING/MSImagingGeometry.hsrc/openms/source/IMAGING/IonImage.cppsrc/openms/source/IMAGING/MSImagingExperiment.cppsrc/openms/source/IMAGING/MSImagingGeometry.cppsrc/tests/class_tests/openms/source/IonImage_test.cppsrc/tests/class_tests/openms/source/MSImagingExperiment_test.cppsrc/tests/class_tests/openms/source/MSImagingGeometry_test.cpp
- extractIonImage rejects negative/NaN mz or tolerance_ppm up front, preventing inverted m/z windows that silently return an all-zero image. - getSpectrum bounds-checks the spectrum_index returned by the geometry and throws InvalidValue on stale references instead of UB via operator[]. - addPixel rejects coordinates outside [0, width) x [0, height) once dimensions are set; pre-dimension insertion still works for callers that build the geometry incrementally. Tests cover the three new failure modes plus extractIonImage on an empty experiment and an m/z window outside all peaks.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/tests/class_tests/openms/source/MSImagingGeometry_test.cpp (1)
132-146: ⚡ Quick winStrengthen
clear()reset assertions for both pixel-size axes.Line 144 verifies only
getPixelSizeX()afterclear(). Add a matchinggetPixelSizeY()assertion to prevent one-axis reset regressions from slipping through.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/tests/class_tests/openms/source/MSImagingGeometry_test.cpp` around lines 132 - 146, The test fails to assert that both pixel-size axes are reset by MSImagingGeometry::clear(); after the existing TEST_REAL_SIMILAR(g.getPixelSizeX(), 1.0) add a matching assertion for the Y axis (e.g., TEST_REAL_SIMILAR(g.getPixelSizeY(), 1.0)) so that getPixelSizeY() is validated alongside getPixelSizeX(); keep the existing getPixelSizeUnit() check intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/openms/source/IMAGING/MSImagingGeometry.cpp`:
- Around line 16-20: When setting new dimensions in
MSImagingGeometry::setDimensions, ensure existing pixels remain valid: iterate
the internal pixel storage (e.g., the container holding pixel coordinates) and
if any pixel has x >= width or y >= height, reject the change by throwing a
clear exception (or return an error) rather than blindly assigning width_ and
height_; update callers/tests accordingly. Implement this check at the start of
setDimensions, referencing MSImagingGeometry::setDimensions and the
width_/height_ members, and use a suitable exception type (std::invalid_argument
or the project’s exception class) with a descriptive message identifying the
offending pixel(s).
---
Nitpick comments:
In `@src/tests/class_tests/openms/source/MSImagingGeometry_test.cpp`:
- Around line 132-146: The test fails to assert that both pixel-size axes are
reset by MSImagingGeometry::clear(); after the existing
TEST_REAL_SIMILAR(g.getPixelSizeX(), 1.0) add a matching assertion for the Y
axis (e.g., TEST_REAL_SIMILAR(g.getPixelSizeY(), 1.0)) so that getPixelSizeY()
is validated alongside getPixelSizeX(); keep the existing getPixelSizeUnit()
check intact.
🪄 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: 6d382baa-2634-4400-8c4c-5285ae3a2a46
📒 Files selected for processing (6)
src/openms/include/OpenMS/IMAGING/MSImagingExperiment.hsrc/openms/include/OpenMS/IMAGING/MSImagingGeometry.hsrc/openms/source/IMAGING/MSImagingExperiment.cppsrc/openms/source/IMAGING/MSImagingGeometry.cppsrc/tests/class_tests/openms/source/MSImagingExperiment_test.cppsrc/tests/class_tests/openms/source/MSImagingGeometry_test.cpp
🚧 Files skipped from review as they are similar to previous changes (4)
- src/openms/include/OpenMS/IMAGING/MSImagingGeometry.h
- src/tests/class_tests/openms/source/MSImagingExperiment_test.cpp
- src/openms/include/OpenMS/IMAGING/MSImagingExperiment.h
- src/openms/source/IMAGING/MSImagingExperiment.cpp
| void MSImagingGeometry::setDimensions(UInt width, UInt height) | ||
| { | ||
| width_ = width; | ||
| height_ = height; | ||
| } |
There was a problem hiding this comment.
Validate existing pixels when dimensions are set.
Line 16 currently allows setting width_/height_ even if previously added pixels are outside the new bounds. Since pre-dimension insertion is supported, this can leave geometry in an invalid state and fail later in pixel-indexed consumers.
Proposed fix
void MSImagingGeometry::setDimensions(UInt width, UInt height)
{
+ for (const auto& p : pixels_)
+ {
+ if (p.x >= width || p.y >= height)
+ {
+ throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
+ "Existing pixel outside configured geometry bounds",
+ String(p.x) + "," + String(p.y));
+ }
+ }
width_ = width;
height_ = height;
}📝 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.
| void MSImagingGeometry::setDimensions(UInt width, UInt height) | |
| { | |
| width_ = width; | |
| height_ = height; | |
| } | |
| void MSImagingGeometry::setDimensions(UInt width, UInt height) | |
| { | |
| for (const auto& p : pixels_) | |
| { | |
| if (p.x >= width || p.y >= height) | |
| { | |
| throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, | |
| "Existing pixel outside configured geometry bounds", | |
| String(p.x) + "," + String(p.y)); | |
| } | |
| } | |
| width_ = width; | |
| height_ = height; | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/openms/source/IMAGING/MSImagingGeometry.cpp` around lines 16 - 20, When
setting new dimensions in MSImagingGeometry::setDimensions, ensure existing
pixels remain valid: iterate the internal pixel storage (e.g., the container
holding pixel coordinates) and if any pixel has x >= width or y >= height,
reject the change by throwing a clear exception (or return an error) rather than
blindly assigning width_ and height_; update callers/tests accordingly.
Implement this check at the start of setDimensions, referencing
MSImagingGeometry::setDimensions and the width_/height_ members, and use a
suitable exception type (std::invalid_argument or the project’s exception class)
with a descriptive message identifying the offending pixel(s).
…m MSExperiment Lets callers wrap an MSExperiment in a fresh MSImagingExperiment shell (empty geometry, populated by the caller) without going through the two-step default-construct + setMSExperiment dance. - explicit ctor takes MSExperiment by value, moves into experiment_. - operator= takes MSExperiment by value, moves into experiment_, and clears geometry_ since the previous geometry's spectrum_indices were tied to the previous experiment's spectrum order. setMSExperiment() is the no-clear variant if a caller wants to keep the geometry.
…agingExperiment Mirrors the MSSpectrum binding patterns: - IonImage.get_data() returns a zero-copy 2D numpy view (shape (H, W), dtype float64) of the row-major intensity buffer, scoped to the IonImage's lifetime via reference_internal. - IonImage.get_validity() returns a 2D uint8 array (1 = valid). std::vector<bool> is bit-packed so the validity mask is materialized as a copy. - MSImagingGeometry.get_pixels_struct() returns a zero-copy structured numpy array (fields x: uint32, y: uint32, spectrum_index: uint64), backed by the C++ pixel vector. Layout guarded by static_asserts. - MSImagingExperiment.extractIonImage() returns a fresh IonImage; pixel spectrum access goes through getSpectrum(x, y) with reference_internal.
Eleven tests covering the new IonImage / MSImagingGeometry / MSImagingExperiment bindings: - IonImage: construction, getWidth/Height/Intensity, OOB raises - IonImage.get_data() zero-copy: write through the returned 2D float64 view is reflected in subsequent getIntensity() calls - IonImage.get_validity() 2D uint8 mask round-trip - MSImagingGeometry: setDimensions, setPixelSize, addPixel/hasPixel/ getSpectrumIndex, duplicate + OOB rejection - MSImagingGeometry.get_pixels_struct(): structured dtype names, itemsize, per-field values match insertion order - MSImagingExperiment.extractIonImage() on the 2x2 fixture: intensity grid [[30, 0], [100, 0]], validity at the missing corner, mz range - extractIonImage rejects negative mz and ppm - getSpectrum lookup and missing-pixel error path - constructor(MSExperiment) vs setMSExperiment() geometry semantics
- IonImage::getValidity() -> getMask(); private member valid_pixels_ -> mask_ - Python: IonImage.get_validity() -> get_mask() - Doxygen / docstrings updated to "per-pixel mask" / "masked-out" wording - Tests renamed accordingly (test_ion_image_get_mask_copy, local mask var) No behavior change.
std::vector<bool>::operator[] returns a proxy reference, not a bool; Apple Clang/libc++ in Xcode 15.4 trips the TEST_EQUAL macro path in ClassTest.h on that proxy and the macOS build-and-test job has been red since the initial commit because of it. Switching to TEST_TRUE on the proxy works on every libc++ / libstdc++ we ship against.
… MS (#9381) (#9384) Co-authored-by: GitHub Copilot <[email protected]> Co-authored-by: Copilot <[email protected]>
…) and IMAGING module (#9381) (#9385) Two recent feature commits (both merged Tue May 19 2026) did not have CHANGELOG entries in the 3.6.0 section: - #9380: BrukerTimsFile IM-axis hill-based centroiding (PASEFHillCentroider) with new Config fields for hill params, isotopic prefilter, and per-mode centroid-algorithm selection; Greedy2D path retained as back-compat default. - #9381: New OpenMS/IMAGING module — IonImage, MSImagingGeometry, MSImagingExperiment — providing in-memory data structures for imaging MS; first phase of imzML/MSI support. Also adds the missing (#9379) PR reference tag to the existing pyOpenMS BrukerTimsFile bindings line so the entry is traceable. Co-authored-by: GitHub Copilot <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: timosachsenberg <[email protected]>
…9390) IonImage, MSImagingGeometry, and MSImagingExperiment (added in #9381) are bound in bind_experiment.cpp. The header-path → binding-file lookup table in CLAUDE.md was missing the IMAGING/ entry. Co-authored-by: GitHub Copilot <[email protected]> Co-authored-by: Copilot <[email protected]>
For Discussion
Description
This PR introduces three new core data structures for handling imaging mass spectrometry (MSI) datasets:
IonImage: A dense W×H×D grid storing ion intensities with a per-pixel validity mask. Supports arbitrary dimensions and tracks the m/z window used for extraction.
MSImagingGeometry: Manages the pixel grid metadata (dimensions, physical pixel size) and provides efficient (x,y,z) → spectrum_index lookup via bit-packed coordinates. Supports sparse pixel grids where not all grid positions have associated spectra.
MSImagingExperiment: High-level container combining an MSExperiment (spectra) with MSImagingGeometry (pixel mapping). Provides pixel-based spectrum access and implements ion image extraction via intensity summation within a specified m/z tolerance window.
These classes form the foundation for Phase 2 imaging data support in OpenMS, enabling efficient in-memory representation and manipulation of MSI datasets.
Key Features
Implementation Details
index = (z*H + y)*W + xChecklist
Testing
Comprehensive unit tests added for all three classes:
All tests follow OpenMS ClassTest conventions and pass locally.
https://claude.ai/code/session_01KEYyktyCZUq7Rf3WfhYqSq
Summary by CodeRabbit
New Features
Chores
Tests