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

Pixel grid metadata and (x, y) -> spectrum_index lookup for MSI data. More...

#include <OpenMS/IMAGING/MSImagingGeometry.h>

Collaboration diagram for MSImagingGeometry:
[legend]

Classes

struct  Pixel
 A pixel in the imaging grid, linked to one spectrum in the experiment. More...
 

Public Member Functions

void setDimensions (UInt width, UInt height)
 Sets the image dimensions.
 
UInt getWidth () const
 Image width.
 
UInt getHeight () const
 Image height.
 
void setPixelSize (double x, double y, const std::string &unit="micrometer")
 Records the physical pixel size and its unit.
 
double getPixelSizeX () const
 Physical pixel size along x.
 
double getPixelSizeY () const
 Physical pixel size along y.
 
const std::string & getPixelSizeUnit () const
 Unit for the pixel size.
 
void addPixel (UInt x, UInt y, Size spectrum_index)
 Adds a pixel at (x, y) bound to spectrum_index.
 
bool hasPixel (UInt x, UInt y) const
 Tests pixel presence at (x, y).
 
Size getSpectrumIndex (UInt x, UInt y) const
 Looks up the spectrum index at (x, y).
 
const std::vector< Pixel > & getPixels () const
 Pixels in insertion order.
 
Size getNumberOfPixels () const
 Total number of pixels with a bound spectrum.
 
void clear ()
 Resets all state (dimensions, pixel size, pixels, lookup).
 

Static Private Member Functions

static UInt64 packKey_ (UInt x, UInt y)
 

Private Attributes

UInt width_ = 0
 
UInt height_ = 0
 
double pixel_size_x_ = 1.0
 
double pixel_size_y_ = 1.0
 
std::string pixel_size_unit_ = "micrometer"
 
std::vector< Pixelpixels_
 
std::unordered_map< UInt64, Sizelookup_
 

Detailed Description

Pixel grid metadata and (x, y) -> spectrum_index lookup for MSI data.

Coordinates are zero-based. imzML files are one-based; the Phase 2 loader (ImzMLFile) is responsible for normalizing those to zero-based coordinates before populating this geometry.

3D MSI is intentionally not modeled here. Serial-section experiments should be handled as a collection of MSImagingExperiment objects (one per section).


Class Documentation

◆ OpenMS::MSImagingGeometry::Pixel

struct OpenMS::MSImagingGeometry::Pixel

A pixel in the imaging grid, linked to one spectrum in the experiment.

Collaboration diagram for MSImagingGeometry::Pixel:
[legend]
Class Members
Size spectrum_index = 0 Index into the bound MSExperiment.
UInt x = 0 Column index (zero-based).
UInt y = 0 Row index (zero-based).

Member Function Documentation

◆ addPixel()

void addPixel ( UInt  x,
UInt  y,
Size  spectrum_index 
)

Adds a pixel at (x, y) bound to spectrum_index.

Parameters
[in]xColumn index (zero-based).
[in]yRow index (zero-based).
[in]spectrum_indexIndex into the bound MSExperiment.
Exceptions
Exception::InvalidValueon duplicate coordinates, or if dimensions have been set and (x, y) is outside [0, width) x [0, height).

◆ clear()

void clear ( )

Resets all state (dimensions, pixel size, pixels, lookup).

◆ getHeight()

UInt getHeight ( ) const

Image height.

Returns
Number of rows.

◆ getNumberOfPixels()

Size getNumberOfPixels ( ) const

Total number of pixels with a bound spectrum.

Returns
Size of the pixel list.

◆ getPixels()

const std::vector< Pixel > & getPixels ( ) const

Pixels in insertion order.

Returns
Reference to the internal pixel list.

◆ getPixelSizeUnit()

const std::string & getPixelSizeUnit ( ) const

Unit for the pixel size.

Returns
Reference to the unit string.

◆ getPixelSizeX()

double getPixelSizeX ( ) const

Physical pixel size along x.

Returns
Stored x pixel size.

◆ getPixelSizeY()

double getPixelSizeY ( ) const

Physical pixel size along y.

Returns
Stored y pixel size.

◆ getSpectrumIndex()

Size getSpectrumIndex ( UInt  x,
UInt  y 
) const

Looks up the spectrum index at (x, y).

Parameters
[in]xColumn index.
[in]yRow index.
Returns
spectrum_index recorded for that pixel.
Exceptions
Exception::ElementNotFoundif no pixel exists at that coordinate.

◆ getWidth()

UInt getWidth ( ) const

Image width.

Returns
Number of columns.

◆ 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 was inserted at that coordinate.

◆ packKey_()

static UInt64 packKey_ ( UInt  x,
UInt  y 
)
staticprivate

◆ setDimensions()

void setDimensions ( UInt  width,
UInt  height 
)

Sets the image dimensions.

Parameters
[in]widthNumber of columns.
[in]heightNumber of rows.

◆ setPixelSize()

void setPixelSize ( double  x,
double  y,
const std::string &  unit = "micrometer" 
)

Records the physical pixel size and its unit.

Parameters
[in]xPixel size along x.
[in]yPixel size along y.
[in]unitLength unit (default "micrometer").

Member Data Documentation

◆ height_

UInt height_ = 0
private

◆ lookup_

std::unordered_map<UInt64, Size> lookup_
private

◆ pixel_size_unit_

std::string pixel_size_unit_ = "micrometer"
private

◆ pixel_size_x_

double pixel_size_x_ = 1.0
private

◆ pixel_size_y_

double pixel_size_y_ = 1.0
private

◆ pixels_

std::vector<Pixel> pixels_
private

◆ width_

UInt width_ = 0
private