OpenMS
Loading...
Searching...
No Matches
MSImagingExperiment Class Referencefinal

In-memory model for a 2D imaging mass spectrometry dataset. More...

#include <OpenMS/IMAGING/MSImagingExperiment.h>

Collaboration diagram for MSImagingExperiment:
[legend]

Public Member Functions

 MSImagingExperiment ()=default
 
 MSImagingExperiment (MSExperiment exp)
 Constructs an MSImagingExperiment wrapping exp with an empty geometry.
 
MSImagingExperimentoperator= (MSExperiment exp)
 Replaces the owned MSExperiment and resets the geometry.
 
MSExperimentgetMSExperiment ()
 Mutable access to the owned MSExperiment.
 
const MSExperimentgetMSExperiment () const
 Read access to the owned MSExperiment.
 
void setMSExperiment (MSExperiment exp)
 Replaces the owned MSExperiment.
 
MSImagingGeometrygetGeometry ()
 Mutable access to the owned geometry.
 
const MSImagingGeometrygetGeometry () const
 Read access to the owned geometry.
 
void setGeometry (MSImagingGeometry geom)
 Replaces the owned geometry.
 
Size getNumberOfPixels () const
 Number of pixels in the geometry.
 
Size getNumberOfSpectra () const
 Number of spectra in the underlying experiment.
 
bool hasPixel (UInt x, UInt y) const
 Tests pixel presence at (x, y).
 
MSSpectrumgetSpectrum (UInt x, UInt y)
 Mutable access to the spectrum bound to the pixel at (x, y).
 
const MSSpectrumgetSpectrum (UInt x, UInt y) const
 Read access to the spectrum bound to the pixel at (x, y).
 
IonImage extractIonImage (double mz, double tolerance_ppm) const
 Extracts an ion image by summing peak intensities inside [mz - dm, mz + dm], with dm = mz * tolerance_ppm * 1e-6.
 
void validate () const
 Validates that every pixel references an in-range spectrum_index.
 

Private Attributes

MSExperiment experiment_
 
MSImagingGeometry geometry_
 

Detailed Description

In-memory model for a 2D imaging mass spectrometry dataset.

Owns an MSExperiment (spectra) and an MSImagingGeometry (pixel grid + pixel -> spectrum index mapping). Provides pixel-based spectrum access and a simple sum-based ion image extraction.

A 3D / serial-section experiment is modeled as a collection of MSImagingExperiment objects, one per section.

Constructor & Destructor Documentation

◆ MSImagingExperiment() [1/2]

MSImagingExperiment ( )
default

◆ MSImagingExperiment() [2/2]

MSImagingExperiment ( MSExperiment  exp)
explicit

Constructs an MSImagingExperiment wrapping exp with an empty geometry.

Parameters
[in]expMSExperiment to take ownership of (moved in).

Member Function Documentation

◆ extractIonImage()

IonImage extractIonImage ( double  mz,
double  tolerance_ppm 
) const

Extracts an ion image by summing peak intensities inside [mz - dm, mz + dm], with dm = mz * tolerance_ppm * 1e-6.

Preconditions: each referenced spectrum must be sorted by m/z. Phase 2's ImzMLFile loader will guarantee this; Phase 1 callers must ensure it manually.

Pixels not present in the geometry remain invalid in the returned image. Pixels with a spectrum but no peaks in the window are marked valid with intensity 0. The returned image's m/z range is set to [mz - dm, mz + dm].

Parameters
[in]mzm/z center of the extraction window (>= 0).
[in]tolerance_ppmHalf-window width in ppm (>= 0).
Returns
Image of the same dimensions as the geometry.
Exceptions
Exception::InvalidValueif mz or tolerance_ppm is negative or non-finite, or if any pixel references a missing spectrum_index.
Exception::IndexOverflowif a pixel coordinate falls outside the geometry's declared dimensions.

◆ getGeometry() [1/2]

MSImagingGeometry & getGeometry ( )

Mutable access to the owned geometry.

Returns
Reference to the owned geometry.

◆ getGeometry() [2/2]

const MSImagingGeometry & getGeometry ( ) const

Read access to the owned geometry.

Returns
Const reference to the owned geometry.

◆ getMSExperiment() [1/2]

MSExperiment & getMSExperiment ( )

Mutable access to the owned MSExperiment.

Returns
Reference to the owned experiment.

◆ getMSExperiment() [2/2]

const MSExperiment & getMSExperiment ( ) const

Read access to the owned MSExperiment.

Returns
Const reference to the owned experiment.

◆ getNumberOfPixels()

Size getNumberOfPixels ( ) const

Number of pixels in the geometry.

Returns
Geometry pixel count.

◆ getNumberOfSpectra()

Size getNumberOfSpectra ( ) const

Number of spectra in the underlying experiment.

Returns
Spectrum count.

◆ getSpectrum() [1/2]

MSSpectrum & getSpectrum ( UInt  x,
UInt  y 
)

Mutable access to the spectrum bound to the pixel at (x, y).

Parameters
[in]xColumn index.
[in]yRow index.
Returns
Reference to the bound spectrum.
Exceptions
Exception::ElementNotFoundif no pixel exists at that coordinate.
Exception::InvalidValueif the pixel references a spectrum_index outside the underlying experiment.

◆ getSpectrum() [2/2]

const MSSpectrum & getSpectrum ( UInt  x,
UInt  y 
) const

Read access to the spectrum bound to the pixel at (x, y).

Parameters
[in]xColumn index.
[in]yRow index.
Returns
Const reference to the bound spectrum.
Exceptions
Exception::ElementNotFoundif no pixel exists at that coordinate.
Exception::InvalidValueif the pixel references a spectrum_index outside the underlying experiment.

◆ hasPixel()

bool hasPixel ( UInt  x,
UInt  y 
) const

Tests pixel presence at (x, y).

Parameters
[in]xColumn index.
[in]yRow index.
Returns
true if a pixel exists at that coordinate.

◆ operator=()

MSImagingExperiment & operator= ( MSExperiment  exp)

Replaces the owned MSExperiment and resets the geometry.

The previous geometry's spectrum indices are tied to the previous experiment's spectrum order and become meaningless after assignment, so the geometry is cleared. Use setMSExperiment() if you want to keep the existing geometry.

Parameters
[in]expMSExperiment to take ownership of (moved in).
Returns
Reference to *this.

◆ setGeometry()

void setGeometry ( MSImagingGeometry  geom)

Replaces the owned geometry.

Parameters
[in]geomNew geometry (moved in).

◆ setMSExperiment()

void setMSExperiment ( MSExperiment  exp)

Replaces the owned MSExperiment.

Parameters
[in]expNew experiment (moved in).

◆ validate()

void validate ( ) const

Validates that every pixel references an in-range spectrum_index.

Exceptions
Exception::InvalidValueon the first dangling reference.

Member Data Documentation

◆ experiment_

MSExperiment experiment_
private

◆ geometry_

MSImagingGeometry geometry_
private