OpenMS
Loading...
Searching...
No Matches
ImzMLHandlerHelper.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>
13
14#include <cstdint>
15#include <cstdio>
16#include <string>
17#include <vector>
18
19namespace OpenMS
20{
21
35 struct OPENMS_DLLAPI ImzMLMeta
36 {
37 // -------------------------------------------------------------------------
38 // Imaging geometry
39 // -------------------------------------------------------------------------
40
41 uint32_t max_count_x {0};
42 uint32_t max_count_y {0};
43 uint32_t max_count_z {1};
44 double pixel_size_x {0};
45 double pixel_size_y {0};
46 double max_dim_x {0};
47 double max_dim_y {0};
48
49 // -------------------------------------------------------------------------
50 // Imaging mode
51 // -------------------------------------------------------------------------
52
54 std::string imaging_mode;
55
56 // -------------------------------------------------------------------------
57 // IBD companion file
58 // -------------------------------------------------------------------------
59
60 std::string ibd_file_path;
61 std::string ibd_sha1;
62 std::string ibd_md5;
63 std::string uuid;
64
65 // -------------------------------------------------------------------------
66 // Array data types (first occurrence, dataset-level summary)
67 // -------------------------------------------------------------------------
68
69 std::string mz_data_type;
70 std::string int_data_type;
71
72 // -------------------------------------------------------------------------
73 // Acquisition geometry
74 // -------------------------------------------------------------------------
75
76 std::string scan_pattern;
77 std::string scan_direction;
78 std::string line_scan_direction;
79 std::string polarity;
80 };
81
82
94 struct OPENMS_DLLAPI ImzMLSpectrumIndex
95 {
97 enum class DataType : uint8_t { FLOAT32, FLOAT64, INT32, INT64, UNKNOWN };
98
99 int32_t index {0};
100 uint32_t x {0};
101 uint32_t y {0};
102 uint32_t z {1};
103 uint64_t mz_offset {0};
104 uint64_t mz_length {0};
105 DataType mz_type {DataType::UNKNOWN};
106 uint64_t int_offset {0};
107 uint64_t int_length {0};
108 DataType int_type {DataType::UNKNOWN};
109 };
110
116 class OPENMS_DLLAPI ImzMLBinaryIO
117 {
118 public:
131 static void readMzArray(FILE* ibd,
132 uint64_t offset,
133 uint64_t count,
135 std::vector<double>& out,
136 const std::string& ibd_path);
137
143 static void readIntArray(FILE* ibd,
144 uint64_t offset,
145 uint64_t count,
147 std::vector<float>& out,
148 const std::string& ibd_path);
149
155 static void writeFloat32Array(FILE* ibd,
156 const float* data,
157 uint64_t count,
158 const std::string& ibd_path);
159
165 static void writeMzAsFloat32(FILE* ibd,
166 const std::vector<double>& mz,
167 const std::string& ibd_path);
168
174 static void writeFloat64Array(FILE* ibd,
175 const double* data,
176 uint64_t count,
177 const std::string& ibd_path);
178
184 static void writeMzAsFloat64(FILE* ibd,
185 const std::vector<double>& mz,
186 const std::string& ibd_path);
187 };
188
189} // namespace OpenMS
Shared .ibd binary array decode utilities for imzML handlers.
Definition ImzMLHandlerHelper.h:117
static void readMzArray(FILE *ibd, uint64_t offset, uint64_t count, ImzMLSpectrumIndex::DataType dt, std::vector< double > &out, const std::string &ibd_path)
Read an m/z array from the companion .ibd file.
static void writeFloat32Array(FILE *ibd, const float *data, uint64_t count, const std::string &ibd_path)
Write a float32 array to the companion .ibd file (little-endian).
static void writeMzAsFloat32(FILE *ibd, const std::vector< double > &mz, const std::string &ibd_path)
Write m/z values as float32 to the companion .ibd file.
static void writeMzAsFloat64(FILE *ibd, const std::vector< double > &mz, const std::string &ibd_path)
Write m/z values as float64 to the companion .ibd file.
static void readIntArray(FILE *ibd, uint64_t offset, uint64_t count, ImzMLSpectrumIndex::DataType dt, std::vector< float > &out, const std::string &ibd_path)
Read an intensity array from the companion .ibd file.
static void writeFloat64Array(FILE *ibd, const double *data, uint64_t count, const std::string &ibd_path)
Write a float64 array to the companion .ibd file (little-endian).
@ UNKNOWN
Unknown or unrecognized ion type.
std::string int_data_type
same set as mz_data_type
Definition ImzMLHandlerHelper.h:70
std::string scan_pattern
"top down" | "bottom up" (IMS:1000401/402)
Definition ImzMLHandlerHelper.h:76
std::string mz_data_type
"float32" | "float64" | "int32" | "int64"
Definition ImzMLHandlerHelper.h:69
std::string line_scan_direction
"left-right" | "right-left" (IMS:1000491/492)
Definition ImzMLHandlerHelper.h:78
std::string polarity
"positive" | "negative" (MS:1000130/129)
Definition ImzMLHandlerHelper.h:79
std::string uuid
Dataset UUID (IMS:1000080)
Definition ImzMLHandlerHelper.h:63
std::string imaging_mode
"continuous" (shared m/z array) or "processed" (per-spectrum m/z).
Definition ImzMLHandlerHelper.h:54
std::string scan_direction
"flyback" | "meander" | "horizontal" | "vertical"
Definition ImzMLHandlerHelper.h:77
std::string ibd_md5
MD5 checksum (IMS:1000090), empty if absent.
Definition ImzMLHandlerHelper.h:62
std::string ibd_file_path
Absolute path to the .ibd file.
Definition ImzMLHandlerHelper.h:60
std::string ibd_sha1
SHA-1 checksum (IMS:1000091), empty if absent.
Definition ImzMLHandlerHelper.h:61
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
Per-spectrum binary index entry for an imzML dataset.
Definition ImzMLHandlerHelper.h:95
DataType
Scalar type identifier for binary array elements.
Definition ImzMLHandlerHelper.h:97