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 $
7// --------------------------------------------------------------------------
8
9#pragma once
10
11#include <OpenMS/OpenMSConfig.h>
15
16#include <cstddef>
17#include <cstdint>
18#include <memory>
19#include <string>
20
21namespace OpenMS
22{
23
24 class MSImagingGeometry; // OpenMS/IMAGING/MSImagingGeometry.h — included in the .cpp
25
59 class OPENMS_DLLAPI OnDiscImzMLExperiment
60 {
61 public:
62
64 ~OnDiscImzMLExperiment(); // needs Impl complete — defined in .cpp
65
68
71
72 // ------------------------------------------------------------------
73 // Open
74 // ------------------------------------------------------------------
75
96 void open(const std::string& imzml_path, const std::string& ibd_path = "");
97
104 void close() noexcept;
105
106 // ------------------------------------------------------------------
107 // State
108 // ------------------------------------------------------------------
109
110 bool isOpen() const noexcept;
111 std::size_t getNrSpectra() const noexcept;
112 std::size_t size() const noexcept { return getNrSpectra(); }
113
114 // ------------------------------------------------------------------
115 // Index access — no IBD read, O(1)
116 // ------------------------------------------------------------------
117
126 const ImzMLSpectrumIndex& getIndex(std::size_t i) const;
127
128 // ------------------------------------------------------------------
129 // On-demand spectrum decode — one fseek + fread per call
130 // ------------------------------------------------------------------
131
143 MSSpectrum getSpectrum(std::size_t i) const;
144
146 MSSpectrum operator[](std::size_t i) const { return getSpectrum(i); }
147
163 MSSpectrum getSpectrumAtCoord(uint32_t x, uint32_t y, uint32_t z = 1) const;
164
165 // ------------------------------------------------------------------
166 // Dataset-level metadata
167 // ------------------------------------------------------------------
168
170 const ImzMLMeta& getImzMLMeta() const noexcept;
171
183 const MSImagingGeometry& getGeometry() const;
184
186 uint32_t gridWidth() const noexcept;
187
189 uint32_t gridHeight() const noexcept;
190
191 private:
192
193 struct Impl;
194 std::unique_ptr<Impl> pimpl_;
195 };
196
197} // namespace OpenMS
Pixel grid metadata and (x, y) -> spectrum_index lookup for MSI data.
Definition MSImagingGeometry.h:31
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.
void close() noexcept
Close the companion .ibd file and release on-disc resources.
OnDiscImzMLExperiment & operator=(const OnDiscImzMLExperiment &)=delete
OnDiscImzMLExperiment & operator=(OnDiscImzMLExperiment &&)
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 &&)
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:146
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
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