FOCUS-3D
FOCUS-3D provides a user-friendly napari plugin for interactive 3D cell segmentation and analysis.
✨ What you can do
🚀 Run automatic 3D cell segmentation with pretrained FOCUS-3D models
✏️ Manually correct segmentation errors
🖱️ Perform one-click segmentation
🧩 Prepare curated patches for human-in-the-loop fine-tuning
🧠 Fine-tune FOCUS-3D models on your own data
🔬 Reconstruct selected 3D cell instances
📊 Compute quantitative statistics
📚 Examples & Tutorials
Visit our website for examples, tutorials, and usage instructions: 🌐 FOCUS-3D Website
☁️ Try FOCUS-3D Online
Want to try FOCUS-3D without installing anything? 🚀 FOCUS-3D Online on Hugging Face Spaces allows you to upload your own 3D fluorescence microscopy data for quick online inference and testing.
Installation
1. Create a new environment
conda create -n focus3d python=3.10 -y
conda activate focus3d
2. Install torch
For CUDA 12.x, replace cu12x with your specific CUDA-compatible PyTorch build. For example, for CUDA 12.6:
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu126
Please check the official PyTorch installation guide if you need another CUDA version.
3. Install FOCUS-3D
pip install -U "focus-3d[gui]"
4. Download pretrained model
Users can download the pretrained model for 3D segmentation: https://huggingface.co/Qinghua-thu/FOCUS-3D/.
5. Install detectron2 (optional, only for Linux model fine-tuning)
For Linux, FOCUS-3D requires Detectron2 for segmentation model fine-tuning. Please install Detectron2 according to the official guide:
https://detectron2.readthedocs.io/en/latest/tutorials/install.html
For most Linux environments, the official source installation command is:
python -m pip install --no-build-isolation 'git+https://github.com/facebookresearch/detectron2.git'
6. Launch napari
python -m napari
Recommended Workflow
Step 1 — Load and inspect the image
- In napari, open
Plugins -> 3D Segmentation (FOCUS-3D). - Load a raw 3D microscopy image:
- use
File -> Open Folderfor a.zarrdataset, which is recommended for large volumes; - use
File -> Open File(s)for.tifor.tiffimages.
- use
- Open the
Basictab and useDisplay Settingswhen the raw image is difficult to inspect:- move the
MinimumandMaximumsliders to adjust contrast; - click
Autofor percentile-based contrast adjustment;
- move the
Step 2 — Run automatic 3D segmentation
- Open the
Segmentationtab. - In
Run Segmentation, set the parameters that are most likely to vary between datasets:- Z Ratio — the physical Z-to-XY spacing ratio. Use
1.0for isotropic data. - Output Path — the directory used for the segmentation result.
- Checkpoint — the pretrained or fine-tuned checkpoint.
- Cell radius (pixel) — the approximate cell radius in the XY plane.
- Background intensity — patches or cells with grayscale values less than this value will be removed.
- Min size (3D) and Max size (3D) — remove small or large instances.
- Z Ratio — the physical Z-to-XY spacing ratio. Use
- Use
Advancedonly when you need to change the GPU, configuration file, normalization percentiles, patch stride, batch size, or stitching thresholds. See the complete menu reference for parameter definitions and defaults. - Click
Run 3D Segmentation.
After inference, FOCUS-3D loads a label layer into napari. The inference outputs are saved to the specified output path in both TIFF and Zarr formats.
Step 3 — Inspect and curate the segmentation
-
Return to the
Basictab. -
Click
Enter Curation Mode, then click a cell label to select it. -
Correct common errors:
- use
Add to Labelto recover missing regions; - use
Subtract from Labelto remove incorrect regions; - use
Add New Labelfor a missed cell; - use
Delete Current Zfor a slice-specific error; - use
Delete All Zto remove an incorrect 3D instance; - use
Delete Inside ROI (All Z)to remove multiple labels in a selected region.
For detailed instructions on label-editing operations and keyboard shortcuts, see Manual Curation.
- use
-
For labels stored in Zarr format, edits are written directly to the underlying Zarr data, so no separate save step is required. Labels loaded from TIFF are edited in memory and must be saved manually from the
Savepanel after curation.
Step 4 — Use one-click segmentation when needed
One-click segmentation can accelerate the curation.
- Keep both the raw image and segmentation label layer loaded.
- Open
Segmentation -> One-click segmentation. - Click
Enter Inactive Modeto load the local refinement model and activate interactive refinement. - Click the target cell in the viewer and inspect the updated label.
- Click
Exit Inactive Modeafter finishing.
Step 5 — Analyze the segmentation results
Open the Analysis tab after the segmentation has been checked.
Reconstruct one selected cell
- Select a non-background cell in the label layer.
- Set the
Z Ratio. - Click
Reconstruct Selected Label. - Save the reconstructed mesh as
.npzwhen needed.
Inspect the full volume in 3D
- Set the physical
Z Ratio. - Click
Switch to 3D View. - Rotate and inspect the image and labels.
- Click
Switch to 2D Viewto return to slice navigation.
Run morphometry analysis
- Set the physical voxel size in Z, Y, and X.
- Choose an output folder.
- Run one or more tasks:
Basic Informationfor cell morphology and optional intensity measurements;Neighborhood Analysisfor centroid-based local organization;Contact Graph Analysisfor face-touching cell relationships;Clusteringfor feature-based cell grouping.
- Use
Show featureto map supported results back to the napari label volume.
Step 6 — Prepare training data and fine-tune the model
Fine-tuning consists of preparing annotated training data and then running the fine-tuning notebook.
A. Prepare training data
There are two ways to prepare the annotations:
-
If the entire volume has been annotated: you do not need to use
Calculate Valid Patchesin napari. Provide the fully annotated raw image and label volume to the fine-tuning notebook. The notebook includes code to automatically crop the full volume into training patches and organize them intoimagesTrandlabelsTr. -
If annotating the entire volume is impractical: use the napari plugin to curate selected patches:
- Keep the raw image and corrected label volume loaded.
- Open
Segmentation -> Finetune with Current Labels. - Click
Calculate Valid Patches. - Choose a
Patch IDand set theSave Path. - Click
Curate Selected Patch. - Correct the labels in the patch viewer and click
Save.
Curated patches are saved as:
<save_path>/
├── imagesTr/
│ ├── patch_0001.tif
│ └── ...
└── labelsTr/
├── patch_0001.tif
└── ...
Use Clear Patch Boxes to remove the patch overlays when finished.
B. Run fine-tuning from the notebook
The fine-tuning notebook is not included in the pip installation and must be downloaded separately from the FOCUS-3D repository.
Open:
notebooks/02_finetune.ipynb
If using a fully annotated volume, first run the notebook section that crops it into training patches. If patches were already exported from napari, directly set the notebook to use the prepared imagesTr and labelsTr directories.
Run fine-tuning to obtain a new checkpoint, then return to Segmentation -> Run Segmentation, select the new checkpoint in the Checkpoint field, and run segmentation again.
The napari plugin can assist with patch preparation, while model fine-tuning itself is performed in the notebook.
Detailed Interface Reference
The complete descriptions of all controls are maintained in:
Issues
If you encounter a problem, please file an issue with a detailed description, relevant logs, and a minimal example when possible. You can also contact zhangqh24@mails.tsinghua.edu.cn. We also look forward to collaborating and jointly developing new algorithms, or customizing models based on your data.
Citing
@article{zhang2026focus,
title={FOCUS-3D: Robust, generalizable volumetric cell segmentation for three-dimensional fluorescence microscopy},
author={Zhang, Qinghua and Mu, Zeyu and Liu, Boqi and Chi, Yunfeng and Li, Donglin and Wang, Wenjuan and Ni, Jian-Quan and Wan, Yinan and Yu, Li and Navajas Acedo, Joaquin and Yu, Guoqiang},
journal={bioRxiv},
year={2026},
doi={10.64898/2026.08.25.746907}
}
Metadata
Release files for focus-3d 0.1.21
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| focus_3d-0.1.21.tar.gz | 258.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| focus_3d-0.1.21-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 562.2 kB
Release files / focus_3d-0.1.21.tar.gz
| Download URL | focus_3d-0.1.21.tar.gz |
|---|---|
| Size | 258.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
18664d7cb7324c631f93c47a4a4660270c81e068602da623abb95cd6e21a67a5
|
|
BLAKE2b-256 checksum How to use checksums |
ca3ee42f431040cad2a766f6e1cc5a6374ed0fc1e873fc6cb86628a6884a8726
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.20
|
Release files / focus_3d-0.1.21-py3-none-any.whl
| Download URL | focus_3d-0.1.21-py3-none-any.whl |
|---|---|
| Size | 303.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0c4bb963febd20316239266df43e5382c5a03ff2334b8240170a25d3882c8814
|
|
BLAKE2b-256 checksum How to use checksums |
f6166782135ff77f1424e915839aa9028eee00c8d75792cb171c91cd18c1f619
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.20
|