Skip to content

FileConverter converts Bruker MALDI imaging .d to flat mzML (or aborts) instead of refusing it #10596

Closed

Description

@patrick-bo

Found while reviewing #10545 (tested on its head, dbd60d9).

Problem

FileConverter reads Bruker .d input with BrukerTimsFile directly. It never checks whether the run is MALDI imaging (MaldiApplicationType = Imaging). FileHandler::loadExperiment refuses such data with InvalidFileType ("load it via FileHandler::loadImagingExperiment"), but FileConverter does not go through it:

An imaging .d is therefore either converted into a flat mzML with all pixel positions lost, without any warning, or the tool aborts.

Observed (two small subsets of real timsTOF fleX imaging runs)

Imaging data Mode Result
MS1 only (all MsMsType 0) default, -process_lowmemory abort, exit 134: terminate called after throwing SQLite::Exception: no such table: Precursors (AUTO → DDA path, see #10597). With -process_lowmemory a 0-byte mzML is left behind.
MS1 only -bruker:export_mode frame (± lowmemory) exit 0, one MS1 spectrum per pixel frame (frame=N), RT = acquisition time, no XY
all MsMsType 9, DiaFrameMsMsWindows populated default (± lowmemory) exit 0, AUTO picks DIA: 7 "window" spectra per pixel frame (14,000 spectra from 2,000 pixels), unrelated to pixels
same -bruker:export_mode frame exit 0, MS level 2 spectra without precursor, no XY

For comparison, FileHandler::loadImagingExperiment loads both subsets correctly (48×21 and 138×29 pixels).

The gap on the normal path predates #10545. The PR adds the second, low-memory entry point.

Proposed fix

Check this once, right after in_type is known, so both branches are covered:

 #ifdef WITH_OPENTIMS
 #include <OpenMS/FORMAT/BrukerTimsFile.h>
+#include <OpenMS/FORMAT/BrukerTimsImagingFile.h>
 #endif
@@
+#ifdef WITH_OPENTIMS
+    // MALDI imaging .d is not a flat run: BrukerTimsFile would read it as DDA/DIA and drop the pixel positions
+    // (FileHandler::loadExperiment refuses it for the same reason)
+    if (in_type == FileTypes::BRUKER_TDF && BrukerTimsImagingFile::isImagingDataset(in))
+    {
+      writeLogError_("Error: '" + in + "' is a Bruker MALDI imaging .d, which cannot be converted to a flat spectra file (the pixel positions would be lost).");
+      return ILLEGAL_PARAMETERS;
+    }
+#endif

(git apply --check passes on dbd60d9. Not compiled or run.)

Open points

  • BrukerTimsImagingFile::isImagingDataset() returns false for a .d.zip, because it looks for <zip>/analysis.tdf and swallows the exception. So imaging archives would still get past this guard, and FileHandler::loadExperiment's guard as well. BrukerTimsImagingFile has no archive support at all: loadImagingExperiment on an imaging .d.zip throws FileNotReadable: '<x>.d.zip/analysis.tdf'.
  • Should frame-wise export of imaging data stay possible on purpose (e.g. -bruker:export_mode frame with a warning)? Some users may want per-pixel spectra keyed by frame=N and join the coordinates themselves.
  • The real fix would be imaging .d → imzML (loadImagingExperiment + ImzMLFile::store). FileConverter has no imzML input or output yet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions