ReScale4DL: Balancing Pixel and Contextual Information for Enhanced Bioimage Segmentation
A systematic approach for determining optimal image resolution in deep learning-based microscopy segmentation, balancing accuracy with acquisition/storage costs. Following this approach, researchers can improve the sustainability and cost-effectiveness of bioimaging studies by reducing data and computing needs while optimising microscopy techniques.
Key Features
- Resolution simulation: Rescale images and their respective annotations (upsample and downsample)
- Segmentation evaluation: Compare performance across resolutions using:
- Mean Intersection-over-Union (IoU)
- Morphological features
- Potential throughput
- Personalised metrics
- Visualization tools: Generate comparative plots and sample outputs
Installation
ReScale4DL is available as a Python package through pip. Activate your conda environment or create one:
conda create -n rescale4dl "python<=3.12"
conda activate rescale4dl
Install ReScale4DL with pip:
pip install rescale4dl
Manual installation
Manual installation using the GitHub repository
git clone https://github.com/HenriquesLab/ReScale4DL.git
cd rescale4dl
conda create -n rescale4dl "python<=3.12"
conda activate rescale4dl
python -m pip install .
Usage
1. Image Rescaling
Notebook: Rescale_Images.ipynb
2. Segmentation Analysis
Notebook for 2D images: Evaluate_Segmentation_2D.ipynb
Notebook for 3D images: Evaluate_Segmentation_3D.ipynb
Notebook to reproduce ReScale4DL results on real acquisitions: Evaluate_Segmentation_real_acquisirions.ipynb
3. Rescale and crop to test foundation models
Notebook: Rescale_Foundation_Models.ipynb
How to use demo
https://github.com/user-attachments/assets/ff67aee1-9e7b-45c1-93f5-7e4c66c6c860
https://github.com/user-attachments/assets/74defb21-9470-4cf3-b993-d6710cfb22c4
Additional DL resources for microscopy:
The deep learning networks presented in the ReScale4DL paper were trained using the following platforms:
- ZeroCostDL4Mic: A Google Colab-based no-cost toolbox to explore Deep Learning in Microscopy
- DL4MicEverywhere: Docker-based implementation bringing the ZeroCostDL4Mic experience for local deployment
For detailed hyperparameter settings and training configurations, please refer to Table 1 in our bioRxiv preprint.
Scripts
ReScale4DL provides a set of functionalities to quickly analyse your images and find an optimal pixel size:
- Rescaling the images in the path by donwsampling with a factor of 2 and 3, and by upsampling with a factor of 2:
rescale4dl.batch.process_all_datasets(“/path/data”, [2,3], [2], [1], modes=[“mean”])
- Analyse the segmentation results for different scaling factors in 2D:
rescale4dl.analyse(“/path/data”)
- Analyse the segmentation results for different scaling factors in 3D:
rescale4dl.analyse(“/path/data”,
is_3d=True,
run_per_object_stats = False, # True for Instance Segmentation, False for Semantic or Binary Segmentation
save_images = False, # True to save images of the segmentation examples and data distributions, False to skip saving images and saving some memory
sampling_dir_list = None)
Contributing
We welcome contributions through:
License
MIT License - See LICENSE for details
How to cite this work
Ferreira, M.G., Saraiva, B.M., Brito, A.D., Pinho, M.G., Henriques, R. and Gómez-de-Mariscal, E., ReScale4DL: Balancing Pixel and Contextual Information for Enhanced Bioimage Segmentation. bioRxiv, pp.2025-04, (2025) https://doi.org/10.1101/2025.04.09.647871
@article{ferreira2025rescale4dl,
title={ReScale4DL: Balancing Pixel and Contextual Information for Enhanced Bioimage Segmentation},
author={Ferreira, Mariana G and Saraiva, Bruno M and Brito, Ant{\'o}nio D and Pinho, Mariana G and Henriques, Ricardo and G{\'o}mez-de-Mariscal, Estibaliz},
journal={bioRxiv},
pages={2025--04},
year={2025},
publisher={Cold Spring Harbor Laboratory},
URL = https://doi.org/10.1101/2025.04.09.647871
}
Metadata
Release files for rescale4dl 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rescale4dl-0.2.3.tar.gz | 56.7 kB | Without provenance | Details for rescale4dl-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rescale4dl-0.2.3-py3-none-any.whl | Python 3 | none | any | Details for rescale4dl-0.2.3-py3-none-any.whl |
Total release size: 108.7 kB
Release files / rescale4dl-0.2.3.tar.gz
| Download URL | rescale4dl-0.2.3.tar.gz |
|---|---|
| Size | 56.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0c9b9a80dc6ae64e60a22bd7a0190d34bc8b2995dccaa1ae557ed7ca4a90f0f5
|
|
BLAKE2b-256 checksum How to use checksums |
2872cacb33852170608cb5a6090eb1413e245bfb516fcf9a02997f225758b6c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Release files / rescale4dl-0.2.3-py3-none-any.whl
| Download URL | rescale4dl-0.2.3-py3-none-any.whl |
|---|---|
| Size | 52.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7a08d25cdee2fe1211902c44681f866eb6db00ef54f66f3e8baf86ec56d021a7
|
|
BLAKE2b-256 checksum How to use checksums |
7b3b4703e6ecccf78da72cc0a120d0abc51e6a313080a442228be8a09870f05a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Security for rescale4dl 0.2.3
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.