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 class ExperimentalSettings; // OpenMS/METADATA/ExperimentalSettings.h — included in the .cpp
28
73 class OPENMS_DLLAPI OnDiscImzMLExperiment
74 {
75 public:
76
78 ~OnDiscImzMLExperiment(); // needs Impl complete — defined in .cpp
79
82
85
86 // ------------------------------------------------------------------
87 // Open
88 // ------------------------------------------------------------------
89
118 void open(const std::string& imzml_path, const std::string& ibd_path = "", bool skip_metadata = false);
119
127 void close() noexcept;
128
129 // ------------------------------------------------------------------
130 // State
131 // ------------------------------------------------------------------
132
133 bool isOpen() const noexcept;
134 std::size_t getNrSpectra() const noexcept;
135 std::size_t size() const noexcept { return getNrSpectra(); }
136
137 // ------------------------------------------------------------------
138 // Index access — no IBD read, O(1)
139 // ------------------------------------------------------------------
140
149 const ImzMLSpectrumIndex& getIndex(std::size_t i) const;
150
151 // ------------------------------------------------------------------
152 // On-demand spectrum decode — one fseek + fread per call
153 // ------------------------------------------------------------------
154
171 MSSpectrum getSpectrum(std::size_t i) const;
172
174 MSSpectrum operator[](std::size_t i) const { return getSpectrum(i); }
175
191 MSSpectrum getSpectrumAtCoord(uint32_t x, uint32_t y, uint32_t z = 1) const;
192
193 // ------------------------------------------------------------------
194 // Ion image extraction — lazy decode, no full dataset in memory
195 // ------------------------------------------------------------------
196
219 IonImage extractIonImage(double mz, double tolerance_ppm) const;
220
235 IonImage extractIonImage(double mz, double tolerance_ppm, Size region_id) const;
236
237 // ------------------------------------------------------------------
238 // Dataset-level metadata
239 // ------------------------------------------------------------------
240
242 const ImzMLMeta& getImzMLMeta() const noexcept;
243
249 const ExperimentalSettings& getExperimentalSettings() const;
250
262 const MSImagingGeometry& getGeometry() const;
263
273 MSImagingGeometry& getGeometry();
274
276 uint32_t gridWidth() const noexcept;
277
279 uint32_t gridHeight() const noexcept;
280
281 private:
282
283 struct Impl;
284 std::unique_ptr<Impl> pimpl_;
285 };
286
287} // namespace OpenMS
Description of the experimental settings.
Definition ExperimentalSettings.h:37
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:74
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.
void open(const std::string &imzml_path, const std::string &ibd_path="", bool skip_metadata=false)
Open an imzML dataset: parse the XML index, build the imaging geometry, and open the ....
MSSpectrum operator[](std::size_t i) const
Sugar for getSpectrum(i).
Definition OnDiscImzMLExperiment.h:174
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:38
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:119