Skip to content

Commit bf0fa2f

Browse files
authored
Merge PR #9 | Update and create documentation using GitHub Pages
from kreshuklab/qy/create-docs
2 parents b38f01d + 85996e1 commit bf0fa2f

File tree

12 files changed

+1080
-173
lines changed

12 files changed

+1080
-173
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Build and Deploy Documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- qy/create-docs
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
build-and-deploy:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
# Checkout the repository
18+
- name: Checkout Code
19+
uses: actions/checkout@v4
20+
21+
# Configure Git credentials
22+
- name: Configure Git Credentials
23+
run: |
24+
git config user.name "github-actions[bot]"
25+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
26+
27+
# Set up Python
28+
- name: Set up Python
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: "3.x"
32+
33+
# Generate cache ID
34+
- name: Set Cache ID
35+
run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
36+
37+
# Cache Python dependencies
38+
- name: Cache Python Dependencies
39+
uses: actions/cache@v4
40+
with:
41+
key: mkdocs-material-${{ env.cache_id }}
42+
path: .cache
43+
restore-keys: |
44+
mkdocs-material-
45+
46+
# Install MkDocs and Plugins, Deploy Documentation
47+
- name: Install Dependencies and Deploy Docs
48+
run: |
49+
pip install mkdocs-material \
50+
mkdocs-git-revision-date-localized-plugin \
51+
mkdocs-git-committers-plugin-2 \
52+
mkdocs-autorefs \
53+
mkdocstrings[python] \
54+
markdown-exec
55+
mkdocs gh-deploy --force
56+
env:
57+
MKDOCS_GIT_COMMITTERS_APIKEY: ${{ secrets.MKDOCS_GIT_COMMITTERS_APIKEY }}

README.md

+58-92
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,73 @@
1-
# Plant Nuclei Segmentation Pipelines <!-- omit in toc -->
1+
# Nuclear Segmentation Pipelines <!-- omit in toc -->
22

