Skip to content

Commit b6d27d9

Browse files
authored
Update and run all pre commit hooks (#121)
* Consolidate project config into pyproject and modernize CI Remove legacy packaging and test config files (setup.cfg, requirements.txt, .isort.cfg, napari_cellseg3d/_tests/pytest.ini, and its conftest). Migrate and update metadata in pyproject.toml: bump supported Python classifiers to 3.10–3.12, add napari manifest entry-point, include napari.yaml in package data, simplify dynamic fields, adjust optional dependencies (add PyQt6, pyside6, move pydensecrf2 to crf extra) and streamline dev dependencies (remove black/isort as direct dev deps). Update tooling rules (ruff token change) and remove redundant tool configs. Update tox.ini to target py310/311/312 across linux/windows/macos, expose platform mappings for GH Actions, and switch to using extras for test/crf/pyqt6 while keeping usedevelop and running pytest as the test command. * Modernize pyproject and update pre-commit hooks Bump and extend pre-commit configuration and migrate pyproject to a PEP 621 style layout. .pre-commit-config.yaml: update pre-commit-hooks rev, replace/update ruff hook to astral-sh/ruff-pre-commit with auto-fix and unsafe-fixes, add ruff-format, mdformat (with mdformat-myst), pyproject-fmt and validate-pyproject hooks; keep napari-plugin-checks. pyproject.toml: add [build-system], normalize project metadata (name, license, requires-python, classifiers), move authors to [[project.authors]], declare dynamic version, reorganize and deduplicate dependencies and optional-dependencies, add project.urls and napari entry-point, add [tool.setuptools] packaging settings, move and refine ruff configuration under [tool.ruff.lint], and add [tool.pyproject-fmt] settings. Overall this modernizes packaging and enables enhanced linting/formatting via pre-commit hooks. * Run updated pre-commit * Re-run pre-commit on all * Migrate pyproject.toml to PEP 621 tables Rework pyproject.toml to use canonical PEP 621 / table-based metadata and tidy tool configs. Authors moved to [[project.authors]], entry points to [project.entry-points], and optional dependencies to [project.optional-dependencies]; project.urls was added. Setuptools package-data and packages entries were converted to table form. Cleaned up classifiers (removed 3.13/3.14) and relocated ruff/pydocstyle settings under [tool.ruff.*]. Added [tool.pyproject-fmt] formatting options. No functional dependency versions were changed—this is metadata/formatting only to improve packaging/tooling compatibility.
1 parent 50f35ab commit b6d27d9

63 files changed

Lines changed: 2290 additions & 2698 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.napari/DESCRIPTION.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
21
<!---->
2+
33
<!--
44
TODO : complete
55
This file is designed to provide you with a starting template for documenting
@@ -10,6 +10,7 @@ The sections below are given as a guide for the flow of information only, and
1010
are in no way prescriptive. You should feel free to merge, remove, add and
1111
rename sections at will to make this document work best for your plugin.
1212
-->
13+
1314
## Description
1415

1516
A napari plugin for 3D cell segmentation: training, inference, and data review. In particular, this project was developed for analysis of mesoSPIM-acquired (cleared tissue + lightsheet) datasets.
@@ -46,6 +47,7 @@ Here is an example of an mp4 video embedded this way.
4647
4748
https://user-images.githubusercontent.com/17995243/120088305-6c093380-c132-11eb-822d-620e81eb5f0e.mp4
4849
-->
50+
4951
## Intended Audience & Supported Data
5052

5153
This plugin requires basic knowledge in machine learning;
@@ -68,16 +70,18 @@ make sure to mention this.
6870
If you know of researchers, groups or labs using your plugin, or if it has been cited
6971
anywhere, feel free to also include this information here.
7072
-->
73+
7174
## Quickstart
7275

7376
Install from pip with `pip install napari-cellseg3d`
7477

7578
OR
7679

7780
- Install napari from pip with `pip install "napari[all]"`,
78-
then from the “Plugins” menu within the napari application, select “Install/Uninstall Package(s)...”
81+
then from the “Plugins” menu within the napari application, select “Install/Uninstall Package(s)...”
7982
- Copy `napari-cellseg3d` and paste it where it says “Install by name/url…”
8083
- Click “Install”
84+
8185
<!--
8286
8387
@@ -91,6 +95,7 @@ quick overview of the plugin's functionality, but you should definitely link out
9195
more complex and in-depth tutorials highlighting any intricacies of your plugin, and
9296
more detailed documentation if you have it.
9397
-->
98+
9499
## Additional Install Steps
95100

96101
**Python >= 3.8 required**
@@ -114,10 +119,12 @@ over in `setup.cfg`. However, if your plugin has any more complex dependencies,
114119
requires any additional preparation before (or after) installation, you should add
115120
this information here.
116121
-->
122+
117123
## Getting Help
118124

119125
If you would like to report an issue with the plugin,
120126
please open an [issue on Github](https://github.com/AdaptiveMotorControlLab/CellSeg3D/issues)
127+
121128
<!--
122129
This section should point users to your preferred support tools, whether this be raising
123130
an issue on GitHub, asking a question on image.sc, or using some other method of contact.
@@ -127,7 +134,6 @@ here.
127134

128135
## How to Cite
129136

130-
131137
<!--
132138
Many plugins may be used in the course of published (or publishable) research, as well as
133139
during conference talks and other public facing events. If you'd like to be cited in

.pre-commit-config.yaml

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,40 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.6.0
3+
rev: v6.0.0
44
hooks:
5-
# - id: check-docstring-first
65
- id: end-of-file-fixer
76
- id: trailing-whitespace
87
- id: check-yaml
98
- id: check-toml
109
# - id: check-added-large-files
11-
# args: [--maxkb=5000]
12-
# - repo: https://github.com/pycqa/isort
13-
# rev: 5.12.0
14-
# hooks:
15-
# - id: isort
16-
# args: ["--profile", "black", --line-length=79]
17-
- repo: https://github.com/charliermarsh/ruff-pre-commit
18-
# Ruff version.
19-
rev: 'v0.5.6'
10+
# args: [--maxkb=5000]
11+
12+
- repo: https://github.com/astral-sh/ruff-pre-commit
13+
rev: v0.15.13
2014
hooks:
2115
- id: ruff
22-
args: [ --fix, --exit-non-zero-on-fix ]
23-
- repo: https://github.com/psf/black
24-
rev: 24.8.0
16+
args: [--fix, --unsafe-fixes, --exit-non-zero-on-fix]
17+
18+
- id: ruff-format
19+
20+
- repo: https://github.com/executablebooks/mdformat
21+
rev: 1.0.0
2522
hooks:
26-
- id: black
27-
args: [--line-length=79]
23+
- id: mdformat
24+
additional_dependencies:
25+
- mdformat-myst
26+
27+
- repo: https://github.com/tox-dev/pyproject-fmt
28+
rev: v2.21.2
29+
hooks:
30+
- id: pyproject-fmt
31+
32+
- repo: https://github.com/abravalheri/validate-pyproject
33+
rev: v0.25
34+
hooks:
35+
- id: validate-pyproject
36+
2837
- repo: https://github.com/tlambert03/napari-plugin-checks
2938
rev: v0.3.0
3039
hooks:
3140
- id: napari-plugin-checks
32-
# https://mypy.readthedocs.io/en/stable/introduction.html
33-
# you may wish to add this as well!
34-
# - repo: https://github.com/pre-commit/mirrors-mypy
35-
# rev: v0.910-1
36-
# hooks:
37-
# - id: mypy

CODE_OF_CONDUCT.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,22 @@ appearance, race, religion, or sexual identity and orientation.
1414
Examples of behavior that contributes to creating a positive environment
1515
include:
1616

17-
* Using welcoming and inclusive language
18-
* Being respectful of differing viewpoints and experiences
19-
* Gracefully accepting constructive criticism
20-
* Focusing on what is best for the community
21-
* Showing empathy towards other community members
17+
- Using welcoming and inclusive language
18+
- Being respectful of differing viewpoints and experiences
19+
- Gracefully accepting constructive criticism
20+
- Focusing on what is best for the community
21+
- Showing empathy towards other community members
2222

2323
Examples of unacceptable behavior by participants include:
2424

25-
* The use of sexualized language or imagery and unwelcome sexual attention or
26-
advances
27-
* Trolling, insulting/derogatory comments, and personal or political attacks
28-
* Public or private harassment
29-
* Publishing others' private information, such as a physical or electronic
30-
address, without explicit permission
31-
* Other conduct which could reasonably be considered inappropriate in a
32-
professional setting
25+
- The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
- Trolling, insulting/derogatory comments, and personal or political attacks
28+
- Public or private harassment
29+
- Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
- Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
3333

3434
## Our Responsibilities
3535

@@ -70,7 +70,7 @@ members of the project's leadership.
7070
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
7171
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
7272

73-
[homepage]: https://www.contributor-covenant.org
74-
7573
For answers to common questions about this code of conduct, see
7674
https://www.contributor-covenant.org/faq
75+
76+
[homepage]: https://www.contributor-covenant.org

README.md

Lines changed: 36 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# CellSeg3D: self-supervised (and supervised) 3D cell segmentation, primarily for mesoSPIM data!
2+
23
<!-- [![napari hub](https://img.shields.io/endpoint?url=https://api.napari-hub.org/shields/napari-cellseg3d)](https://www.napari-hub.org/plugins/napari_cellseg3d) -->
4+
35
[![PyPI](https://img.shields.io/pypi/v/napari-cellseg3d.svg?color=green)](https://pypi.org/project/napari-cellseg3d)
46
[![Downloads](https://static.pepy.tech/badge/napari-cellseg3d)](https://pepy.tech/project/napari-cellseg3d)
57
[![Downloads](https://static.pepy.tech/badge/napari-cellseg3d/month)](https://pepy.tech/project/napari-cellseg3d)
@@ -9,16 +11,13 @@
911

1012
<img src="https://images.squarespace-cdn.com/content/v1/57f6d51c9f74566f55ecf271/838605d0-9723-4e43-83cd-6dbfe4adf36b/cellseg-logo.png?format=1500w" title="cellseg3d" alt="cellseg3d logo" width="150" align="right" vspace = "80"/>
1113

12-
1314
**A package for 3D cell segmentation with deep learning, including a napari plugin**: training, inference, and data review. In particular, this project was developed for analysis of confocal and mesoSPIM-acquired (cleared tissue + lightsheet) tissue datasets, but is not limited to this type of data. [Check out our publication for more information!](https://elifesciences.org/articles/99848)
1415

15-
1616
![demo](https://images.squarespace-cdn.com/content/v1/57f6d51c9f74566f55ecf271/0d16a71b-3ff2-477a-9d83-18d96cb1ce28/full_demo.gif?format=500w)
1717

18-
1918
## Installation
2019

21-
💻 See the [Installation page](https://adaptivemotorcontrollab.github.io/CellSeg3D/welcome.html) in the documentation for detailed instructions.
20+
💻 See the [Installation page](https://adaptivemotorcontrollab.github.io/CellSeg3D/welcome.html) in the documentation for detailed instructions.
2221

2322
## Documentation
2423

@@ -33,21 +32,22 @@ pip install napari_cellseg3d
3332
```
3433

3534
To use the plugin, please run:
35+
3636
```
3737
napari
3838
```
39+
3940
Then go into `Plugins > napari_cellseg3d`, and choose which tool to use.
4041

4142
- **Review (label)**: This module allows you to review your labels, from predictions or manual labeling, and correct them if needed. It then saves the status of each file in a csv, for easier monitoring.
4243
- **Inference**: This module allows you to use pre-trained segmentation algorithms on volumes to automatically label cells and compute statistics.
43-
- **Train**: This module allows you to train segmentation algorithms from labeled volumes.
44+
- **Train**: This module allows you to train segmentation algorithms from labeled volumes.
4445
- **Utilities**: This module allows you to perform several actions like cropping your volumes and labels dynamically, by selecting a fixed size volume and moving it around the image; fragment images into smaller cubes for training; or converting labels from instance to segmentation and the opposite.
4546

4647
## Why use CellSeg3D?
4748

4849
The strength of our approach is we can match supervised model performance with purely self-supervised learning, meaning users don't need to spend (hundreds) of hours on annotation. Here is a quick look of our key results. TL;DR see panel **f**, which shows that with minmal input data we can outperform supervised models:
4950

50-
5151
![FIG1 (1)](https://github.com/user-attachments/assets/0d970b45-79ff-4c58-861f-e1e7dc9abc65)
5252

5353
**Figure 1. Performance of 3D Semantic and Instance Segmentation Models.**
@@ -59,7 +59,6 @@ F1-score is computed from the Intersection over Union (IoU) with ground truth la
5959
**c:** View of 3D instance labels from supervised models, as noted, for visual cortex volume in b evaluation.
6060
**d:** Illustration of our WNet3D architecture showcasing the dual 3D U-Net structure with our modifications.
6161

62-
6362
## News
6463

6564
### **CellSeg3D now published at eLife**
@@ -69,15 +68,19 @@ Read the [article here !](https://elifesciences.org/articles/99848)
6968
### **New version: v0.2.2**
7069

7170
- v0.2.2:
71+
7272
- Updated the Colab Notebooks for training and inference
7373
- New models available in the inference demo notebook
7474
- CRF optional post-processing adjustments (and pip install directly)
75+
7576
- v0.2.1:
77+
7678
- Updated plugin default behaviors across the board to be more readily applicable to demo data
7779
- Threshold value in inference is now automatically set by default according to performance on demo data on a per-model basis
7880
- Added a grid search utility to find best thresholds for supervised models
7981

8082
- v0.2.0:
83+
8184
- Changed project name to "napari_cellseg3d" to avoid setuptools deprecation
8285
- Small API changes for training/inference from a script
8386
- Some fixes to WandB integration and csv saving after training
@@ -97,7 +100,6 @@ Previous additions:
97100
- New utilities
98101
- Many small improvements and many bug fixes
99102

100-
101103
## Requirements
102104

103105
**Compatible with Python 3.8 to 3.10.**
@@ -118,39 +120,38 @@ Please reach out if you have any issues with the installation, we will be happy
118120

119121
To avoid issues when installing on the ARM64 architecture, please follow these steps.
120122

121-
1) Create a new conda env using the provided conda/napari_CellSeg3D_ARM64.yml file :
123+
1. Create a new conda env using the provided conda/napari_CellSeg3D_ARM64.yml file :
122124

123-
git clone https://github.com/AdaptiveMotorControlLab/CellSeg3d.git
124-
cd CellSeg3d
125-
conda env create -f conda/napari_CellSeg3D_ARM64.yml
126-
conda activate napari_CellSeg3D_ARM64
127-
128-
129-
2) Install a Qt backend (PySide or PyQt5)
130-
3) Launch napari, the plugin should be available in the plugins menu.
125+
```
126+
git clone https://github.com/AdaptiveMotorControlLab/CellSeg3d.git
127+
cd CellSeg3d
128+
conda env create -f conda/napari_CellSeg3D_ARM64.yml
129+
conda activate napari_CellSeg3D_ARM64
130+
```
131131

132+
1. Install a Qt backend (PySide or PyQt5)
132133

134+
1. Launch napari, the plugin should be available in the plugins menu.
133135

134136
## Issues
135137

136138
**Help us make the code better by reporting issues and adding your feature requests!**
137139

138-
139140
If you encounter any problems, please [file an issue] along with a detailed description.
140141

141142
## Testing
142143

143-
You can generate docs locally by running ``make html`` in the docs/ folder.
144+
You can generate docs locally by running `make html` in the docs/ folder.
144145

145-
Before testing, install all requirements using ``pip install napari-cellseg3d[test]``.
146+
Before testing, install all requirements using `pip install napari-cellseg3d[test]`.
146147

147-
``pydensecrf`` is also required for testing.
148+
`pydensecrf` is also required for testing.
148149

149150
To run tests locally:
150151

151-
- Locally : run ``pytest napari_cellseg3d\_tests`` in the plugin folder.
152-
- Locally with coverage : In the plugin folder, run ``coverage run --source=napari_cellseg3d -m pytest`` then ``coverage xml`` to generate a .xml coverage file.
153-
- With tox : run ``tox`` in the plugin folder (will simulate tests with several python and OS configs, requires substantial storage space)
152+
- Locally : run `pytest napari_cellseg3d\_tests` in the plugin folder.
153+
- Locally with coverage : In the plugin folder, run `coverage run --source=napari_cellseg3d -m pytest` then `coverage xml` to generate a .xml coverage file.
154+
- With tox : run `tox` in the plugin folder (will simulate tests with several python and OS configs, requires substantial storage space)
154155

155156
## Contributing
156157

@@ -170,23 +171,6 @@ Distributed under the terms of the [MIT] license.
170171

171172
"napari-cellseg3d" is free and open source software.
172173

173-
[napari-hub]: https://www.napari-hub.org/plugins/napari-cellseg3d
174-
175-
[file an issue]: https://github.com/AdaptiveMotorControlLab/CellSeg3D/issues
176-
[napari]: https://github.com/napari/napari
177-
[Cookiecutter]: https://github.com/audreyr/cookiecutter
178-
[@napari]: https://github.com/napari
179-
[MIT]: http://opensource.org/licenses/MIT
180-
[cookiecutter-napari-plugin]: https://github.com/napari/cookiecutter-napari-plugin
181-
[tox]: https://tox.readthedocs.io/en/latest/
182-
[pip]: https://pypi.org/project/pip/
183-
[PyPI]: https://pypi.org/
184-
[Installation page]: https://adaptivemotorcontrollab.github.io/CellSeg3D/source/guides/installation_guide.html
185-
[the PyTorch website for installation instructions]: https://pytorch.org/get-started/locally/
186-
[PyTorch]: https://pytorch.org/get-started/locally/
187-
[MONAI's optional dependencies]: https://docs.monai.io/en/stable/installation.html#installing-the-recommended-dependencies
188-
[MONAI]: https://docs.monai.io/en/stable/installation.html#installing-the-recommended-dependencies
189-
190174
## Citation
191175

192176
```
@@ -220,3 +204,14 @@ Please refer to the documentation for full acknowledgements.
220204
## Plugin base
221205

222206
This [napari] plugin was generated with [Cookiecutter] using [@napari]'s [cookiecutter-napari-plugin] template.
207+
208+
[@napari]: https://github.com/napari
209+
[cookiecutter]: https://github.com/audreyr/cookiecutter
210+
[cookiecutter-napari-plugin]: https://github.com/napari/cookiecutter-napari-plugin
211+
[file an issue]: https://github.com/AdaptiveMotorControlLab/CellSeg3D/issues
212+
[mit]: http://opensource.org/licenses/MIT
213+
[monai]: https://docs.monai.io/en/stable/installation.html#installing-the-recommended-dependencies
214+
[monai's optional dependencies]: https://docs.monai.io/en/stable/installation.html#installing-the-recommended-dependencies
215+
[napari]: https://github.com/napari/napari
216+
[pytorch]: https://pytorch.org/get-started/locally/
217+
[the pytorch website for installation instructions]: https://pytorch.org/get-started/locally/

docs/TODO.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
[//]: # (
1+
\[//\]: # (
22
TODO:
3+
34
- [ ] Add a way to get the current version of the library
45
- [x] Update all modules
56
- [x] Better WNet3D tutorial
67
- [x] Setup GH Actions
78
- [ ] Add a bibliography
8-
)
9+
)

docs/source/guides/training_wnet.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The WNet3D **does not require a large amount of data to train**, but **choosing
1818

1919
You may find below some guidelines, based on our own data and testing.
2020

21-
The WNet3D is a self-supervised learning approach for 3D cell segmentation, and relies on the assumption that structural and morphological features of cells can be inferred directly from unlabeled data. This involves leveraging inherent properties such as spatial coherence and local contrast in imaging volumes to distinguish cellular structures. This approach assumes that meaningful representations of cellular boundaries and nuclei can emerge solely from raw 3D volumes. Thus, we strongly recommend that you use WNet3D on stacks that have clear foreground/background segregation and limited noise. Even if your final samples have noise, it is best to train on data that is as clean as you can.
21+
The WNet3D is a self-supervised learning approach for 3D cell segmentation, and relies on the assumption that structural and morphological features of cells can be inferred directly from unlabeled data. This involves leveraging inherent properties such as spatial coherence and local contrast in imaging volumes to distinguish cellular structures. This approach assumes that meaningful representations of cellular boundaries and nuclei can emerge solely from raw 3D volumes. Thus, we strongly recommend that you use WNet3D on stacks that have clear foreground/background segregation and limited noise. Even if your final samples have noise, it is best to train on data that is as clean as you can.
2222

2323

2424
.. important::

examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ All credits to the original authors of the data.
55
You can install, launch `napari`, activate the CellSeg3D plugin app, and drag & drop this volume into the canvas.
66
Then, for example, run the `Inference` module with one of our models.
77

8-
See [CellSeg3D documentation](https://adaptivemotorcontrollab.github.io/CellSeg3D/welcome.html) for more details.
8+
See [CellSeg3D documentation](https://adaptivemotorcontrollab.github.io/CellSeg3D/welcome.html) for more details.

0 commit comments

Comments
 (0)