{"name":"focus-3d","display_name":"FOCUS-3D","visibility":"public","icon":"","categories":[],"schema_version":"0.2.1","on_activate":null,"on_deactivate":null,"contributions":{"commands":[{"id":"focus-3d.get_reader","title":"Open data with FOCUS-3D","python_name":"focus3d._reader:napari_get_reader","short_title":null,"category":null,"icon":null,"enablement":null},{"id":"focus-3d.write_multiple","title":"Save multi-layer data with FOCUS-3D","python_name":"focus3d._writer:write_multiple","short_title":null,"category":null,"icon":null,"enablement":null},{"id":"focus-3d.write_single_image","title":"Save image data with FOCUS-3D","python_name":"focus3d._writer:write_single_image","short_title":null,"category":null,"icon":null,"enablement":null},{"id":"focus-3d.make_sample_data","title":"Load sample data from FOCUS-3D","python_name":"focus3d._sample_data:make_sample_data","short_title":null,"category":null,"icon":null,"enablement":null},{"id":"focus-3d.make_segmentation_widget","title":"Open FOCUS-3D Segmentation Widget","python_name":"focus3d._widget:SegmentationWidget","short_title":null,"category":null,"icon":null,"enablement":null},{"id":"focus-3d.make_tracking_widget","title":"Open FOCUS-3D Tracking Widget","python_name":"focus3d._widget:TrackingWidget","short_title":null,"category":null,"icon":null,"enablement":null}],"readers":[{"command":"focus-3d.get_reader","filename_patterns":["*.npy"],"accepts_directories":false}],"writers":[{"command":"focus-3d.write_multiple","layer_types":["image*","labels*"],"filename_extensions":[],"display_name":""},{"command":"focus-3d.write_single_image","layer_types":["image"],"filename_extensions":[".npy"],"display_name":""}],"widgets":[{"command":"focus-3d.make_segmentation_widget","display_name":"3D Segmentation","autogenerate":false}],"sample_data":[{"command":"focus-3d.make_sample_data","key":"unique_id.1","display_name":"FOCUS-3D"}],"themes":null,"menus":{},"submenus":null,"keybindings":null,"configuration":[]},"package_metadata":{"metadata_version":"2.4","name":"focus-3d","version":"0.1.1","dynamic":["license-file"],"platform":null,"supported_platform":null,"summary":"FOCUS-3D: a user-friendly napari plugin for interactive 3D cell segmentation, curation, and analysis","description":"# FOCUS-3D\n\n[![License BSD-3](https://img.shields.io/pypi/l/cellseg.svg?color=green)](https://github.com/Qinghua24/cellseg/raw/main/LICENSE)\n[![PyPI](https://img.shields.io/pypi/v/cellseg.svg?color=green)](https://pypi.org/project/cellseg)\n[![Python Version](https://img.shields.io/pypi/pyversions/cellseg.svg?color=green)](https://python.org)\n[![tests](https://github.com/Qinghua24/cellseg/workflows/tests/badge.svg)](https://github.com/Qinghua24/cellseg/actions)\n[![codecov](https://codecov.io/gh/Qinghua24/cellseg/branch/main/graph/badge.svg)](https://codecov.io/gh/Qinghua24/cellseg)\n[![napari hub](https://img.shields.io/endpoint?url=https://api.napari-hub.org/shields/cellseg)](https://napari-hub.org/plugins/cellseg)\n[![npe2](https://img.shields.io/badge/plugin-npe2-blue?link=https://napari.org/stable/plugins/index.html)](https://napari.org/stable/plugins/index.html)\n\nFOCUS-3D provides a user-friendly napari plugin for interactive 3D cell segmentation, manual curation, model fine-tuning, 3D reconstruction, and quantitative analysis. Users can run automatic 3D segmentation with pretrained FOCUS3D models, manually correct segmentation errors, perform one-click segmentation, prepare curated patches for human-in-the-loop fine-tuning, reconstruct selected 3D cell instances, and compute quantitative statistics within the same napari workflow.\n\n<img width=\"3839\" height=\"2082\" alt=\"image\" src=\"https://github.com/user-attachments/assets/2a9ccc08-3109-4b73-bcae-0514bcec2a86\" />\n\n## Installation\n\nYou can install `FOCUS-3D` with the following steps.\n\n### 1. Create a new environment\n\n```bash\ncd your_path\nconda env create -n FOCUS3D -f environment.yml\n```\n\n### 2. Install FOCUS-3D\n\n```bash\nconda activate FOCUS3D\npip install napari[all]\npip install -e .\n```\n\n### 3. Launch napari\n\n```bash\nnapari\n```\n\n## Usage\n\n1. Open FOCUS-3D from `Plugins -> FOCUS-3D`.\n2. Load the raw image from `File -> Open Folder` for a `.zarr` dataset, or `File -> Open File(s)` for `.tif` images.\n3. Use the `Basic`, `Segmentation`, and `Analysis` tabs to load labels, run FOCUS3D segmentation, manually curate results, fine-tune models, reconstruct 3D structures, and calculate quantitative statistics.\n\n## FOCUS-3D Overview\n\nFOCUS-3D provides an integrated workflow for 3D microscopy image analysis. It combines automatic segmentation, interactive correction, local one-click refinement, curated patch generation, model fine-tuning, 3D label reconstruction, and quantitative measurement in a single napari-based interface. This design allows users to move smoothly from raw 3D images to corrected segmentation results and downstream analysis, while also supporting human-in-the-loop improvement of FOCUS3D models using newly curated annotations.\n\n## Basic Menu\n\nThe `Basic` menu provides functions for loading segmentation labels, adjusting image display, manually curating labels, and saving edited results.\n\n### Load Label\n\n| Operation | Description |\n|---|---|\n| Load from Zarr | Load an existing 3D label map from a `.zarr` folder. This is recommended for large 3D volumes because it supports efficient data access and editing. |\n| Load from TIFF | Load an existing 3D label map from a `.tif` or `.tiff` file. |\n| Only Show Contour | Display label contours instead of filled label masks, making it easier to inspect boundaries and compare labels with the raw image. |\n\n### Display Settings\n\n| Operation | Description |\n|---|---|\n| Minimum / Maximum | Adjust the display contrast range of the currently selected image layer. |\n| Auto | Automatically estimate a suitable contrast range for the active image layer using robust intensity percentiles. |\n| Reset Contrast | Reset the contrast range of the active image layer. |\n| Channel Composite | Select one or more image layers and assign different colormaps for multi-channel visualization. |\n| Apply | Apply the selected channel visibility and colormap settings. |\n| Reset Display | Reset image layers to the default display mode. |\n\n### Manual Curation\n\n| Operation | Shortcut | Description |\n|---|---|---|\n| Enter Curation Mode | — | Activate label editing mode. Users can click on an existing label to select and modify it. |\n| Polygon Draw Mode | — | Define an ROI by clicking polygon vertices. The enclosed region is used for label editing. |\n| Brush Draw Mode | — | Define an ROI by painting directly on the image. The painted region is used for label editing. |\n| Trace Draw Mode | — | Define an ROI using trace-based drawing. |\n| Brush Size | `+` / `-` | Adjust the ROI brush size or label brush size. |\n| Brush Color | — | Change the display color of the ROI brush. |\n| Add to Label | `A` | Add the selected ROI to the currently selected label. |\n| Subtract from Label | `S` | Remove the selected ROI from the currently selected label. |\n| Add New Label | `Ctrl + D` | Create a new label. Regions from multiple Z slices can be combined into the same 3D instance. |\n| Change Label | `C` | Change the ID of the currently selected label. |\n| Apply ROI | `Ctrl + A` | Apply the current ROI operation. Used with **Add to Label**, **Subtract from Label**, and **Add New Label**. |\n| Cancel ROI | `Ctrl + C` | Cancel the current ROI operation without applying changes. |\n| Delete Current Z | `Delete` | Delete the selected label only on the current Z slice. |\n| Delete All Z | `Ctrl + Delete` | Delete the selected label across all Z slices. |\n| Delete Inside ROI (All Z) | — | Delete all labels inside the selected ROI across all Z slices. |\n| Show Log File | — | Open or show the curation log file that records editing operations. |\n| Previous Slice | `Q` | Move to the previous Z slice. |\n| Next Slice | `W` | Move to the next Z slice. |\n| Undo Local Refinement | `Ctrl + Z` | Undo the latest one-click local refinement result when available. |\n\n### Save\n\n| Operation | Description |\n|---|---|\n| Browse | Select the folder for saving the current label result. |\n| Save format | Choose the output format, including `Zarr (recommended)` or `TIFF`. |\n| Update Labels | Reassign label IDs before saving so that labels are stored in a clean consecutive order. |\n| Save | Save the current label layer to the selected output path. |\n\n## Segmentation Menu\n\nThe `Segmentation` menu provides automatic 3D segmentation with **FOCUS3D**, one-click local segmentation refinement, and human-in-the-loop fine-tuning based on curated labels.\n<img width=\"3839\" height=\"2084\" alt=\"image\" src=\"https://github.com/user-attachments/assets/74b6b9ae-0a00-4b40-bb31-fb743709c725\" />\n\n### Run Segmentation\n\n| Parameter / Operation | Description |\n|---|---|\n| Z Ratio | Set the physical Z-to-XY spacing ratio for anisotropic 3D data. |\n| Output Path | Set the output folder for FOCUS3D segmentation results. By default, the plugin creates an output folder based on the input image path. |\n| GPU IDs | Select the GPU device used for inference, such as `0`, `1`, or `0,1`. |\n| Refresh | Refresh the list of available GPU devices. |\n| Advanced | Expand or collapse advanced inference settings. |\n| Checkpoint | Select the pretrained FOCUS3D model checkpoint. The default path is relative to the FOCUS3D backend folder. |\n| Configure | Select the FOCUS3D configuration file. The default configuration is `configs/3d_test.yaml`. |\n| Lower / Upper Percentile | Set the intensity percentile range for image normalization before inference. |\n| Patch size (Z/Y/X) | Set the 3D patch size used for sliding-window inference. |\n| Stride (Z/Y/X) | Set the stride between neighboring inference patches. Smaller strides increase overlap but require more computation. |\n| Background intensity | Ignore patches whose maximum intensity is below this threshold. |\n| Batch size | Set the inference batch size. Larger values may improve speed but require more GPU memory. |\n| Score confidence | Set the object-level confidence threshold for accepting predicted instances. |\n| Mask confidence | Set the voxel-level mask confidence threshold for generating instance masks. |\n| Min area (2D) | Remove small 2D components below the specified area threshold during stitching or post-processing. |\n| Min size (3D) | Remove 3D objects smaller than the specified voxel size. A value of `0` disables minimum-size filtering. |\n| Max size (3D) | Remove 3D objects larger than the specified voxel size. The default value is `100000`. |\n| Run 3D Segmentation | Run automatic 3D segmentation using FOCUS3D. The result is loaded back into napari as an editable label layer, and the confidence map can also be saved or visualized. |\n\n### One-click Segmentation\n\n| Operation | Description |\n|---|---|\n| Enter Inactive Mode | Load the one-click segmentation model and enter interactive local segmentation mode. After entering this mode, users can click on a target cell region to trigger local refinement. |\n| Exit Inactive Mode | Exit one-click segmentation mode and return to normal interaction. |\n| Status Label | Display the current status of the one-click segmentation module, such as inactive, loading, active, or busy. |\n| Local Refinement | Use the pretrained FOCUS3D model to refine a clicked cell or local region, supporting fast correction of missed or inaccurate instances. |\n| Undo | Undo the latest one-click segmentation refinement result with `Ctrl + Z`. |\n\n### Finetune with Current Labels\n\n| Operation | Description |\n|---|---|\n| Calculate Valid Patches | Automatically scan the current image and label volume to find valid 3D patches for fine-tuning. Patches are selected according to patch size, stride, and intensity threshold. |\n| Select Patch ID | Select a valid patch by ID. The corresponding patch region is highlighted in the viewer. |\n| Save Path | Set the folder for saving curated training patches. The expected structure is `imagesTr/` and `labelsTr/`. |\n| Curate Selected Patch | Open the selected 3D patch in a new napari viewer for focused manual correction. |\n| Save Curated Patch | Save the curated patch image and label into `imagesTr/` and `labelsTr/`. |\n| Checkpoint Dir | Set the output directory for fine-tuned FOCUS3D checkpoints. |\n| Run Fine-tune | Fine-tune the FOCUS3D model using the curated patches. After fine-tuning, the newly generated checkpoint can be used for subsequent segmentation. |\n\n## Analysis Menu\n\nThe `Analysis` menu provides tools for 3D structure reconstruction, full-volume 3D visualization, and quantitative statistics.\n\n<img width=\"3839\" height=\"2087\" alt=\"image\" src=\"https://github.com/user-attachments/assets/7d499c7c-952c-4ad0-a2a4-5f1b9896d0f3\" />\n\n### 3D Label Reconstruction\n\n| Operation | Description |\n|---|---|\n| Z Ratio | Set the physical Z-to-XY ratio for 3D reconstruction. This is important for anisotropic microscopy volumes. |\n| Reconstruct Selected Label | Reconstruct the selected label as a 3D mesh for visualization and downstream analysis. |\n| Load Mesh | Load a previously saved 3D mesh file. |\n| Save Mesh | Save the reconstructed 3D mesh. |\n\n### Full 3D View\n\n| Operation | Description |\n|---|---|\n| Z Ratio | Set the Z-axis scaling factor for full-volume 3D visualization. |\n| Switch to 3D View | Switch the current napari viewer between 2D slice view and 3D visualization mode. |\n\n### Quantitative Statistics\n\n| Operation | Description |\n|---|---|\n| Calculate Size Distribution | Calculate cell count and cell size distribution from the current label layer. This can be used for basic quantitative analysis of segmentation results. |\n\n## Recommended Workflow\n\nA typical workflow is:\n\n1. Load the raw 3D microscopy image into napari.\n2. Run automatic 3D segmentation with **FOCUS3D** from the `Segmentation` menu.\n3. Inspect the segmentation result in the `Basic` menu.\n4. Correct segmentation errors using manual curation tools such as **Add to Label**, **Subtract from Label**, **Add New Label**, and **Delete Inside ROI**.\n5. Use **One-click Segmentation** for fast local correction of difficult or missed cells.\n6. Save the curated labels as `.zarr` or `.tif`.\n7. Optionally select valid curated patches and fine-tune FOCUS3D with the corrected labels.\n8. Use the `Analysis` menu for 3D reconstruction, full 3D visualization, and quantitative statistics.\n\n## License\n\nDistributed under the terms of the [BSD-3] license, `FOCUS-3D` is free and open source software.\n\n## Issues\n\nIf you encounter any problems, please [file an issue] along with a detailed description or contact zhangqh24@mails.tsinghua.edu.cn.\n\n[napari]: https://github.com/napari/napari\n[BSD-3]: http://opensource.org/licenses/BSD-3-Clause\n[pip]: https://pypi.org/project/pip/\n[PyPI]: https://pypi.org/\n","description_content_type":"text/markdown","keywords":null,"home_page":null,"download_url":null,"author":"Qinghua Zhang","author_email":"zhangqh24@mails.tsinghua.edu.cn","maintainer":null,"maintainer_email":null,"license":null,"classifier":["Development Status :: 2 - Pre-Alpha","Framework :: napari","Intended Audience :: Developers","Operating System :: OS Independent","Programming Language :: Python","Programming Language :: Python :: 3","Programming Language :: Python :: 3 :: Only","Programming Language :: Python :: 3.10","Programming Language :: Python :: 3.11","Programming Language :: Python :: 3.12","Programming Language :: Python :: 3.13","Topic :: Scientific/Engineering :: Image Processing"],"requires_dist":["numpy","magicgui","qtpy","scikit-image","scipy","pandas","tifffile","zarr","imageio","pyyaml","requests","dask","fsspec","numcodecs","pillow","matplotlib","napari[all]; extra == \"all\"","torch; extra == \"all\"","torchvision; extra == \"all\""],"requires_python":">=3.10","requires_external":null,"project_url":null,"provides_extra":["all"],"provides_dist":null,"obsoletes_dist":null},"npe1_shim":false}