Repository navigation
Add mkdocs-based full API docs, linked to main JB docs #141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a8a852d
Add separate API docs
C-Achard 51df2ef
Remove old RST API docs from Sphinx autodoc
C-Achard ba500e4
Add logo for new API docs
C-Achard 598bd63
Fix workflow path in build_docs.yml for correct file reference
C-Achard b6c64e1
Fix model input size in inference configuration
C-Achard 20f9a29
Create results path folder if it doesn't exist
C-Achard b1dde01
Inotrduce proper mdformat hook for mkdocs
C-Achard 1408066
Restrict mkdocs version to <2 for api-docs dependencies
C-Achard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| /* CellSeg3D palette: napari greys (napari_cellseg3d/interface.py) + logo purple/magenta */ | ||
|
|
||
| :root { | ||
| --cs-napari-grey: #262930; | ||
| --cs-napari-darkgrey: #202228; | ||
| --cs-napari-param-grey: #414851; | ||
| --cs-purple: #5b3aa8; | ||
| --cs-purple-light: #a48be0; | ||
| --cs-magenta: #b0306a; | ||
| --cs-magenta-light: #e0609a; | ||
| } | ||
|
|
||
| [data-md-color-primary="custom"] { | ||
| --md-primary-fg-color: var(--cs-napari-grey); | ||
| --md-primary-fg-color--light: var(--cs-napari-param-grey); | ||
| --md-primary-fg-color--dark: var(--cs-napari-darkgrey); | ||
| --md-primary-bg-color: #ffffff; | ||
| --md-primary-bg-color--light: #ffffffb3; | ||
| } | ||
|
|
||
| [data-md-color-accent="custom"] { | ||
| --md-accent-fg-color: var(--cs-magenta); | ||
| --md-accent-fg-color--transparent: #b0306a1a; | ||
| } | ||
|
|
||
| [data-md-color-scheme="default"] { | ||
| --md-typeset-a-color: var(--cs-purple); | ||
| } | ||
|
|
||
| [data-md-color-scheme="slate"] { | ||
| --md-default-bg-color: var(--cs-napari-grey); | ||
| --md-default-bg-color--light: #262930b3; | ||
| --md-code-bg-color: var(--cs-napari-darkgrey); | ||
| --md-typeset-a-color: var(--cs-purple-light); | ||
| --md-accent-fg-color: var(--cs-magenta-light); | ||
| --md-accent-fg-color--transparent: #e0609a1a; | ||
| } | ||
|
|
||
| [data-md-color-scheme="slate"][data-md-color-primary="custom"] { | ||
| --md-primary-fg-color: var(--cs-napari-darkgrey); | ||
| } | ||
|
|
||
| /* The logo is a detailed disc: use the full header height */ | ||
| .md-header__button.md-logo { | ||
| margin: 0; | ||
| padding: 0.2rem; | ||
| } | ||
|
|
||
| .md-header__button.md-logo img { | ||
| height: 2.6rem; | ||
| } | ||
|
|
||
| /* Landing page logo */ | ||
| .md-typeset img.cs-hero-logo { | ||
| display: block; | ||
| margin: 1rem 0 2rem; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # High-level API | ||
|
|
||
| Entry points for running CellSeg3D from Python without the napari interface, as used in the [Colab notebooks](https://github.com/AdaptiveMotorControlLab/CellSeg3D/tree/main/notebooks). | ||
|
|
||
| - [Inference](inference.md): segment a volume with a pretrained model, then threshold and split it into instances. | ||
| - [Training](training.md): train WNet3D (self-supervised) or a supervised model. | ||
|
|
||
| Every object is configured with a dataclass from [`napari_cellseg3d.config`][napari_cellseg3d.config]. | ||
|
|
||
| Other functionality is documented in the [API Reference](../reference/napari_cellseg3d/index.md). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # Inference | ||
|
|
||
| ```python | ||
| from tifffile import imread | ||
|
|
||
| from napari_cellseg3d.config import ModelInfo | ||
| from napari_cellseg3d.dev_scripts import remote_inference as cs3d | ||
|
|
||
| image = imread("examples/c5image.tif") | ||
|
|
||
| config = cs3d.CONFIG # InferenceWorkerConfig with defaults for a single volume | ||
| config.model_info = ModelInfo(name="SwinUNetR", model_input_size=64, num_classes=2) | ||
|
|
||
| results = cs3d.inference_on_images(image, config=config) | ||
|
|
||
| labels, stats = cs3d.post_processing( | ||
| results[0].semantic_segmentation, | ||
| config=cs3d.PostProcessConfig(), | ||
| ) | ||
| ``` | ||
|
|
||
| For WNet3D, pass `results[0].semantic_segmentation[1]` to `post_processing`. | ||
|
|
||
| ## Functions | ||
|
|
||
| ::: napari_cellseg3d.dev_scripts.remote_inference.inference_on_images | ||
|
|
||
| ::: napari_cellseg3d.dev_scripts.remote_inference.post_processing | ||
|
|
||
| ::: napari_cellseg3d.dev_scripts.remote_inference.PostProcessConfig | ||
|
|
||
| ## Configuration and worker | ||
|
|
||
| - [`InferenceWorkerConfig`][napari_cellseg3d.config.InferenceWorkerConfig]: device, model, weights, sliding window and post-processing settings. | ||
| - [`ModelInfo`][napari_cellseg3d.config.ModelInfo]: model name, input size and number of classes. | ||
| - [`SlidingWindowConfig`][napari_cellseg3d.config.SlidingWindowConfig]: window size and overlap. | ||
| - [`InferenceResult`][napari_cellseg3d.code_models.workers_utils.InferenceResult]: what `inference_on_images` returns, one per image. | ||
| - [`InferenceWorker`][napari_cellseg3d.code_models.worker_inference.InferenceWorker]: the worker `inference_on_images` runs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # Training | ||
|
|
||
| ## WNet3D (self-supervised) | ||
|
|
||
| ```python | ||
| from pathlib import Path | ||
|
|
||
| from napari_cellseg3d.config import WandBConfig, WeightsInfo, WNetTrainingWorkerConfig | ||
| from napari_cellseg3d.dev_scripts import colab_training as c | ||
|
|
||
| config = WNetTrainingWorkerConfig( | ||
| device="cuda:0", | ||
| max_epochs=50, | ||
| learning_rate=2e-5, | ||
| validation_interval=2, | ||
| batch_size=4, | ||
| num_workers=2, | ||
| weights_info=WeightsInfo(), | ||
| results_path_folder="results", | ||
| train_data_dict=c.create_dataset_dict_no_labs(Path("train_images")), | ||
| eval_volume_dict=c.create_eval_dataset_dict(Path("eval_images"), Path("eval_labels")), # or None | ||
| ) | ||
|
|
||
| Path(config.results_path_folder).mkdir(parents=True, exist_ok=True) | ||
| worker = c.get_colab_worker(worker_config=config, wandb_config=WandBConfig(mode="disabled")) | ||
| for _report in worker.train(): | ||
| pass | ||
| ``` | ||
|
|
||
| ::: napari_cellseg3d.dev_scripts.colab_training.get_colab_worker | ||
|
|
||
| ::: napari_cellseg3d.dev_scripts.colab_training.create_dataset_dict_no_labs | ||
|
|
||
| ::: napari_cellseg3d.dev_scripts.colab_training.create_eval_dataset_dict | ||
|
|
||
| - [`WNetTrainingWorkerConfig`][napari_cellseg3d.config.WNetTrainingWorkerConfig]: WNet3D hyperparameters and data. | ||
| - [`WNetTrainingWorker`][napari_cellseg3d.code_models.worker_training.WNetTrainingWorker]: `train()` is a generator yielding a `TrainingReport` per epoch and per validation. | ||
|
|
||
| ## Supervised models | ||
|
|
||
| Supervised models (SegResNet, SwinUNetR, …) use the same pattern with their own config and worker: | ||
|
|
||
| - [`SupervisedTrainingWorkerConfig`][napari_cellseg3d.config.SupervisedTrainingWorkerConfig] | ||
| - [`SupervisedTrainingWorker`][napari_cellseg3d.code_models.worker_training.SupervisedTrainingWorker] | ||
|
|
||
| ## Shared configuration | ||
|
|
||
| - [`TrainingWorkerConfig`][napari_cellseg3d.config.TrainingWorkerConfig]: fields common to all training configs. | ||
| - [`WeightsInfo`][napari_cellseg3d.config.WeightsInfo]: pretrained or custom weights. | ||
| - [`WandBConfig`][napari_cellseg3d.config.WandBConfig]: Weights & Biases logging. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # CellSeg3D API Reference | ||
|
|
||
| { .cs-hero-logo width="280" } | ||
|
|
||
| Reference for the `napari_cellseg3d` Python package, generated from its docstrings. | ||
|
|
||
| To run inference or training from Python, start with the [High-level API](high-level/index.md). | ||
|
|
||
| For installation and usage of the napari plugin, see the [main user documentation](https://adaptivemotorcontrollab.github.io/CellSeg3D/). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| site_name: CellSeg3D API Reference | ||
| site_description: API reference for napari-cellseg3d | ||
| site_url: https://adaptivemotorcontrollab.github.io/CellSeg3D/api/ | ||
| site_dir: "../docs/_build/html/api" | ||
|
|
||
| repo_name: AdaptiveMotorControlLab/CellSeg3D | ||
| repo_url: https://github.com/AdaptiveMotorControlLab/CellSeg3D | ||
|
|
||
| theme: | ||
| name: material | ||
| logo: assets/logo.png | ||
| favicon: assets/logo.png | ||
| palette: | ||
| - media: "(prefers-color-scheme: light)" | ||
| scheme: default | ||
| primary: custom | ||
| accent: custom | ||
| toggle: | ||
| icon: material/brightness-7 | ||
| name: Switch to dark mode | ||
| - media: "(prefers-color-scheme: dark)" | ||
| scheme: slate | ||
| primary: custom | ||
| accent: custom | ||
| toggle: | ||
| icon: material/brightness-4 | ||
| name: Switch to light mode | ||
| features: | ||
| - content.code.copy | ||
| - navigation.indexes | ||
| - navigation.tabs | ||
| - navigation.top | ||
| - search.highlight | ||
| - search.suggest | ||
| - toc.follow | ||
|
|
||
| plugins: | ||
| - search | ||
| - autorefs | ||
| - api-autonav: | ||
| modules: | ||
| - "../napari_cellseg3d" | ||
| exclude: | ||
| - "napari_cellseg3d._tests" | ||
| - "napari_cellseg3d._version" | ||
| - "napari_cellseg3d.dev_scripts" | ||
| - "napari_cellseg3d.res" | ||
| - "napari_cellseg3d.setup" | ||
| nav_section_title: "API Reference" | ||
| api_root_uri: "reference" | ||
| exclude_private: true | ||
| - mkdocstrings: | ||
| default_handler: python | ||
| handlers: | ||
| python: | ||
| paths: [".."] | ||
| options: | ||
| docstring_style: google | ||
| docstring_options: | ||
| warn_missing_types: false | ||
| docstring_section_style: table | ||
| show_root_heading: true | ||
| show_symbol_type_heading: true | ||
| show_signature_annotations: true | ||
| separate_signature: true | ||
| summary: true | ||
| inventories: | ||
| - url: https://docs.python.org/3/objects.inv | ||
| domains: [py, std] | ||
| - url: https://numpy.org/doc/stable/objects.inv | ||
| - url: https://pytorch.org/docs/stable/objects.inv | ||
| - url: https://napari.org/stable/objects.inv | ||
|
|
||
| extra_css: | ||
| - assets/stylesheets/cellseg3d.css | ||
|
|
||
| markdown_extensions: | ||
| - admonition | ||
| - attr_list | ||
| - pymdownx.details | ||
| - pymdownx.highlight | ||
| - pymdownx.superfences | ||
|
|
||
| extra: | ||
| social: | ||
| - icon: material/book-open-variant | ||
| link: https://adaptivemotorcontrollab.github.io/CellSeg3D/ | ||
| name: User documentation | ||
|
|
||
| nav: | ||
| - Home: index.md | ||
| - High-level API: | ||
| - high-level/index.md | ||
| - Inference: high-level/inference.md | ||
| - Training: high-level/training.md | ||
| - API Reference |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.