m/z-array-processing
Summary
Extract and aggregate m/z values and their corresponding intensity arrays from mass spectrometry imaging (MSI) spectra loaded in imzML or vendor-specific format. This skill prepares spectral data for downstream quantitative analysis by structuring m/z–intensity pairs into a standardized format.
When to use
When you have imported MSI data (imzML or vendor format) loaded into the napari plugin environment and need to organize raw spectral m/z and intensity arrays prior to mean intensity calculation, ROI analysis, or database annotation. Apply this skill as the first post-import step to ensure consistent m/z indexing across all pixels/samples in the dataset.
When NOT to use
- If m/z values and intensities are already pre-processed and aggregated into a mean spectrum table; extract only when raw per-pixel/per-sample data are available.
- If data have already been converted to a feature table (e.g., m/z bins × samples intensity matrix) by another tool; extraction is redundant.
- If you require only visualization of raw spectra without quantitative extraction; skip this step if the goal is exploratory browsing only.
Inputs
- imzML file (or vendor-specific MSI format)
- Imported MSI spectral dataset within napari plugin environment
- Raw m/z and intensity arrays from mass spectrometry detector
Outputs
- Structured m/z array (1D vector of unique m/z values)
- Intensity matrix (m/z values × pixel/sample indices)
- CSV or HDF5 table (m/z vs. intensity columns)
- Validated m/z–intensity mapping ready for downstream analysis
How to apply
After loading imzML data via the MSI-Explorer import interface, extract the m/z axis (common to all spectra) and the intensity arrays for each pixel or sample. Validate that all spectra share the same m/z grid (or perform m/z alignment if data is in profile mode by opting to convert to centroid mode when prompted). Organize extracted m/z values and intensity arrays into a structured table or array object keyed by m/z. This preprocessed m/z–intensity mapping then serves as input to mean intensity aggregation (computing arithmetic mean of intensities at each m/z across all pixels) and enables efficient ROI and annotation queries.
Related tools
- napari (Plugin framework and interactive environment for loading, visualizing, and processing MSI spectral data; hosts the MSI-Explorer plugin interface) — https://github.com/napari/napari
- MSI-Explorer (napari plugin that provides data import, m/z–intensity array extraction, visualization, and downstream analysis workflows for MSI datasets) — https://github.com/MMV-Lab/MSI-Explorer
- Python (Programming language and ecosystem for array manipulation, m/z indexing, and intensity aggregation operations)
Evaluation signals
- All imported spectra share the same m/z array after extraction (verify by checking m/z grid consistency across pixel indices).
- Intensity matrix dimensions match expected pixel count × m/z bin count; no missing or NaN values in m/z axis.
- Mean intensity calculation on extracted m/z–intensity arrays produces a 1D spectrum with peaks at expected m/z values and no negative intensities.
- Exported CSV/HDF5 file contains m/z and intensity columns with correct data types and numeric ranges; file can be re-imported for ROI or database queries.
- Profile-mode data prompted for centroid conversion; centroid output has higher m/z resolution and lower data size than profile, as expected.
Limitations
- MSI-Explorer prompts for profile-to-centroid conversion only upon upload; users must explicitly confirm conversion, or data remain in profile mode which may inflate array size and reduce m/z precision.
- m/z arrays extracted from different vendor formats (e.g., Bruker imzML vs. Waters) may differ in precision and binning; alignment or interpolation may be required for cross-platform comparisons.
- If spectra have non-uniform m/z spacing or instrument drift, extracted m/z arrays may contain gaps or duplicate bins; validation and binning strategies are not documented in the README.
- Large MSI datasets (>10,000 pixels) may result in large intensity matrices; memory constraints and file I/O performance are not addressed in the documentation.
Evidence
- [other] Extract m/z values and intensity arrays for all spectra in the dataset.: "Extract m/z values and intensity arrays for all spectra in the dataset."
- [other] For each unique m/z value across all spectra, calculate the arithmetic mean of intensities at that m/z across all pixels/samples.: "For each unique m/z value across all spectra, calculate the arithmetic mean of intensities at that m/z across all pixels/samples."
- [other] Aggregate results into a structured table (m/z vs. mean intensity) and save as a CSV or HDF5 file compatible with downstream ROI analysis and annotation workflows.: "Aggregate results into a structured table (m/z vs. mean intensity) and save as a CSV or HDF5 file compatible with downstream ROI analysis and annotation workflows."
- [other] Load imported MSI spectral data (imzML or vendor-specific format) into the napari plugin environment via the MSI-Explorer data import interface.: "Load imported MSI spectral data (imzML or vendor-specific format) into the napari plugin environment via the MSI-Explorer data import interface."
- [readme] Upon uploading profile mode data, a pop-up appears prompting you to convert it to centroid mode. Selecting
Yesconverts the data, whileNokeeps it in its original profile format.: "Upon uploading profile mode data, a pop-up appears prompting you to convert it to centroid mode. SelectingYesconverts the data, whileNokeeps it in its original profile format."