Skip to main content

A PyTorch implementation of the SPAGHETTI model for phase-contrast microscopy image transformation

Project description

SPAGHETTI - SSIM-restrained Phase Contrast Microscopy GAN for H&E Translation of Images

Implementation of the SPAGHETTI method for phase-contrast microscopy images pre-processing so that you can use your favourite H&E model on them.

Read the paper at some_big_journal_websites.

Installing SPAGHETTI

Installing using PyPI

SPAGHETTI is available on the Python Package Index (PyPI) to be installed with pip directly. To install, run:

pip install pcm-spaghetti

Installing Locally

Alternatively, you may also install SPAGHETTI from the GitHub repository directly. To do that, first create a virtual Python environment and install SPAHETTI locally.

virtualenv --no-download spaghetti
source spaghetti/bin/activate 
git clone https://github.com/schwartzlab-methods/spaghetti
cd spaghetti
python setup.py sdist bdist_wheel
pip install .

Inferences using SPAGHETTI

An example workflow of how to use SPAGHETTI to convert your phase-contrast microscopy images into H&E-like images can be found at ./tutorials/inference_example.py. Before running the example code, please ensure that you have cloned the default SPAGHETTI checkpoint file properly located at ./spaghetti_checkpoint.ckpt. If not, please go to the repository and directly download this checkpoint file.

Inferences with the CLI tool

Alternatively, you can also run inferences using the CLI interface to perform quick inferences. To do this, after you have installed SPAGHETTI, run:

python spaghetti --input path_to_directory_with_your_images \
--output path_to_directory_to_save_the_images --checkpoint path_to_the_checkpoint_file

The checkpoint file can either be the default checkpoint file (to be downloaded from ./spaghetti_checkpoint.ckpt), or can be the checkpoint files from your own training (see below for more details on how to train your own SPAGHETTI model).

Inferences with Docker Image

The CLI inference tool of SPAGHETTI is available as a Docker image so that you do not need to worry about setting up the environment. To use it, ensure you have Docker installed, then run:

docker pull yinnikun/spaghetti:latest

Before running the following command, please ensure that all your files (the input image/directory and the model checkpoint) is stored in one directory as we will need to mount this directory in the VM for Docker to run.

Suppose all your input files are stored at /usr/data/spaghetti_inferences/inputs/ and your model checkpoint is loacted at /usr/data/spaghetti_inferences/model.ckpt, and you want to save your results at /usr/data/spaghetti_inferences/outputs/, run the following command to performan the inference using Docker:

docker run --rm -v /usr/data/spaghetti_inferences/:/usr/data/ spaghetti \
--input /usr/data/inputs/ --output /usr/data/outputs/ --checkpoint /usr/data/model.ckpt

Training your own model

You can also train your own model to perform the inferences. See an example code at ./tutorials/train_example.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pcm-spaghetti-0.1.0.tar.gz (21.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pcm_spaghetti-0.1.0-py3-none-any.whl (31.1 kB view details)

Uploaded Python 3

File details

Details for the file pcm-spaghetti-0.1.0.tar.gz.

File metadata

  • Download URL: pcm-spaghetti-0.1.0.tar.gz
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.18

File hashes

Hashes for pcm-spaghetti-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e5167be7300cdc469e10b45e43697620214e2fb092874824822b35b3189bcfd1
MD5 5e08022fb1f24aacbc88bce039c32e3c
BLAKE2b-256 1eba7e3e33ae14c0183a98b05876c58936624dd1395f5abaa941e56321ba2638

See more details on using hashes here.

File details

Details for the file pcm_spaghetti-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pcm_spaghetti-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 31.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.18

File hashes

Hashes for pcm_spaghetti-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fd73e38dd7a27c56b162177e67cb2bd9d3438a0145662745bdf30fff626571bc
MD5 96a40eb9d695383cb80a4b664e3d314b
BLAKE2b-256 c1f39109b9850121565c2a334d98ceb814134801a054fe0f60d0dc20ab6d335f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page