This repository reproduces the experiments for SWITi: Quantifying and Reducing Tiling Artifacts with Sliding Window Inner Tiling. SWITi is a test-time procedure for posterior image-splitting models that averages shifted tiled predictions to reduce seam artifacts without increasing the number of forward passes required for an MMSE estimate. The paper also introduces reference-free tiling-artifact metrics based on gradient-distribution tests.
The data and MicroSplit model weights are downloaded from Zenodo:
- Dataset: https://zenodo.org/records/22213583
- Model weights: https://zenodo.org/records/22214478.
SWITi has been implemented in CAREamics, an image restoration deep-learning library. (Currently in the feature branch mc/feat/switi-merge).
The gradient test and Fourier Ring Correlation (FRC) metrics are implemented in the repository juglab/TilArtMetrics.
We recommend using uv to run the scripts from the repository root with uv run.
See the uv documentation.
-
Download data and checkpoints.
uv run scripts/download.py --output-dir switi
This creates
switi/dataandswiti/checkpoints. -
Run baseline inner-tiling inference.
uv run scripts/microsplit_inner_tiling_inference.py \ --dataset HT_LIF24 \ --data-root switi/data \ --checkpoint-root switi/checkpoints \ --prediction-root switi/results \ --overlap 32 32 \ --mmse-count 64This writes stitched predictions and
inference_params.jsonunderinner_tiling. -
Run SWITi inference.
uv run scripts/microsplit_switi_inference.py \ --dataset HT_LIF24 \ --data-root switi/data \ --checkpoint-root switi/checkpoints \ --prediction-root switi/results \ --overlap 32 32 \ --mmse-count 64For 3D datasets, pass a 3-axis overlap and
--stride-z, for example--overlap 2 32 32 --stride-z 1. -
Compute global image-quality metrics.
uv run scripts/microsplit_compute_metrics.py \ --dataset HT_LIF24 \ --prediction-root switi/results \ --prediction-subdir predictions_MMSE64 \ --method inner_tiling \ --data-root switi/data uv run scripts/microsplit_compute_metrics.py \ --dataset HT_LIF24 \ --prediction-root switi/results \ --prediction-subdir predictions_MMSE64 \ --method SWITi \ --data-root switi/dataThis writes
metrics.jsonandmetrics_per_image.jsonbeside each method's predictions. -
Run FRC analysis.
uv run scripts/run_frc_analysis_on_dataset.py \ --dataset HT_LIF24 \ --prediction-root switi/results \ --prediction-subdir predictions_MMSE64 \ --methods inner_tiling SWITi \ --data-root switi/data \ --ndim 2 \ --output-dir switi/resultsThis writes FRC reports,
summary.csv, and per-channel FRC curve figures underfrc. -
Run the gradient permutation test.
uv run scripts/run_gradient_test_on_dataset.py \ --dataset HT_LIF24 \ --prediction-root switi/results \ --prediction-subdir predictions_MMSE64 \ --methods inner_tiling SWITi \ --data-root switi/data \ --strip-width 1 \ --output-dir switi/resultsThis writes reports,
summary.csv, andgradient_test_config.jsonundergradient_test. -
Create example gradient-test overlay figures.
uv run scripts/example_gradient_test_figure.py \ --dataset HT_LIF24 \ --prediction-root switi/results \ --prediction-subdir predictions_MMSE64 \ --data-root switi/data \ --output-dir switi/results \ --image-name <input-image-stem>The figure script reads the gradient-test reports and writes significance-overlay PNGs into the same
gradient_testdirectory.
After the scripts above have run, the example directory should contain:
switi/
├── data/
│ └── HT_LIF24/
│ ├── inputs/
│ │ ├── train/*.tif
│ │ ├── val/*.tif
│ │ └── test/*.tif
│ ├── targets/
│ │ ├── train/*.tif
│ │ ├── val/*.tif
│ │ └── test/*.tif
│ └── stats.json
├── checkpoints/
│ └── HT_LIF24/
│ ├── BaselineVAECL_best.ckpt
│ └── config.yaml
└── results/
└── HT_LIF24/
└── predictions_MMSE64/
├── inner_tiling/
│ ├── predictions.npz
│ ├── inference_params.json
│ ├── metrics.json
│ └── metrics_per_image.json
├── sw_inner_tiling/
│ ├── predictions.npz
│ ├── inference_params.json
│ ├── metrics.json
│ └── metrics_per_image.json
├── gradient_test/
│ ├── gradient_test_config.json
│ ├── inner_tiling_gradient_report.json
│ ├── SWITi_gradient_report.json
│ ├── GT_gradient_report.json
│ ├── summary.csv
│ └── significance_overlay_<method>_channel<channel>.png
└── frc/
├── inner_tiling_frc_report.json
├── SWITi_frc_report.json
├── summary.csv
└── frc_curves_ch<channel>.pdf
*.tif: input and target microscopy images for each split.stats.json: cached per-channel normalization statistics computed from the training data.BaselineVAECL_best.ckpt: pretrained MicroSplit checkpoint.config.yaml: training configuration used to reconstruct the model and prediction data configuration.predictions.npz: stitched predictions keyed by input image stem.inference_params.json: tile geometry, MMSE count, checkpoint path, and data path used for inference.metrics.json: dataset-average global image-quality metrics.metrics_per_image.json: global image-quality metrics for each predicted image.gradient_test_config.json: parameters used for the gradient permutation test.<method>_gradient_report.json: per-method gradient-test report.GT_gradient_report.json: gradient-test report for the ground truth reference, when included.significance_overlay_<method>_channel<channel>.png: example gradient-test overlay figures.<method>_frc_report.json: per-method FRC report.frc_curves_ch<channel>.pdf: FRC summary figure for one channel.
The hpc directory contains SLURM wrappers for the same workflow, which contain the arguments used to run the experiments:
hpc/microsplit_inner_tiling.sbatch
hpc/microsplit_switi.sbatch
hpc/microsplit_metrics.sbatch
hpc/run_gradient_test.sbatch
hpc/run_frc_analysis.sbatch