Skip to main content

Mass Spectrometry Imaging Workflow (maspim)

maspim is a python package that allows users to read, process and interpret mass spectrometry imaging (MSI) data from Bruker instruments.

This package implements methods to process mass spectra, combine them with image information or other measurements (such as micro X-Ray fluorescence, µXRF) and special functionality for laminated sediments to combine spectra in the same layers.

Try it yourself

Binder

You are welcome to use (any parts of) this package but please cite it:

DOI

Prerequisites

Before you begin, ensure you have met the following requirements:

  • You have a version of python3 installed (preferentially the up-to-date version)

  • You have R installed

  • You have the R package rtms installed

You may also want to check out msiAlign, which is not directly a prerequisite, but useful for setting the punch-holes when the automatic detection fails and msi_feature_extraction if you want to work with exported txt files from DataAnalysis.

Installing maspim

maspim is now on PyPI. E.g. run

pip install maspim

to install the basic version of maspim. Processing raw MALDI data depends on the R package rtms. If you need that functionality, run

pip install maspim['all']

or, equivalently

pip install maspim rpy2==3.5.12

Also, checkout our github page for the up-to-date version and additional resources.

To get the freshest version, run

pip install git+https://github.com/yaza11/maspim.git

in your console.

Using maspim

This is just a quick overview. For more comprehensive tutorials please have a look at the Notebooks.

Generally it is advised to stick to the objects provided at the top level of maspim, which are

  • ProjectMSI and ProjectXRF to manage MSI and µXRF measurements respectively and fetched with the get_project function

  • ImageSample, ImageROI and ImageClassified to set photo properties and finding the sample area

  • Transformation to register images

  • ReadBrukerMCF and hdf5handler for reading and storing data files.

  • Spectra to extract intensities from the mass spectra

  • MSI and XRF for handling MSI and µXRF measurements.

  • XRay for adding information from an X-Ray

  • AgeModel to set an age model

and a few others. ProjectMSI and ProjectXRF are the core objects of this package, which manage most of the aforementioned objects. So unless you have a very specific application in mind, it is recommended to do everything with the methods provided by ProjectMSI and ProjectXRF.

Let's look at a short example of how to define the ${U_{37}^{k}}^\prime$ proxy, which you can use to check that your installation worked.

from maspim import get_project

from maspim.res.compound_masses import mC37_2, mC37_3



p = get_project(is_MSI=True, path_folder='path/to/your/measurement.i', is_laminated=False)

# sets or loads ImageHandler, ImageSample, ImageROI and ImageClassified

p.require_images()

# perform all steps to extract intensities from alkenones

p.set_spectra(targets=[mC37_2, mC37_3], suppress_warnings=True)

p.set_data_object()

p.add_pixels_ROI()

# we did not provide any ages, so a time series does not make much sense, but 

# this is just a test, so don't try to interpret the results

p.set_time_series(average_by_col='x', is_continuous=True)

p.set_UK37(method_SST='prahl', n_successes_required=0)

# we can use the index instead of the age for now

p.uk37_proxy.feature_table.loc[:, 'age'] = p.uk37_proxy.feature_table.x

# you should see a plot after this

p.uk37_proxy.plot_comp('SST', errors=False)

Contributing to maspim

If you find any bugs or missing features, you are welcome to contribute to maspim, just follow these steps:

  1. Fork this repository.

  2. Create a branch: git checkout -b <branch_name>.

  3. Make your changes and commit them: git commit -m '<commit_message>'

  4. Push to the original branch: git push origin <project_name>/<location>

  5. Create the pull request.

Alternatively see the GitHub documentation on creating a pull request.

Contributors

Thanks to @weimin-liu who has contributed to this project.

Contact

Feel free to reach out at me via yzander@marum.de.

Release files for maspim 1.4.2

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

Source distribution (sdist)

Source distribution for maspim 1.4.2
File Size Uploaded
maspim-1.4.2.tar.gz 266.0 kB Details

Built distribution (wheel)

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

Total release size: 562.9 kB

Release files / maspim-1.4.2.tar.gz

Download URL maspim-1.4.2.tar.gz
Size 266.0 kB
Tags Source
SHA-256 checksum
How to use checksums
adadedf4871d5518430c3a13df53d00be74a62e0ec232789996ec9344d9fdcde
BLAKE2b-256 checksum
How to use checksums
c2eb559b57eb2d44a09d1b3cccdb1f4224991fe12c8b35bfe68034f377bdadd1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.3

Release files / maspim-1.4.2-py3-none-any.whl

Download URL maspim-1.4.2-py3-none-any.whl
Size 296.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5aa664be50fb39530d6a6df4a498938c5d60ef14b2012d8c1dcda1b19a2a946d
BLAKE2b-256 checksum
How to use checksums
d19bf8a82af352ec43f521819dcd6e054a07d93fd49f14f7e0ad69555f7f9b06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.3

Release history Release notifications | RSS feed

This release

1.4.2 This release

2 release files

1.3.3

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.5

2 release files

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