Skip to content
/ MetaLens Public

MetaLens: Super-Resolved Spatial Metabolomics

License

Notifications You must be signed in to change notification settings

LRpz/MetaLens

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MetaLens: Codebase for Super-Resolved Spatial Metabolomics

This repository contains the codebase for the paper titled "Inferring super-resolved spatial metabolomics from microscopy".

Table of Contents

  1. Introduction
  2. Setup
  3. Training Data Preparation
  4. Model Training
  5. Model Inference
  6. License
  7. Acknowledgements

Introduction

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.

Setup

To set up the Python environment required for MetaLens, follow these steps:

conda create -n MetaLens python==3.10
conda activate MetaLens
pip install -r MetaLens/requirements.txt

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.

Training Data Preparation

The training data necessary for model development can be obtained and prepared as follows:

Download Pre-prepared Training Data

  1. Access the training data from this link.
  2. Download and extract the patches to the MetaLens/data/training_data directory.

Generate New Training Data

To generate new training data using other SpaceM datasets, follow these steps:

  1. Download the dataset archive from this link.
  2. 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 the MetaLens/data/raw_data directory.

For the dataset F1, repeat the following steps for other datasets:

a. Register and Crop Pre- and Post-MALDI Data

python MetaLens/preprocessing/microscopy_registration_crop.py F1

b. Segment Cells

python MetaLens/preprocessing/cell_segmentation.py F1

c. Segment Ablation Marks Using Pre-Trained Model

  1. Download the Ablation Mark (AM) segmentation model from this link.
  2. Place the downloaded model in the MetaLens/models directory.
  3. Run the segmentation:
python MetaLens/preprocessing/AM_segmenation_inference.py F1

d. Generate Training Patches

python MetaLens/preprocessing/make_training_patches.py F1

Model Training

You can either use the pretrained model or train a new model:

Using Pretrained Model

  1. Download the pretrained model from this link.
  2. Place the model in the MetaLens/models directory.

Train a New Model

python MetaLens/dl/train.py MetaLens/data/training_data MetaLens/models

Model Inference

To evaluate a model on a dataset (e.g., eval_dataset.tif, download here and place in the MetaLens/data directory), use the following command:

python MetaLens/dl/eval.py MetaLens/data/eval_dataset.tif MetaLens/models/pretrained_model.ckpt

License

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.

Acknowledgements

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.

About

MetaLens: Super-Resolved Spatial Metabolomics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages