Random-access, on-disc reader for imzML mass spectrometry imaging datasets.
More...
#include <OpenMS/KERNEL/OnDiscImzMLExperiment.h>
|
| std::unique_ptr< Impl > | pimpl_ |
| |
Random-access, on-disc reader for imzML mass spectrometry imaging datasets.
Analogous to OnDiscMSExperiment for indexed mzML files, but designed specifically for imzML's two-file layout (.imzML + .ibd).
Workflow:
exp.
open(
"tissue.imzML");
The representation of a 1D spectrum.
Definition MSSpectrum.h:44
Random-access, on-disc reader for imzML mass spectrometry imaging datasets.
Definition OnDiscImzMLExperiment.h:60
const ImzMLSpectrumIndex & getIndex(std::size_t i) const
Return the index entry for spectrum i.
MSSpectrum getSpectrumAtCoord(uint32_t x, uint32_t y, uint32_t z=1) const
Return the spectrum at imzML pixel coordinate (x, y[, z]).
const ImzMLMeta & getImzMLMeta() const noexcept
Returns imaging metadata parsed during open() — no IBD reads.
MSSpectrum getSpectrum(std::size_t i) const
Decode and return spectrum i from the .ibd file.
std::size_t getNrSpectra() const noexcept
void open(const std::string &imzml_path, const std::string &ibd_path="")
Open an imzML dataset: parse the XML index, build the imaging geometry, and open the ....
Per-spectrum binary index entry for an imzML dataset.
Definition ImzMLHandlerHelper.h:95
Design. The PIMPL idiom hides all implementation details (IBD FILE*, index vector, coordinate map) so that this header has no dependency on expat, Xerces, or the native imzml:: parser library. The index is built by running ImzMLFile::loadSpectraIndex() during open() — no peak arrays are decoded until getSpectrum() is called.
- Note
- This class is not thread-safe. If concurrent reads are needed, construct one instance per thread.
- See also
- ImzMLFile, ImzMLMeta, ImzMLSpectrumIndex, OnDiscMSExperiment
◆ OnDiscImzMLExperiment() [1/3]
◆ ~OnDiscImzMLExperiment()
◆ OnDiscImzMLExperiment() [2/3]
◆ OnDiscImzMLExperiment() [3/3]
◆ close()
Close the companion .ibd file and release on-disc resources.
After close(), isOpen() returns false and spectrum decode calls fail until open() is invoked again.
◆ getGeometry()
The standard 2D imaging geometry (pixel grid + (x,y)->spectrum map).
Returns the shared MSImagingGeometry abstraction (the same type populated by ImzMLFile::load(filename, MSImagingExperiment&)), so on-disc and in-memory access expose pixel coordinates the same way. Coordinates are 0-based; imzML's 1-based coordinates are normalized here, and only the z == 1 plane is represented. Built during open() from the parsed index (no IBD reads); this is a const, O(1) accessor (any duplicate/invalid-coordinate error already surfaced at open()).
◆ getImzMLMeta()
Returns imaging metadata parsed during open() — no IBD reads.
◆ getIndex()
Return the index entry for spectrum i.
Contains pixel coordinates and byte offsets — no IBD read performed.
- Parameters
-
- Exceptions
-
◆ getNrSpectra()
| std::size_t getNrSpectra |
( |
| ) |
const |
|
noexcept |
◆ getSpectrum()
Decode and return spectrum i from the .ibd file.
The returned MSSpectrum contains peak arrays decoded from the .ibd file and pixel coordinates as MetaValues (imzml:x, imzml:y, imzml:z). mzML scan metadata (RT, MS level, etc.) is not loaded in on-disc mode.
- Parameters
-
- Exceptions
-
◆ getSpectrumAtCoord()
| MSSpectrum getSpectrumAtCoord |
( |
uint32_t |
x, |
|
|
uint32_t |
y, |
|
|
uint32_t |
z = 1 |
|
) |
| const |
Return the spectrum at imzML pixel coordinate (x, y[, z]).
Coordinates are imzML-native 1-based, matching ImzMLSpectrumIndex::x/y/z. The lookup is served by the shared MSImagingGeometry (see getGeometry()), which is 0-based and 2-dimensional; this method converts (x, y) to 0-based and only the z == 1 plane is addressable (consistent with the in-memory ImzMLFile loader, which likewise builds a 2D geometry). The geometry is built once during open(), so this is an O(1) lookup plus one peak-decode read.
- Parameters
-
| x | Pixel column (1-based). |
| y | Pixel row (1-based). |
| z | Depth slice (1-based, default 1; only z == 1 is supported). |
- Exceptions
-
◆ gridHeight()
| uint32_t gridHeight |
( |
| ) |
const |
|
noexcept |
◆ gridWidth()
| uint32_t gridWidth |
( |
| ) |
const |
|
noexcept |
◆ isOpen()
◆ open()
| void open |
( |
const std::string & |
imzml_path, |
|
|
const std::string & |
ibd_path = "" |
|
) |
| |
Open an imzML dataset: parse the XML index, build the imaging geometry, and open the .ibd.
The .ibd path is inferred from imzml_path unless ibd_path is provided explicitly. No peak data is read — peak arrays are decoded lazily per getSpectrum() call. The 2D pixel geometry (see getGeometry()) is built eagerly here from the parsed index (an in-memory pass, no .ibd reads), so a structurally broken coordinate grid is rejected at open() rather than later.
A UUID-header mismatch between the .ibd and the XML's IMS:1000080, an out-of-grid pixel, or a <1 coordinate are reported as warnings (the dataset still loads); only duplicate pixel coordinates are a hard error.
- Parameters
-
| imzml_path | Path to the .imzML file. |
| ibd_path | Optional override for the .ibd path. |
- Exceptions
-
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ operator[]()
Sugar for getSpectrum(i).
◆ size()
| std::size_t size |
( |
| ) |
const |
|
inlinenoexcept |
◆ pimpl_
| std::unique_ptr<Impl> pimpl_ |
|
private |