Skip to main content

Documentation Status

Installation:

Installing imzML Writer has gotten easier! We're now available as:

  1. (Recommended) As a python package available from pip:
pip install imzml-writer
  1. (Experimental) Standalone app bundles / executables for Mac and PC in the builds folder of the Github.

Installation:

Using imzML Writer depends on msconvert for conversion of raw vendor files to the open format mzML. On PC, this can be installed normally from Proteowizard: https://proteowizard.sourceforge.io/download.html

imzML Writer will prompt you for the path to msconvert the first time you try to convert raw files (see Docs), or you can add msconvert to the system path if you'd like to run msconvert from the command line.

On Mac, you can still run msconvert via a docker image. First, install Docker: https://www.docker.com/products/docker-desktop/

Similarly, imzML Writer will prompt you to download the docker image the first time you try to call it. If you'd like to do this in advance you can open Terminal.app and run the command:

docker pull chambm/pwiz-skyline-i-agree-to-the-vendor-licenses

Quickstart

Once the python package (pip install imzML-Writer) and msconvert (or the docker image) have been successful installed, you can quickly launch the GUI with the script:

import imzML_Writer.imzML_Writer as iw

iw.gui()

Combined Zarr output

On Python 3.12 or 3.13, install the optional Thyra integration:

pip install 'imzML-Writer[zarr]'

To convert a directory of completed imzML scan-filter files into one Zarr store, with one named SpatialData dataset per scan filter:

from imzml_writer.zarr_writer import write_combined_zarr

write_combined_zarr("path/to/imzML/files", "path/to/sample.zarr")

Scan filters are summarized into compact labels such as Positive fullscan, Negative fullscan, and Positive product ion scan (m/z 885.5497). These are also written into each MSI table for viewers such as VIUChem. The original instrument scan-filter string remains available alongside the display name in the root imzml_writer_scan_filters metadata.

Combined conversion enables Thyra's automatic common-mass-axis resampling by default. This avoids enormous raw union axes for centroid imzML data and keeps interactive viewers responsive. Pass thyra_options={"resampling_config": None} only when the unresampled union axis is specifically required.

The final metadata stage can do the same operation directly by passing write_zarr=True to imzML_metadata_process.

In the desktop GUI, Create combined Zarr appears contextually whenever the active folder contains completed .imzML/.ibd pairs. It asks for the Zarr destination and then opens an optional optical-TIFF picker. Cancel the TIFF picker to create MSI-only output; selecting an image adds it and opens the registration preview before the transform is saved.

An optical TIFF can be added to an existing store by path, or selected with a native file dialog when the path is omitted:

from imzml_writer.zarr_writer import add_optical_image

add_optical_image(
    "path/to/sample.zarr",
    "path/to/optical-image.tiff",
)
add_optical_image("path/to/sample.zarr")  # opens a file dialog

The optical image can then be translationally coregistered to the MSI data. By default, two-class k-means uses every m/z feature in each pixel spectrum to identify tissue/background. The optical dark and bright masks are both tested, and a non-wrapping cross-correlation supplies a coarse placement. A translation-only search across the valid field then uses normalized mutual information and normalized cross-correlation against the continuous full-spectrum clustering confidence:

from imzml_writer.zarr_writer import coregister_optical_image

result = coregister_optical_image(
    "path/to/sample.zarr",
    "optical_optical-image",
)
print(result.translation_pixels, result.dice_overlap)

This displays the registered intensity and tissue-mask overlays with Save automatic, Manual override, and Discard buttons. Manual override keeps the optical image fixed while allowing the colored ion image to be dragged into place. Its live field accepts one or several comma-separated m/z values; Previous and Next cycle through them, and Next dataset switches scan filters. Weak NMI/NCC agreement is highlighted in the automatic preview. MSI x/y spacing is read independently from Thyra's imzML detection metadata, so rectangular MSI pixels are displayed and registered in their true physical aspect ratio. Pass msi_pixel_size_um=(40, 150) to override that metadata. Optical spacing is read from OME-XML or calibrated TIFF resolution tags when the image is added. It can be overridden with optical_pixel_size_um=2.5. Use save=True to save without prompting, or save=False to calculate and return a non-mutating result.

The complete optical image is searched by default; no tissue ROI selection is required. An explicit crop can still be supplied with optical_roi=(x0, y0, x1, y1), or selected interactively with select_roi=True for unusually large optical fields.

Pass ion_image_name="<dataset>_z0_tic" to register against one specific ion dataset instead of combining the tissue masks from all MSI tables. The earlier intensity-only behavior remains available with segmentation="tic". The method estimates translation only; it does not correct rotation or nonlinear distortion.

By default, scan-filter masks are weighted by spatial coherence and border contact, allowing a strong tissue silhouette to dominate noisy or weak filters. Set minimum_tissue_votes=2 (or another integer) to use a fixed cross-filter vote threshold instead.

Accepting the registration also stores the aggregate mask as the SpatialData label msi_spectral_tissue_mask. Every selected MSI table receives a boolean obs["tissue"] column and a continuous obs["tissue_confidence"] column, so background spectra can be excluded directly:

from spatialdata import read_zarr

sdata = read_zarr("path/to/sample.zarr")
table = sdata.tables["<scan-filter>_z0"]
tissue_only = table[table.obs["tissue"]].copy()

The accepted mapping is written both to the physical global coordinate system and to the MSI-to-optical registered coordinate system used by viu_chem. Standalone label metadata is normalized automatically to avoid ome-zarr's spurious no parent found message. Existing stores can be repaired without rerunning registration:

from imzml_writer.zarr_writer import repair_standalone_label_metadata

repair_standalone_label_metadata("path/to/sample.zarr")

Compatibility

Software Functioning? Comments
Cardinal MSI Yes
METASPACE Yes
M2aia Yes
MSIReader Yes
Julia mzML_imzML Yes
SCiLS Lab Yes Pixel dimensions must be written as an integer to be read properly
Mozaic Yes

Documentation

Detailed installation instructions, quickstart guides, and documentation are available on the ReadTheDocs page: https://imzml-writer.readthedocs.io/en/latest/

Contact us

Please direct any questions, concerns, or feature requests to me at Joseph.Monaghan@viu.ca

Metadata

Release files for imzML-Writer 1.2.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for imzML-Writer 1.2.10
File Size Uploaded Provenance Actions
imzml_writer-1.2.10.tar.gz 80.8 kB Without provenance Details for imzml_writer-1.2.10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for imzML-Writer 1.2.10
File Interpreter ABI Platform Actions
imzml_writer-1.2.10-py3-none-any.whl Python 3 none any Details for imzml_writer-1.2.10-py3-none-any.whl

Total release size: 164.2 kB

Release files / imzml_writer-1.2.10.tar.gz

Download URL imzml_writer-1.2.10.tar.gz
Size 80.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f863e34a02d780fc929e08914766ecc11a4fd44c946fb9ef70de9ee44f669045
BLAKE2b-256 checksum
How to use checksums
57e86cd91314fb740514925b31d02b34a3c86cdee75ff892fabfec868c40e175
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.0 CPython/3.12.10 Darwin/25.6.0

Release files / imzml_writer-1.2.10-py3-none-any.whl

Download URL imzml_writer-1.2.10-py3-none-any.whl
Size 83.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
be84653ec68cfaa37579d492c67b36ad7bb204a4cac7a1882e39378ff565c665
BLAKE2b-256 checksum
How to use checksums
48de863f87053ba29b9706efbd349726d8099eaa0268a5b9c71fdbe420993304
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.0 CPython/3.12.10 Darwin/25.6.0

Security for imzML-Writer 1.2.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.2.10 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page