Bleed-Through Correction in Fluorescent Microscopy Images
- From PyPI:
pip install "theia-py==0.1.2"
- Using poetry:
poetry add [email protected]
- Install xcode command line tools:
xcode-select --install
- Install miniforge:
- Disable the
base
conda environment from activating by default:
conda config --set auto_activate_base false
- Install poetry:
curl -sSL https://install.python-poetry.org | python3 -
- Add poetry to your path using the hint provided by the poetry installer.
- Create a conda environment:
conda create -n theia python=3.9
conda activate theia
- Install tensorflow dependencies:
conda install -c apple tensorflow-deps
- Install using poetry:
poetry add [email protected]
- Re-evaluate your life choices.
- Install Linux.
- Read this document from the beginning.
Here is a simple example of how to use Theia to correct a set of images.
For a more detailed example, see the streamlit app in examples/rxrx.py
.
import theia
# Load training and validation images
train_images = ...
valid_images = ...
# Make a tile-generator for feeding the model
train_generator = theia.TileGenerator(train_images, tile_size=(256, 256), normalize=False)
valid_generator = theia.TileGenerator(valid_images, tile_size=(256, 256), normalize=False)
# Build the model
model = theia.models.Neural(
num_channels=...,
channel_overlap=1,
kernel_size=5,
alpha=1,
beta=1,
tile_size=256,
)
model.early_stopping(
min_delta=1e-3,
patience=4,
verbose=1,
restore_best_weights=True,
)
model.compile(optimizer="adam")
model.fit_theia(
train_gen=train_gen,
valid_gen=valid_gen,
epochs=128,
verbose=1,
)
# Get the transformer
transformer = model.transformer
# Correct and save the images
for image in train_images + valid_images:
corrected_image = transformer.transform(image, remove_interactions=True)
with open("<path-to-image>", "w") as f:
...