This project explores a self-supervised learning framework for deconvolving 3D fluorescence microscopy volumes without access to ground truth. We extend DeepContrast to 3D and simulate training data using a physics-based forward model (PSF + noise). Our pipeline supports realistic degradation, modular 3D U-Net training in JAX/Equinox, and evaluation across diverse noise/blur levels.
├── archive/ # Old experimental notebooks
├── notebooks/ # Sample Jupyter notebooks for data generation, PSF simulation, and evaluation
├── report_visualization/ # Sample Scripts and notebooks used for creating visualization for the report
├── scripts/ # Sample Shell and Python scripts to automate dataset creation, training, and grid runs
├── simulator.py # Functions to simulate PSF degradation on volumes
├── train_unet3d.py # Training script for the 3D U-Net deconvolution model
├── unet3d_clean.py # Clean implementation of the 3D U-Net architecture (JAX/Equinox)
├── utils.py # Utility functions and helpers
├── environment.yml # Reproducible environment
├── .gitignore # Files and directories to ignore in version control
├── SemesterProjectReportFinal.pdf # Report
└── README.md # Project overview and usage instructions
This project requires Python 3.9+ and JAX-compatible hardware (CPU or GPU). You can use Miniconda to manage environments.
conda env create -f environment.ymlThis will create a new environment called deconvolution (defined in the YAML file).
conda activate deconvolutionThe simulator.py script simulates 3D fluorescence microscopy images by convolving real or simulated biological sample with a point spread function (PSF), then adding realistic noise (Gaussian and Poisson) and a controllable background offset. This simulates measured images suitable for training or benchmarking deconvolution models.
- Convolution with a default or custom 3D PSF
- Additive Gaussian and Poisson noise
- Background signal simulation
- OME-TIFF input/output
To process all .ome.tif files in a directory:
python simulator.py \
--input_dir path/to/directory \
--output_dir path/to/directory \
--psf path/to/psf.npy \
--sigma_g 0.001 \
--alpha_p 100 \
--background 10 \
--label measuredFor example, to create the "measured" samples from the original/ideal samples:
python simulator.py \
--input_dir /home/dcorrea/deconvolution/data/tubes/ideal \
--output_dir /home/dcorrea/deconvolution/data/tubes/Gaussian/measured \
--psf /home/dcorrea/deconvolution/data/tubes/Gaussian/psf_gaussian.npy \
--sigma_g 0.001 \
--alpha_p 100 \
--background 10 \
--label measured| Argument | Description |
|---|---|
--input |
Path to a single 3D .ome.tif file, If --input is provided we only porcess that single single file. |
--input_dir |
Input directory containing OME-TIFF files (.ome.tif). All such files will be processed. |
--psf |
PSF file (.npy format). If not provided, a default PSF will be generated using the PSF generator. |
--sigma_g |
Standard deviation of Gaussian noise (e.g. read noise) If not provided, no Gaussian noise will be added. |
--alpha_p |
Poisson noise scaling factor. Scaling factor for converting intensities. If not provided, no Poisson noise will be added. |
--background |
Background level as a percentage of max intensity (e.g., 10 = 10%) |
--label |
Optional suffix label for output files (default: "degraded") |
--output_dir |
Output directory where the simulated images will be saved (used when processing multiple files). |
--visualize |
If set, shows the middle slice of the simulated volume (set to false if processing many files to avoid spam) |
Each processed .ome.tif volume will result in a new file:
basename_degraded.ome.tif
Stored in the specified --output_dir.
This script trains the 3D U-Net (defined in unet3d_clean.py) on simulated fluorescence microscopy volumes to perform deconvolution. It uses 3D patches from matched ground truth and degraded inputs, and supports training with or without SSIM-based loss.
python train_unet.py \
--gt_dir data/ground_truth \
--sim_dir data/simulated \
--id run_ssimTrue \
--epochs 40 \
--batch_size 1 \
--learning_rate 0.003 \
--checkpoint_every 5 \
--num_volumes 30 \
--use_ssim \
--ssim_weight 0.5 \
--psf_file psfs/default_psf.npy| Argument | Description |
|---|---|
--gt_dir |
Directory with ground truth OME-TIFF volumes |
--sim_dir |
Directory with simulated (blurred/noisy) OME-TIFF volumes |
--id |
Unique run name used for the experiment folder |
--epochs |
Number of training epochs |
--batch_size |
Batch size for training (default: 1) |
--learning_rate |
Learning rate for Adam optimizer |
--checkpoint_every |
Save a model checkpoint every N epochs |
--num_volumes |
Number of full 3D volumes to use for training |
--use_ssim |
If set, SSIM loss is included alongside MAE |
--ssim_weight |
Relative weight of SSIM in total loss |
--psf_file |
PSF .npy file for visualization comparisons |
All outputs are saved in experiments/<run_id>/:
| File | Description |
|---|---|
model_final.eqx |
Final trained model saved with Equinox serialization |
model_epoch_*.eqx |
Model checkpoints saved every --checkpoint_every epochs |
ideal.ome.tif |
Ground truth test volume used for evaluation |
degr.ome.tif |
Degraded input volume for prediction |
pred.ome.tif |
Final model prediction on test volume |
epoch_X_comparison.png |
4-panel visualization of GT / degraded / prediction / RL deconvolution for epoch X |
loss_epoch_X.png |
Training/validation curves for epoch X showing total loss, MAE, and SSIM |
train_debug.log |
Training progress and gradient stats per epoch |
metrics.json |
Final summary with training/test losses, MAE, SSIM, and metadata |
Each saved figure shows the central slice of the test volume:
- Ground truth
- Degraded input
- Model prediction
- Richardson–Lucy deconvolution (baseline)
Tracked and saved per epoch:
- MAE: Mean absolute error (per voxel)
- SSIM: Structural similarity (optional)
- Total Loss: Combination of MAE + weighted SSIM
You can adjust the relative weight using --ssim_weight.
- 3D U-Net with 2 downsampling and 2 upsampling blocks
- Dropout in bottleneck and decoder
- Optional bilinear vs transposed upsampling
- Uses
equinoxmodules for efficient and functional model definitions
If there are any questions, you can reach me at daniela.correa@epfl.ch