Skip to main content

SPAGHETTI - Structural Phase Adaptation via Generative Histological Enhancement and Texture-preserving Translation Integration

PyPI version

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

Read the documentation at documentations.md

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:

python3 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

For a dependency-free and reproducible environment, the CLI inference tool of SPAGHETTI is available as a Docker image. To use it, ensure you have Docker installed, then run:

Option 1: Use the Pre-built Image from Docker Hub

The official image is hosted on Docker Hub.

  1. Pull the latest image:

    docker pull yinnikun/spaghetti:latest
    
  2. Run Inference:

    To run inference, you need to mount a local directory into the container. This directory should contain your input images and the model checkpoint. The container will write the output images back to this same directory.

    Let's say your local data is organized as follows:

    /path/to/your/data/
    ├── inputs/
    │   ├── image1.tif
    │   └── image2.tif
    ├── spaghetti_checkpoint.ckpt
    └── outputs/  <-- This will be created
    

    Execute the following command:

    docker run --rm -v "/path/to/your/data:/data" yinnikun/spaghetti:latest \
      --input /data/inputs \
      --output /data/outputs \
      --checkpoint /data/spaghetti_checkpoint.ckpt
    
    • --rm: Automatically removes the container when it exits.
    • -v "/path/to/your/data:/data": Mounts your local data directory into the /data directory inside the container. Remember to use absolute paths.

Option 2: Build the Image Locally

You can also build the Docker image directly from the dockerfile in this repository.

  1. Build the image:

    docker build -t spaghetti:latest .
    
  2. Run Inference: The docker run command is the same as above, just replace the image name:

    docker run --rm -v "/path/to/your/data:/data" spaghetti:latest \
      --input /data/inputs \
      --output /data/outputs \
      --checkpoint /data/spaghetti_checkpoint.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

Release files for pcm-spaghetti 1.2.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 pcm-spaghetti 1.2.2
File Size Uploaded
pcm_spaghetti-1.2.2.tar.gz 22.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pcm-spaghetti 1.2.2
File Interpreter ABI Platform
pcm_spaghetti-1.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 47.3 kB

Release files / pcm_spaghetti-1.2.2.tar.gz

Download URL pcm_spaghetti-1.2.2.tar.gz
Size 22.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c61b8797c5fe89407db223d3ff234747810566ad4153a0cea1c5973b7a719928
BLAKE2b-256 checksum
How to use checksums
7e3e9dc1ebff99d7649ba5276d488e623153b8397375f7962d279ea8bb665118
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 20, 2026.

Transparency log

Release files / pcm_spaghetti-1.2.2-py3-none-any.whl

Download URL pcm_spaghetti-1.2.2-py3-none-any.whl
Size 24.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ffb1a69dabd19f39ef4fff3a75f0290ce8f664910ad237bf3778ec6426d63859
BLAKE2b-256 checksum
How to use checksums
e4a826da2d5cb552b4740b61e8b0cdde516e6d8aea05eb28b1147f267aa24f2f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 20, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.2.2 This release

2 release files

1.2.1

2 release files

1.2

2 release files

1.1.1

2 release files

1.1

2 release files

1.0.2

2 release files

1.0.1

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