Important
This repository is the official implementation of Adaptive-SN2N.
Artifact-suppressed and adaptive self-inspired learning denoising for super-resolution fluorescence microscopy.
This repository contains the official source code for our paper, "Artifact-suppressed and adaptive self-inspired learning denoising for super-resolution fluorescence microscopy". This work introduces Adaptive-SN2N, an enhanced self-inspired learning framework for image denoising in fluorescence microscopy. Our method is specifically designed to suppress background artifacts, a common challenge in biological image analysis, by incorporating a risk-aware adaptive normalization strategy and a Gaussian-weighted overlap-tile inference mechanism.
Published paper DOI: https://doi.org/10.3724/PXLIFE.2025-0010
✨ Introduction | 🔧 Installation | 🎨 Data Generation | 💻 Training & Inference | 📜 License
Adaptive-SN2N is an enhanced self-inspired learning framework for image denoising in fluorescence microscopy. It overcomes the limitations of standard self-supervised methods by:
- Suppressing Background Artifacts: Utilizing a risk-aware adaptive normalization strategy.
- Adaptive Inference: Implementing a Gaussian-weighted overlap-tile inference mechanism for seamless reconstruction.
- Dual-Mode Learning: Supporting both global and local learning modes to adapt to different noise characteristics.
- Python >= 3.8
- PyTorch >= 1.12
- Other dependencies:
numpy,scipy,scikit-image,tifffile,matplotlib,pandas
-
Clone the repository.
git clone https://github.com/YourUsername/aSN2N.git cd aSN2N -
Install the required dependencies.
pip install -r requirements.txt
Before training the model, you need to generate an unsupervised training dataset from your raw microscopy images(preferably with images in tif format) using Scripts_aSN2N_datagen.py. This script generates "Global" and "Local" mode datasets required for the adaptive learning process.
Run the script from the command line:
python Scripts_aSN2N_datagen.py --train_data_path "path/to/raw/images" --output_base_path "path/to/save/data" --both_modes -----Parameters------
--train_data_path: (Required)
Path to the directory containing your raw training images (e.g., .tif files).
--output_base_path: (Optional, default: './output')
Base path where the generated datasets will be saved.
Subdirectories 'global' and 'local' will be created automatically.
--both_modes: (Optional, flag)
If set, generates BOTH global and local datasets regardless of the adaptive decision.
--vis_patches: (Optional, flag)
Enable visualization of individual patches for debugging/analysis.
--vis_overlay: (Optional, flag)
Enable visualization of risk overlay on images.
--export_csv: (Optional, flag)
Export patch metrics to CSV for analysis.
The training and inference processes are integrated into Scripts_aSN2N_train.py. This script supports multi-GPU training and is configured via a JSON file.
Create a configuration file (e.g., Config/your_config.json) based on the provided example in Config/example.json.
Example Configuration (Config/example.json):
[
{
"dataset_name": "experiment_name",
"train_data_path": "path/to/generated/training_data",
"test_path": "path/to/raw/data/for/inference",
"epochs": 60,
"train_batch_size": 32,
"test_batch_size": 1,
"reg_sparse": 0,
"reg": 0.5,
"work_mode": "local",
"inference_mode": "local"
}
]- work_mode: Set to
"local"or"global"depending on the dataset being trained. - inference_mode: Defines the inference strategy (usually matches
work_mode).
Before running the script, ensure the config_path in Scripts_aSN2N_train.py points to your configuration file, or modify the script to load your specific JSON file.
# In Scripts_aSN2N_train.py
config_path = './Config/your_config.json' Run the training script:
python Scripts_aSN2N_train.pyThe script will:
- Automatically detect available GPUs.
- Distribute experiments defined in the JSON config across GPUs.
- Train the model and perform inference on the
test_pathdata. - Save results (images and checkpoints) in the
./images/directory.
This software and corresponding methods can only be used for non-commercial use, and they are under Open Data Commons Open Database License v1.0.