agentsclimarketplace

Mass spectrometry imaging line scan data handling

Skill HolobiomicsLab/asb-skill-collections/packs/metabolomics/ion-mobility/skills/mass-spectrometry-imaging-line-scan-data-handling

Use when you have raw line-scan MSI data from a vendor instrument (Agilent, Bruker, Thermo, or open-source .mzML format) and need to extract ion images for specified m/z targets with spatial binning and tolerance-based filtering.From its SKILL.md

Install
npx -y skills add HolobiomicsLab/asb-skill-collections --skill mass-spectrometry-imaging-line-scan-data-handling

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 15 stars15 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its file declares

Copied from the file, not written here

The file declares its own license as CC-BY-4.0. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

9.8 KB, ~1.9k tokens by cl100k_base, as published. Nobody here has run it

mass-spectrometry-imaging-line-scan-data-handling

Summary

Convert raw line-scan mass spectrometry imaging (MSI) data from vendor formats (Agilent .d, Bruker .tsf/.baf/.tdf, Thermo .raw, or .mzML) into standardized NumPy pixel arrays and JSON metadata for downstream visualization and quantification. This skill is essential for preparing nano-DESI MSI and other line-scan acquisition modes into a uniform array representation indexed by m/z, spatial position, and optional ion mobility.

When to use

Use this skill when you have raw line-scan MSI data from a vendor instrument (Agilent, Bruker, Thermo, or open-source .mzML format) and need to extract ion images for specified m/z targets with spatial binning and tolerance-based filtering. Apply it at the start of an MSI analysis pipeline when you need reproducible, normalized pixel arrays and accompanying metadata for subsequent visualization, quantification, or statistical analysis.

When NOT to use

  • Input is already a processed pixel array (pixels.npy) or a pre-made visualization — use load_pixels() instead to reload existing arrays.
  • Line-scan data has been acquired in raster or orthogonal grid mode rather than continuous line motion — MSIGen is designed specifically for line-scan geometries.
  • Raw data is from a non-supported vendor format or custom binary format without mzML or vendor SDK conversion — preprocessing to a supported format is required first.

Inputs

  • Raw vendor MSI file (Agilent .d, Bruker .tsf, Bruker .baf, Bruker .tdf, Thermo .raw, or mzML)
  • Mass list file (Excel .xlsx or CSV with columns for m/z, precursor m/z, fragment m/z, and/or ion mobility)
  • Image acquisition geometry (scanned area height and width in mm or other units)

Outputs

  • pixels.npy: 3D NumPy array of shape (n+1, y, x) with n target ion images plus TIC
  • pixels_metadata.json: JSON metadata file with m/z values, tolerance settings, image dimensions, spatial binning info, and normalization parameters

How to apply

Install MSIGen via pip with Python ≥3.9 and ≤3.11, optionally including pyBaf2Sql for Bruker .baf support. Define processing parameters: specify the input file path, a mass list file (Excel or CSV with m/z, precursor m/z, fragment m/z, and/or ion mobility columns), and tolerance windows (MS1, precursor, fragment, and mobility tolerances in ppm, mz, 1/K0, or μs units). Set image acquisition parameters: scanned area height and width, and whether to normalize all images to the same pixel count per line using max, min, or mean. Initialize the msigen object with all parameters and call get_image_data(verbose=True) to extract spectra, match m/z and mobility values within tolerances, bin pixels spatially, and generate a 3D array of shape (n+1, y, x) where n is the number of target masses plus one TIC image. Verify output files pixels.npy and pixels_metadata.json are written to the output directory with correct dimensions and all metadata fields populated.

Related tools

Examples

conda activate MSIGen
python -c "from msigen import msigen; gen = msigen(example_file='sample.d', mass_list_dir='masses.xlsx', mass_tolerance_MS1=5, mass_tolerance_MS1_units='ppm', img_height=10, img_width=10, output_file_loc='./output'); metadata, pixels = gen.get_image_data(verbose=True)"

Evaluation signals

  • pixels.npy has correct output shape (n+1, y, x) where n equals the number of target masses in the mass list plus one for TIC image
  • pixels_metadata.json contains all specified m/z values, tolerance windows, spatial dimensions, and normalization method used
  • Pixel intensity ranges are non-negative and TIC image sums to expected ion current totals across the spatial grid
  • Image dimensions (y, x) match the normalized or original scanned area geometry specified in img_height and img_width parameters
  • All target m/z values from the mass list appear in metadata with correct precursor/fragment and ion mobility classifications

Limitations

  • Python version constraint: ≥3.9 and ≤3.11 (not 3.12 or later); users must create a compatible conda environment.
  • Bruker .baf format support requires separate installation of pyBaf2Sql from GitHub; this dependency is not included in standard pip install.
  • No changelog provided in repository, so version history and breaking changes between releases are not documented.
  • Tolerance-based m/z and mobility filtering can result in missed or false-positive ion matches if tolerances are set too broadly or too narrowly; empirical validation against known ion masses is recommended.
  • Spatial pixel binning is performed uniformly across the entire scanned area; local variations in scan line density or sample topography are not explicitly modeled.

Evidence

  • [other] MSIGen converts raw line-scan MSI data to visualizable format by processing data through pipeline generating NumPy pixel array and JSON metadata: "MSIGen converts raw line-scan MSI data to a visualizable format by processing the data through a pipeline that generates both a NumPy pixel array and JSON metadata as intermediate outputs for"
  • [methods] Install MSIGen via pip with Python 3.9–3.11 and optionally pyBaf2Sql for Bruker .baf support: "Install MSIGen via pip with Python ≥3.9 and ≤3.11, optionally installing pyBaf2Sql for Bruker .baf support."
  • [methods] Define processing parameters: input file path, mass list file, and tolerance windows; set image acquisition geometry; initialize msigen object and call get_image_data(): "Define processing parameters: specify the input file path (Agilent .d, Bruker .tsf/.baf/.tdf, Thermo .raw, or .mzML), mass list file (Excel or CSV with m/z, precursor m/z, fragment m/z, and/or ion"
  • [methods] Set image acquisition parameters: scanned area height/width and normalization; call get_image_data() to generate 3D array: "Set image acquisition parameters: scanned area height and width in specified units (e.g., mm), and whether to normalize all images to the same size using max, min, or mean pixels per line. Initialize"
  • [methods] Verify output files pixels.npy and pixels_metadata.json with correct dimensions and metadata fields: "Verify output files pixels.npy and pixels_metadata.json are written to the specified output directory with correct dimensions and metadata fields."
  • [intro] MSIGen designed for converting MSI from raw line-scan data to visualizable format: "MSIGen is designed for converting mass spectrometry imaging (MSI) data from the raw line-scan data to a visualizable format"
  • [intro] MSIGen designed with nano-DESI MSI in mind: "is designed with nano-DESI MSI in mind"
  • [readme] Create conda environment with Python 3.9–3.11 and install MSIGen via pip: "conda create --name MSIGen python=3.11 -y conda activate MSIGen pip install MSIGen"
  • [readme] For Jupyter Notebook tool, download MSIGen_jupyter.ipynb from repository and open in Jupyter: "Download "MSIGen_jupyter.ipynb" from the other_files folder in the Github repository. Open Anaconda Navigator and run Jupyter Notebook in the MSIGen environment."
  • [readme] pyBaf2Sql wraps Bruker's Baf2Sql library for reading .baf files: "This package is a Python wrapper for Bruker's Baf2Sql data access library to be used with other Python packages."

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.