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
61 class OPENMS_DLLAPI OnDiscImzMLExperiment
62 {
63 public:
64
66 ~OnDiscImzMLExperiment(); // needs Impl complete — defined in .cpp
67
70
73
74 // ------------------------------------------------------------------
75 // Open
76 // ------------------------------------------------------------------
77
99 void open(const std::string& imzml_path, const std::string& ibd_path = "");
100
107 void close() noexcept;
108
109 // ------------------------------------------------------------------
110 // State
111 // ------------------------------------------------------------------
112
113 bool isOpen() const noexcept;
114 std::size_t getNrSpectra() const noexcept;
115 std::size_t size() const noexcept { return getNrSpectra(); }
116
117 // ------------------------------------------------------------------
118 // Index access — no IBD read, O(1)
119 // ------------------------------------------------------------------
120
129 const ImzMLSpectrumIndex& getIndex(std::size_t i) const;
130
131 // ------------------------------------------------------------------
132 // On-demand spectrum decode — one fseek + fread per call
133 // ------------------------------------------------------------------
134
146 MSSpectrum getSpectrum(std::size_t i) const;
147
149 MSSpectrum operator[](std::size_t i) const { return getSpectrum(i); }
150
166 MSSpectrum getSpectrumAtCoord(uint32_t x, uint32_t y, uint32_t z = 1) const;
167
168 // ------------------------------------------------------------------
169 // Ion image extraction — lazy decode, no full dataset in memory
170 // ------------------------------------------------------------------
171
192 IonImage extractIonImage(double mz, double tolerance_ppm) const;
193
208 IonImage extractIonImage(double mz, double tolerance_ppm, Size region_id) const;
209
210 // ------------------------------------------------------------------
211 // Dataset-level metadata
212 // ------------------------------------------------------------------
213
215 const ImzMLMeta& getImzMLMeta() const noexcept;
216
228 const MSImagingGeometry& getGeometry() const;
229
239 MSImagingGeometry& getGeometry();
240
242 uint32_t gridWidth() const noexcept;
243
245 uint32_t gridHeight() const noexcept;
246
247 private:
248
249 struct Impl;
250 std::unique_ptr<Impl> pimpl_;
251 };
252
253} // 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:62
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:149
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:95