Skip to main content

imzy

Dependencies Status Python Version Python package index Python package index download statistics

Code style: black Security: bandit Pre-commit Code coverage Semantic Versions License

imzy: A simple reader interface to imzML, Bruker (.tdf/.tsf) and Waters (.raw) file formats

Getting started

Install using pip

pip install imzy

Analyse your data

import numpy as np
from imzy import get_reader

PATH_TO_FILE = "path/to/file"

# we currently support imzML, Bruker .d (.tsf/.tdf) formats
reader = get_reader(PATH_TO_FILE)
# will extract mass spectrum for pixel index '0'
mz_x, mz_y = reader.get_mass_spectrum(0)
# will extract summed mass spectrum for pixel indices 0-100
mz_x, mz_y = reader.get_summed_spectrum(np.arange(100))
# iterate over all mass spectra in the dataset
for mz_x, mz_y in reader.spectra_iter():
  ...
# get tic array
tic = reader.get_tic()
# this array is 1d so needs to be reshaped to 2d if you want to view it as an image
tic = reader.reshape(tic)
# will extract the 885.549 ion image with 10 ppm window around it
image = reader.get_ion_image(885.549, ppm=10)
# you can also extract multiple images at the same time (which is much more efficient since the spectra
# only need to be loaded into memory once)
mzs = [...] # list of m/zs to extract
images = reader.get_ion_images(mzs, tol=0.05)

Supported formats

  • imzML on Windows, macOS and Linux
  • Bruker (.tdf/.tsf) on Windows and Linux

Plugins

It is now possible to create your own readers by implementing the imzy.hookspec interface. This allows you to create your own readers for any format you want. You can then register your reader with imzy by adding the following to your setup.py or pyproject.toml or setup.cfg file:

If you have project named your_project_name, you could add a file imzy.py to your project with the following code:

from imzy import BaseReader
from imzy.hookspec import hook_impl

class YourReader(BaseReader):
  """Your reader class."""
  

@hook_impl
def imzy_reader(path: str, **kwargs) -> ty.Optional[YourReader]:
    """Return YourReader if path is valid."""
    ...

In the pyproject.toml file, please define the interface:

[options.entry_points."imzy.plugins"]
your_project_name = "your_project_name.imzy"

Your reader will be automatically detected when the ImzyPluginManager is initialized, which happens when the get_reader function is called. You can then use your reader as follows:

Planned features

  • improve performance
  • improve tests
  • add better caching support
  • add support for Thermo (.raw) files

Contributing

Initialize your code

  1. Initialize git inside your repo:
cd imzy && git init
  1. Create conda environment. We are using imzy as its name.
conda create -n imzy python=3.9
  1. Initialize and install pre-commit hooks:
make develop
make pre-commit-install
  1. Run the codestyle:
make codestyle
  1. Upload initial code to GitHub:
git add .
git commit -m ":tada: Initial commit"
git branch -M main
git remote add origin https://github.com/imzy/imzy.git
git push -u origin main

🛡 License

License

This project is licensed under the terms of the BSD-3 license. See LICENSE for more details.

📃 Citation

@misc{imzy,
  author = {imzy},
  title = {imzy: A new reader/writer interface to imzML and other imaging mass spectrometry formats.},
  year = {2022},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/imzy/imzy}}
}

Metadata

Release files for imzy 0.3.0

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

Source distribution (sdist)

Source distribution for imzy 0.3.0
File Size Uploaded Provenance Actions
imzy-0.3.0.tar.gz 23.1 MB Without provenance Details for imzy-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for imzy 0.3.0
File Interpreter ABI Platform Actions
imzy-0.3.0-py3-none-any.whl Python 3 none any Details for imzy-0.3.0-py3-none-any.whl

Total release size: 29.5 MB

Release files / imzy-0.3.0.tar.gz

Download URL imzy-0.3.0.tar.gz
Size 23.1 MB
Tags Source
SHA-256 checksum
How to use checksums
40999e6610d1fac3e67f9946121dd4bc8d93953fae3fe024bd331dbc9dfd8f71
BLAKE2b-256 checksum
How to use checksums
22d790f4d85809b24e4d3065d490074a48806b420614d8aa85519fdfa0cc4012
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / imzy-0.3.0-py3-none-any.whl

Download URL imzy-0.3.0-py3-none-any.whl
Size 6.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
32ca088f3c131bacb6f762a98e11548f3d6051536e3ac98495f8ae4e5ea62306
BLAKE2b-256 checksum
How to use checksums
8b34e614012442bfaa4ef6b3d0850d2cbaccf0088cfd5aba8b8a0b302a6bb529
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Security for imzy 0.3.0

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.

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