3-
This repository hosts the code and guides for the pipelines used in the paper [_A deep learning-based toolkit for 3D nuclei segmentation and quantitative analysis in cellular and tissue context_](https://www.biorxiv.org/content/10.1101/2024.02.19.580954v1). It is structured in to four folders:
3+
![stardist_raw_and_segmentation](https://zenodo.org/records/8432366/files/stardist_raw_and_segmentation.jpg)
4+
5+
The GoNuclear repository hosts the code and guides for the pipelines used in the paper [_A deep learning-based toolkit for 3D nuclei segmentation and quantitative analysis in cellular and tissue context_](https://doi.org/10.1242/dev.202800). It is structured in to four folders:
46

57
- **stardist/** contains a 3D StarDist training and inference pipeline, `run-stardist`.
68
- **plantseg/** contains configuration files for training and inference with PlantSeg.
79
- **cellpose/** contains scripts for training and inference with Cellpose.
810
- **evaluation/** contains modules for evaluating the segmentation results.
911

10-
## Table of Contents <!-- omit in toc -->
11-
12-
- [Tools and Workflows](#tools-and-workflows)
13-
- [StarDist](#stardist)
14-
- [PlantSeg](#plantseg)
15-
- [Cellpose](#cellpose)
16-
- [Data](#data)
17-
- [Training Data](#training-data)
18-
- [Preparing Data for Inference](#preparing-data-for-inference)
19-
- [Cite](#cite)
20-
21-
22-
## Tools and Workflows
23-
24-
### StarDist
25-
26-
*See [`run-stardist`'s README.md](stardist/README.md) for more details.*
27-
28-
This is one of the most important contribution of this repository. If your nuclei are more or less uniform in shape, please consider using the `run-stardist` pipeline in this repository. It generate separate and round instance segmentation masks for your nuclei images.
29-
30-
- The code and tutorial for running StarDist inference is in the `stardist/` folder
31-
- The pretrained model is automatically downloaded during inference (also available at [BioImage.IO: StarDist Plant Nuclei 3D ResNet](https://bioimage.io/#/?id=10.5281%2Fzenodo.8421755))
32-
- An example of segmentation results is shown below.
33-
34-
![stardist_raw_and_segmentation](https://zenodo.org/records/8432366/files/stardist_raw_and_segmentation.jpg)
35-
36-
### PlantSeg
37-
38-
*See [PlantSeg's README.md](plantseg/README.md) for more details.*
39-
40-
If your nuclei have irregular shapes, please consider using the PlantSeg pipeline. It generates instance masks for your nuclei images regardless of their nucleus size and shape.
41-
42-
- The code and tutorial for running PlantSeg inference is in the `plantseg/` folder
43-
- The pretrained model is automatically downloaded during inference (also available at [BioImage.IO: PlantSeg Plant Nuclei 3D UNet](https://bioimage.io/#/?id=10.5281%2Fzenodo.8401064))
44-
- An example of segmentation results is shown below.
45-
46-
![plantseg_raw_and_gasp_segmentation](https://zenodo.org/records/10070349/files/plantseg_raw_and_gasp_segmentation.jpg)
47-
48-
### Cellpose
49-
50-
*See [Cellpose's README.md](cellpose/README.md) for more details.*
51-
52-
- The guide for running Cellpose inference and training is in the `cellpose/` folder
53-
54-
## Data
55-
56-
### Training Data
57-
58-
The training data is publicly available on [BioImage Archive](https://www.ebi.ac.uk/biostudies/BioImages/studies/S-BIAD1026).
59-
60-
An example of the raw image:
61-
62-
![raw](https://zenodo.org/records/10070349/files/plantseg_raw.jpg)
63-
64-
Some key information about the training data is listed below:
65-
66-
```python
67-
original_voxel_size = { # z, y, x
68-
1135: [0.28371836501901143, 0.12678642066720086, 0.12678642066720086], # validation
69-
1136: [0.2837183895131086, 0.12756971653115998, 0.12756971653115998], # training
70-
1137: [0.2837183895131086, 0.1266211463645486, 0.1266211463645486 ], # training
71-
1139: [0.2799036917562724, 0.12674335484590543, 0.12674335484590543], # training
72-
1170: [0.27799632231404964, 0.12698523961670266, 0.12698522349145364], # training
73-
} # [0.2837, 0.1268, 0.1268] is taken as the median
74-
75-
original_median_extents = { # z, y, x
76-
1135: [16, 32, 33], # validation
77-
1136: [16, 32, 32], # training
78-
1137: [16, 32, 32], # training
79-
1139: [16, 32, 33], # training
80-
1170: [16, 29, 30], # training
81-
'average':
82-
} # [16, 32, 32] is taken as the median
12+
and are described in [**GoNuclear documentation** :book:](https://kreshuklab.github.io/go-nuclear/).
13+
14+
## Data and Models
15+
16+
Please go to [BioImage Archive S-BIAD1026](https://www.ebi.ac.uk/biostudies/BioImages/studies/S-BIAD1026) for the training data and models. I organised them in the following structure:
17+
18+
```bash
19+
Training data
20+
├── 2d/
21+
│ ├── isotropic/
22+
│ │ ├── gold/
23+
│ │ └── initial/
24+
│ └── original/
25+
│ ├── gold/
26+
│ └── README.txt
27+
└── 3d_all_in_one/
28+
├── 1135.h5
29+
├── 1136.h5
30+
├── 1137.h5
31+
├── 1139.h5
32+
└── 1170.h5
33+
34+
Models
35+
├── cellpose/
36+
│ ├── cyto2_finetune/
37+
│ │ └── gold/
38+
│ ├── nuclei_finetune/
39+
│ │ ├── gold/
40+
│ │ └── initial/
41+
│ └── scratch_trained/
42+
│ └── gold/
43+
├── plantseg/
44+
│ └── 3dunet/
45+
│ ├── gold/
46+
│ ├── initial/
47+
│ ├── platinum/
48+
│ └── train_example.yml
49+
└── stardist/
50+
├── resnet/
51+
│ ├── gold/
52+
│ ├── initial/
53+
│ └── platinum/
54+
├── train_example.yml
55+
└── unet/
56+
└── gold/
8357
```
8458

85-
**Note for training Cellpose:** The best image form for training StarDist and PlantSeg models are the original forms, i.e. the linked dataset is the one that provide the best results. However, to train Cellpose which only takes 2D training data, the images are prepared to be 2D slices of the rescaled isotropic 3D images. The 2D slices includes all XY, XZ and YZ slices ordered randomly by a random prefix in the file name. The 2D slices are saved as TIFF files.
86-
87-
### Preparing Data for Inference
88-
89-
Both HDF5 files and TIFF files can be directly used for both `run-stardist` and `plant-seg` inference. Go to the respective folders's README.md for more details.
90-
91-
## Cite
59+
## Citation
9260

9361
If you find this work useful, please cite our paper and the respective tools' papers:
9462

9563
```bibtex
96-
@article {Vijayan2024.02.19.580954,
97-
author = {Athul Vijayan and Tejasvinee Atul Mody and Qin Yu and Adrian Wolny and Lorenzo Cerrone and Soeren Strauss and Miltos Tsiantis and Richard S. Smith and Fred Hamprecht and Anna Kreshuk and Kay Schneitz},
98-
title = {A deep learning-based toolkit for 3D nuclei segmentation and quantitative analysis in cellular and tissue context},
99-
elocation-id = {2024.02.19.580954},
100-
year = {2024},
101-
doi = {10.1101/2024.02.19.580954},
102-
publisher = {Cold Spring Harbor Laboratory},
103-
URL = {https://www.biorxiv.org/content/early/2024/02/21/2024.02.19.580954},
104-
eprint = {https://www.biorxiv.org/content/early/2024/02/21/2024.02.19.580954.full.pdf},
105-
journal = {bioRxiv}
64+
@article{vijayan2024deep,
65+
title={A deep learning-based toolkit for 3D nuclei segmentation and quantitative analysis in cellular and tissue context},
66+
author={Vijayan, Athul and Mody, Tejasvinee Atul and Yu, Qin and Wolny, Adrian and Cerrone, Lorenzo and Strauss, Soeren and Tsiantis, Miltos and Smith, Richard S and Hamprecht, Fred A and Kreshuk, Anna and others},
67+
journal={Development},
68+
volume={151},
69+
number={14},
70+
year={2024},
71+
publisher={The Company of Biologists}
10672
}
10773
```

cellpose/README.md

+57-14
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,52 @@
22

33
This part of the repo concisely shows how to install, train and segment with Cellpose. In other word, it is a record of how Cellpose is used in this paper. Since my experiments show StarDist and PlantSeg have better 3D segmentation performance than Cellpose, this section is complete yet not extensive.
44

5-
- [Installation](#installation)
6-
- [Install Miniconda](#install-miniconda)
7-
- [Install `cellpose` using `pip`](#install-cellpose-using-pip)
8-
- [Segmentation](#segmentation)
9-
- [Data Preparation](#data-preparation)
10-
- [Segmentation Command](#segmentation-command)
11-
- [Training](#training)
12-
- [Data Preparation](#data-preparation-1)
13-
- [Training Command](#training-command)
14-
- [Cellpose Version and Code](#cellpose-version-and-code)
15-
5+
* [Installation](#installation)
6+
* [Install Miniconda](#install-miniconda)
7+
* [Install `cellpose` using `pip`](#install-cellpose-using-pip)
8+
* [Segmentation](#segmentation)
9+
* [Data Preparation](#data-preparation)
10+
* [Segmentation Command](#segmentation-command)
11+
* [Training](#training)
12+
* [Data Preparation](#data-preparation-1)
13+
* [Training Command](#training-command)
14+
* [Cellpose Version and Code](#cellpose-version-and-code)
15+
* [Cite](#cite)
1616

1717
## Installation
1818

1919
It is recommended to install this package in an environment managed by `conda`. We start the guide by installing Mini-`conda`.
2020

2121
### Install Miniconda
22+
2223
First step required to use the pipeline is installing Miniconda. If you already have a working Anaconda setup you can go directly to the next step. Anaconda can be downloaded for all platforms from [here](https://www.anaconda.com/products/distribution). We suggest to use Miniconda, because it is lighter and install fewer unnecessary packages.
2324

2425
To download Miniconda, open a terminal and type:
26+
2527
```bash
2628
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
2729
```
2830

2931
Then install by typing:
32+
3033
```bash
3134
bash ./Miniconda3-latest-Linux-x86_64.sh
3235
```
36+
3337
and follow the installation instructions. The Miniconda3-latest-Linux-x86_64.sh file can be safely deleted.
3438

3539
### Install `cellpose` using `pip`
40+
3641
To create and activate an `conda` environment for `cellpose`, then install `cellpose` in it, run the following commands in the terminal:
42+
3743
```bash
3844
conda create --name cellpose python=3.8
3945
conda activate cellpose
4046
pip install cellpose
4147
```
4248

4349
If you have a nvidia gpu, follow these steps to make use of it:
50+
4451
```bash
4552
pip uninstall torch
4653
conda install pytorch==1.12.0 cudatoolkit=11.3 -c pytorch
@@ -50,13 +57,18 @@ If you encounter error or need more explanation, go to [Cellpose's official inst
5057

5158
## Segmentation
5259

60+
Although the PlantSeg and StarDist models from this study outperform the Cellpose models I trained. One may find the gold models in [BioImage Archive S-BIAD1026](https://www.ebi.ac.uk/biostudies/BioImages/studies/S-BIAD1026), or one of them [`philosophical-panda` at BioImage Model Zoo](https://bioimage.io/#/?tags=qin%20yu&id=philosophical-panda).
61+
5362
### Data Preparation
63+
5464
Cellpose inference only segmenet TIFF images, not HDF5. However, it can take 3D volumes as input.
5565

5666
### Segmentation Command
5767

5868
There are two ways of segmenting 3D images with Cellpose:
59-
- Segment 3D images slice by slice then stitch 2D segmentation results into 3D segmentation results. With this approach, the images doesn't have to be isotropic, as long as the XY planes have similar properties as the training data.
69+
70+
* Segment 3D images slice by slice then stitch 2D segmentation results into 3D segmentation results. With this approach, the images doesn't have to be isotropic, as long as the XY planes have similar properties as the training data.
71+
6072
```bash
6173
cellpose \
6274
--pretrained_model PATH_TO_MODEL \
@@ -70,7 +82,9 @@ There are two ways of segmenting 3D images with Cellpose:
7082
--no_npy \
7183
--save_tif
7284
```
73-
- Compute spatial flow of 3D images in all dimensions then segment the images in 3D directly. You may choose to rescale the images to be isotropic before segmentation, or specify the anisotropy to let Cellpose deal with the rescaling. Here I show the later.
85+
86+
* Compute spatial flow of 3D images in all dimensions then segment the images in 3D directly. You may choose to rescale the images to be isotropic before segmentation, or specify the anisotropy to let Cellpose deal with the rescaling. Here I show the later.
87+
7488
```bash
7589
cellpose \
7690
--pretrained_model PATH_TO_MODEL \
@@ -86,13 +100,14 @@ There are two ways of segmenting 3D images with Cellpose:
86100
--save_tif
87101
```
88102

89-
90103
## Training
91104

92105
### Data Preparation
106+
93107
Cellpose training only takes 2D images as input. To train on 3D images, we first need to split the 3D images into 2D images. Note that 3D images are better to be rescaled for isotropy in the resulting 2D training data.
94108

95109
### Training Command
110+
96111
An example training command is shown below, which is used in the paper. The parameters `--learning_rate 0.1` and `--weight_decay 0.0001` are recommended by the [Cellpose official documentation](https://cellpose.readthedocs.io/en/latest/train.html).
97112

98113
```bash
@@ -106,4 +121,32 @@ cellpose --train --use_gpu \
106121
```
107122

108123
## Cellpose Version and Code
124+
109125
See [Cellpose's GitHub page](https://github.com/MouseLand/cellpose) for the code. Cellpose v2.0.5 was used for training and inference in this paper.
126+
127+
## Cite
128+
129+
If you find the code/models/datasets useful, please cite our paper and Cellpose:
130+
131+
```bibtex
132+
@article{vijayan2024deep,
133+
title={A deep learning-based toolkit for 3D nuclei segmentation and quantitative analysis in cellular and tissue context},
134+
author={Vijayan, Athul and Mody, Tejasvinee Atul and Yu, Qin and Wolny, Adrian and Cerrone, Lorenzo and Strauss, Soeren and Tsiantis, Miltos and Smith, Richard S and Hamprecht, Fred A and Kreshuk, Anna and others},
135+
journal={Development},
136+
volume={151},
137+
number={14},
138+
year={2024},
139+
publisher={The Company of Biologists}
140+
}
141+
142+
@article{stringer2021cellpose,
143+
title={Cellpose: a generalist algorithm for cellular segmentation},
144+
author={Stringer, Carsen and Wang, Tim and Michaelos, Michalis and Pachitariu, Marius},
145+
journal={Nature methods},
146+
volume={18},
147+
number={1},
148+
pages={100--106},
149+
year={2021},
150+
publisher={Nature Publishing Group US New York}
151+
}
152+
```

0 commit comments

Comments
 (0)