FOCUS-3D provides a user-friendly napari plugin for interactive 3D cell segmentation and analysis.
🚀 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
Visit our website for examples, tutorials, and usage instructions: 🌐 FOCUS-3D Website
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.
conda create -n focus3d python=3.10 -y
conda activate focus3dFor 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/cu126Please check the official PyTorch installation guide if you need another CUDA version.
pip install -U "focus-3d[gui]"Users can download the pretrained model for 3D segmentation: https://huggingface.co/Qinghua-thu/FOCUS-3D/.
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'python -m napari- 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
- 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.
-
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.
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.
Open the Analysis tab after the segmentation has been checked.
- Select a non-background cell in the label layer.
- Set the
Z Ratio. - Click
Reconstruct Selected Label. - Save the reconstructed mesh as
.npzwhen needed.
- 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.
- 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.
Fine-tuning consists of preparing annotated training data and then running the fine-tuning notebook.
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.
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.
The complete descriptions of all controls are maintained in:
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.
@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}
}