OpenMS
Loading...
Searching...
No Matches
OnDiscImzMLExperiment.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Timo Sachsenberg $
6// $Authors: Aditya Sarna, Patrick Boschmann $
7// --------------------------------------------------------------------------
8
9#pragma once
10
11#include <OpenMS/OpenMSConfig.h>
16
17#include <cstddef>
18#include <cstdint>
19#include <memory>
20#include <string>
21
22namespace OpenMS
23{
24
25 class MSImagingGeometry; // OpenMS/IMAGING/MSImagingGeometry.h — included in the .cpp
26 class IonImage; // OpenMS/IMAGING/IonImage.h — included in the .cpp
27
68 class OPENMS_DLLAPI OnDiscImzMLExperiment
69 {
70 public:
71
73 ~OnDiscImzMLExperiment(); // needs Impl complete — defined in .cpp
74
77
80
81 // ------------------------------------------------------------------
82 // Open
83 // ------------------------------------------------------------------
84
106 void open(const std::string& imzml_path, const std::string& ibd_path = "");
107
114 void close() noexcept;
115
116 // ------------------------------------------------------------------
117 // State
118 // ------------------------------------------------------------------
119
120 bool isOpen() const noexcept;
121 std::size_t getNrSpectra() const noexcept;
122 std::size_t size() const noexcept { return getNrSpectra(); }
123
124 // ------------------------------------------------------------------
125 // Index access — no IBD read, O(1)
126 // ------------------------------------------------------------------
127
136 const ImzMLSpectrumIndex& getIndex(std::size_t i) const;
137
138 // ------------------------------------------------------------------
139 // On-demand spectrum decode — one fseek + fread per call
140 // ------------------------------------------------------------------
141
157 MSSpectrum getSpectrum(std::size_t i) const;
158
160 MSSpectrum operator[](std::size_t i) const { return getSpectrum(i); }
161
177 MSSpectrum getSpectrumAtCoord(uint32_t x, uint32_t y, uint32_t z = 1) const;
178
179 // ------------------------------------------------------------------
180 // Ion image extraction — lazy decode, no full dataset in memory
181 // ------------------------------------------------------------------
182
205 IonImage extractIonImage(double mz, double tolerance_ppm) const;
206
221 IonImage extractIonImage(double mz, double tolerance_ppm, Size region_id) const;
222
223 // ------------------------------------------------------------------
224 // Dataset-level metadata
225 // ------------------------------------------------------------------
226
228 const ImzMLMeta& getImzMLMeta() const noexcept;
229
241 const MSImagingGeometry& getGeometry() const;
242
252 MSImagingGeometry& getGeometry();
253
255 uint32_t gridWidth() const noexcept;
256
258 uint32_t gridHeight() const noexcept;
259
260 private:
261
262 struct Impl;
263 std::unique_ptr<Impl> pimpl_;
264 };
265
266} // namespace OpenMS
Dense W x H grid of ion intensities with a per-pixel mask.
Definition IonImage.h:31
Pixel grid metadata and (x, y) -> spectrum_index lookup for MSI data.
Definition MSImagingGeometry.h:33
The representation of a 1D spectrum.
Definition MSSpectrum.h:44
Random-access, on-disc reader for imzML mass spectrometry imaging datasets.
Definition OnDiscImzMLExperiment.h:69
const ImzMLSpectrumIndex & getIndex(std::size_t i) const
Return the index entry for spectrum i.
void close() noexcept
Close the companion .ibd file and release on-disc resources.
OnDiscImzMLExperiment & operator=(const OnDiscImzMLExperiment &)=delete
OnDiscImzMLExperiment & operator=(OnDiscImzMLExperiment &&)
IonImage extractIonImage(double mz, double tolerance_ppm, Size region_id) const
Extract an ion image for a single region only.
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.
OnDiscImzMLExperiment(OnDiscImzMLExperiment &&)
IonImage extractIonImage(double mz, double tolerance_ppm) const
Extract an ion image over the whole dataset by summing peak intensities inside [mz - dm,...
MSSpectrum getSpectrum(std::size_t i) const
Decode and return spectrum i from the .ibd file.
MSSpectrum operator[](std::size_t i) const
Sugar for getSpectrum(i).
Definition OnDiscImzMLExperiment.h:160
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 ....
OnDiscImzMLExperiment(const OnDiscImzMLExperiment &)=delete
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
Dataset-level metadata for imzML mass spectrometry imaging files.
Definition ImzMLHandlerHelper.h:36
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
STL namespace.
Per-spectrum binary index entry for an imzML dataset.
Definition ImzMLHandlerHelper.h:103