OpenMS
Loading...
Searching...
No Matches
ImzMLWriter Class Reference

Writer for imzML 1.1.0 files (.imzML + companion .ibd). More...

#include <OpenMS/FORMAT/HANDLERS/ImzMLWriter.h>

Static Public Member Functions

static void store (const std::string &imzml_path, const MSExperiment &exp, const PeakFileOptions &options, ProgressLogger &logger)
 Store an MSExperiment as imzML + .ibd.
 

Detailed Description

Writer for imzML 1.1.0 files (.imzML + companion .ibd).

Member Function Documentation

◆ store()

static void store ( const std::string &  imzml_path,
const MSExperiment &  exp,
const PeakFileOptions &  options,
ProgressLogger &  logger 
)
static

Store an MSExperiment as imzML + .ibd.

Supports continuous (shared m/z array) and processed (per-spectrum m/z) modes. Pixel coordinates are read from imzml:x/y/z MetaValues on each spectrum (required for export); dataset metadata is taken from experiment MetaValues when present.

Export writes external binary arrays with a 16-byte UUID header in the .ibd file. Binary precision for m/z and intensity follows PeakFileOptions (getMz32Bit, getIntensity32Bit).

Per-spectrum FloatDataArray values are exported as additional external binary arrays after m/z and intensity (standard imzML multi-array layout). Scope of that path:

  • FloatDataArray only (not integer/string data arrays)
  • unnamed arrays are skipped with a warning
  • arrays named after the peak CV terms (MS:1000514 "m/z array", MS:1000515 "intensity array") are skipped with a warning: such an array would be read back as the spectrum's peak metadata
  • arrays must have the same length as the spectrum peaks (others are skipped)
  • always 32-bit float, uncompressed (MS:1000576 on the array and on the m/z and intensity referenceableParamGroup entries)
  • PSI-MS accession resolved via the ontology (children of MS:1000513). If the term declares exactly one allowed unit, that unit is written (accession, name, cvRef). Terms with several allowed units get no unit attributes (no arbitrary choice). Unknown names become MS:1000786 "non-standard data array"

Viewers can rely on MSSpectrum::containsIMData() after load for IM arrays.

PeakFileOptions spectrum/peak filters (MS level, RT, precursor m/z, m/z and intensity ranges, metadata-only, sort-by-m/z) are applied to a temporary copy before export.

Spectra sharing a pixel coordinate are written out as-is with a warning, matching what the reader accepts for the same dataset (readers map only the first spectrum per pixel into the imaging geometry).

Parameters
[in]imzml_pathPath to the output .imzML file.
[in]expExperiment to store (must contain at least one spectrum).
[in]optionsPeak file options (filtering, sort, binary precision).
[in]loggerProgress logger for status output.
Exceptions
Exception::MissingInformationif exp has no spectra or lacks imzml:x/y on any spectrum.
Exception::InvalidValueif pixel coordinates are invalid.
Exception::InvalidParameterif continuous export is requested but spectra are incompatible.
Exception::UnableToCreateFileif output files cannot be written.
Exception::ParseErrorif binary array serialization fails.