This repository contains the codebase for the paper titled "Inferring super-resolved spatial metabolomics from microscopy".
- Introduction
- Setup
- Napari Integration
- Training Data Preparation
- Model Training
- Model Inference
- License
- Acknowledgements
MetaLens is a tool for generating super-resolved spatial metabolomics data from microscopy images. The codebase and accompanying datasets allow users to replicate and extend the experiments presented in the associated research paper.
To set up the Python environment required for MetaLens, follow these steps:
conda create -n MetaLens python==3.10
conda activate MetaLens
# Basic installation (CLI only)
pip install -e .
# Full installation (including Napari plugin)
pip install -e .[napari]
Note: A CUDA-capable machine with a GPU having more than 16GB of RAM is strongly recommended for both training and evaluation tasks. The expected runtime for training is approximately 2 hours, while evaluation can take up to 12 hours.
MetaLens provides a Napari plugin for interactive visualization and analysis. The plugin offers a user-friendly interface for model inference and results visualization. After installing MetaLens with Napari support, launch Napari and access the plugin through the Plugins > MetaLens
menu.
The training data necessary for model development can be obtained and prepared as follows:
- Access the training data from this link.
- Download and extract the patches to the
data/training_data
directory.
To generate new training data using other SpaceM datasets, follow these steps:
- Download the dataset archive from this link.
- In the archive, navigate to
IDR_submission_Rappez > Data > ExperimentB
and copy all files that start with the same prefix (e.g.,F1
,F2
,F3
,F4
) into thedata/raw_data
directory.
For the dataset F1
, repeat the following steps for other datasets:
python metalens/preprocessing/microscopy_registration_crop.py F1
python metalens/preprocessing/cell_segmentation.py F1
- Download the Ablation Mark (AM) segmentation model from this link.
- Place the downloaded model in the
models
directory. - Run the segmentation:
python metalens/preprocessing/AM_segmenation_inference.py F1
python metalens/preprocessing/make_training_patches.py F1
You can either use the pretrained model or train a new model:
- Download the pretrained model from this link.
- Place the model in the
models
directory.
python metalens/dl/train.py data/training_data models
To evaluate a model on a dataset (e.g., eval_dataset.tif
, download here and place in the data
directory), use the following command:
python metalens/dl/eval.py data/eval_dataset.tif models/pretrained_model.ckpt
This work is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/ . See the LICENSE
file for details.
We acknowledge the contributors to the SpaceM dataset and the developers of the tools integrated into this pipeline. Special thanks to the research community that has supported this work.