Skip to content

Commit 0d713ba

Browse files
Prepare initial release (#2)
* First commit * corrected file location of images * updated test data * updated setup * added section on creation of FQ outlines - updates on example data * readme as pdf * updates on jupyter * Small improvments on the docs. add test data to readme * licence added * docs and imjoy plugins * work on docs, plugins, and workflow * Delete readme.pdf * Updates after move to FISH-quant * removed jupyter notebooks * Updated docs * Update readme.md added link to issues.
1 parent 0151c46 commit 0d713ba

38 files changed

+1821
-0
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.DS_Store
2+
__pycache__
3+
*.pyc
4+
.ipynb_checkpoints/
5+
segwrap.egg-info/
6+
site/

LICENSE

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
BSD 3-Clause License
2+
3+
Copyright © 2020, Florian Mueller
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
* Redistributions of source code must retain the above copyright
9+
notice, this list of conditions and the following disclaimer.
10+
* Redistributions in binary form must reproduce the above copyright
11+
notice, this list of conditions and the following disclaimer in the
12+
documentation and/or other materials provided with the distribution.
13+
* Neither the name of the copyright holder nor the names of its
14+
contributors may be used to endorse or promote products derived from
15+
this software without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20+
DISCLAIMED. IN NO EVENT SHALL COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
21+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

docs/data.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Data
2+
3+
## Data organization
4+
We strongly recommend the following data-organization on which this workflow has been tested.
5+
1. Images are store as single-channel multi-z-stack tif files, e.g on tif per position and channel.
6+
2. All raw 3D images are stored in a folder `acquisition`
7+
3. All analysis results are stored in subfolder `analysis`, where each analysis step has a separate subfolder.
8+
9+
The organization of the provided test data is the following
10+
11+
```
12+
├─ example_data/
13+
│ ├─ acquisition # Folder with raw data
14+
│ │ ├─ test_pos001_cy3.tif
15+
│ │ ├─ test_pos002_dapi.tif
16+
│ │ ├─ test_pos002_cy3.tif
17+
│ │ ├─ test_pos002_dapi.tif
18+
│ ├─ analysis # Folder with all analysis results
19+
│ │ ├─ segmentation-input # Folder with projected images for segmentation
20+
│ │ │ ├─ img-prop__test_pos001_cy3.json # json file with image properties
21+
│ │ │ ├─ test_pos001_cy3.png # Projected image
22+
│ │ │ ├─ ....
23+
│ │ ├─ segmentation-results # Folder with segmentation results
24+
│ │ │ ├─ test_pos001_cy3.tif
25+
│ │ │ ├─ test_pos001_cy3.tif
26+
│ │ │ ├─ test_pos001_cy3.tif
27+
│ │ │ ├─ ....
28+
│ │ ├─ ....
29+
│ │ ├─ FQ_outline # [Optional] FQ outlines
30+
│ │ │ ├─ test_pos001_cy3_outline.txt
31+
│ │ │ ├─ ....
32+
```
33+
34+
## Test data
35+
Already processed test data can be downloaded from [**Dropbox**](https://www.dropbox.com/sh/yr1s5olqwkvyx0i/AADH0QQtdNuWWq7z9wgQpLiOa?dl=0). With these data, you can verify if the different analysis steps are properly executed.

docs/img/fq-create-outlines.png

24.8 KB
Loading

docs/img/imjoy-interface.png

59.3 KB
Loading

docs/img/imjoy-logo-powered.svg

+268
Loading

docs/img/imjoy-preprocess-ui.png

10.4 KB
Loading
16.1 KB
Loading

docs/img/jupyer-code-cell.png

8.62 KB
Loading

docs/img/jupyter-landing-page.png

33.4 KB
Loading

docs/img/preprocess-results.png

374 KB
Loading

docs/img/preprocess-ui.png

11.5 KB
Loading

docs/img/segmentation-log.png

29.9 KB
Loading

docs/img/segmentation-results.png

817 KB
Loading

docs/img/segmentation-ui.png

18.6 KB
Loading

docs/img/segmentation__cells.png

1.5 MB
Loading

docs/img/segmentation__nuclei.png

968 KB
Loading

docs/imjoy-overview.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
We provide several ImJoy plugins to
3+
4+
* Pre-process 3D images
5+
* Perform segmentation
6+
7+
Each workflow is documented in a dedicated section.

docs/imjoy-pre-processing.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
## Preprocessing
3+
Segmentation is done on 2D images. In this step, 3D images are transformed into
4+
2D images by applying a projection.
5+
6+
Preprocessing is done with the ImJoy plugin `PreProcess`:
7+
<a href="https://imjoy.io/#/app?w=cellpose&plugin=fish-quant/segmentation:PreProcess@stable&upgrade=1" target="_blank">**install from here.**</a>
8+
9+
1. Before running the plugin, you have to specify a few parameters. Note that you have to perform this
10+
projection for each channel-type. This allows to use different projection methods for a channel. This can be set in the plugin interface, avaible after clicking on the arrow down next to the plugin name.
11+
12+
![imjoy-preprocess](img/imjoy-preprocess-ui.png)
13+
14+
Here the following parameters can be set.
15+
16+
Option | Type | Default | Description
17+
---------------- | ---- | ----------- | -----------
18+
`Path DATA` | str | | Full path to folder containing data to be segmented.
19+
`Path SAVE` | str | | Full path to folder where results should be stored.
20+
`Channel string` | str | dapi | Unique string to identify channel that should be processed.
21+
`Projection type` | str | mean | Different projection types: `max`, `mean`, `indiv`. The option `indiv` implies that a z-stack is split into individual slices, stored in subfolder for each image.
22+
23+
0. Pressing the button `PreProcess` will **start the pre-processing**. Progress
24+
can be monitored in the plugin log, available by pressing on the `i` next to the plugin name.
25+
26+
0. **Results** will be saved in the specified folder. For each image a json file with
27+
basic properties of the file, and an image with the same name as the original one will be saved.
28+

docs/imjoy-segmentation.md

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
2+
# Segmentation of cells and nuclei
3+
4+
Preprocessing is done with the ImJoy plugin `SegmentCellsNuclei`:
5+
<a href="https://imjoy.io/#/app?w=cellpose&plugin=fish-quant/segmentation:SegmentCellsNuclei@stable&upgrade=1" target="_blank">**install from here.**</a>
6+
7+
8+
**Resizing to speed up prediction**: segmentation speed depends on the image size. In our experience, resizing the images
9+
can lead to a substantial speed-up. In case you resize the images, we implemented a post-processing
10+
routine that will resize the predicted masks back to the original image size.
11+
12+
13+
1. Before running the plugin, you have to specify a few parameters. This can be done in the plugin interface,
14+
avaible after clicking on the arrow down next to the plugin name..
15+
16+
![imjoy-segment-cells-nuclei-ui](img/imjoy-segment-cells-nuclei-ui.png)
17+
18+
Here the following parameters can be set:
19+
20+
Option | Type | Default | Description
21+
---------------- | ---- | ----------- | -----------
22+
`Path DATA` | str | | Full path to folder containing data to be segmented.
23+
`Path SAVE` | str | | Full path to folder where results should be stored.
24+
`String CELLS` | str | cy3 | Unique identifier for images of cytoplasmic stain.
25+
`String NUCLEI` | str | dapi | Unique identifier for images of nuclear stain.
26+
`String img ext` | str | .png | File extension of images that should be segmented.
27+
`Size CELLS` | int | 100 | Typical size of a cell (in resized image).
28+
`Size NUCLEI` | int | 50 | Typical size of a nucleus (in resized image).
29+
`New size` | str | 512, 512 | String to specify new size of image. No resizing if empty.
30+
31+
2. Pressing on the plugin name `SegmentCellsNuclei` will start the segmentation.
32+
When using CellPose for the first time, the models for nuclear and cytoplasmic segmentations are downloaded.
33+
34+
The actual segmentation can take a while, depending on the numberof images that should be segmented
35+
(and their size). Progress will be displayed in the ImJoy status bar, and more details provided in the
36+
plugin log available by pressing on the `i` next to the plugin name.
37+
38+
Once a image is segmented, the results will be saved (see below). So you can monitor the result folder
39+
to verify on the fly if the segmentation works.
40+
41+
42+
3. **Results** will be saved in the specified folder. For each image the following files, results files with different suffices are created:
43+
* `flow_...`: these are the predicted distance maps of CellPose. They are an intermediate result, and
44+
not needed for most end-users.
45+
* `mask_...`: these contain the actual segmentation results. Each segmented cell or nuclei is a filled
46+
object with a constant pixel value. If the images were resized during segmentation, the mask is scaled
47+
back up to the original image size. The actually obtained (smaller) mask is saved under the name `mask__rescale_...`.
48+
* `segmentation_...`: summary plot showing the input image, the predicted distance map, and the segmented
49+
objects. This plot is also shown in the interface.
50+
51+
![segmentation__nuclei](img/segmentation__nuclei.png)

docs/index.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
This repository provides wrapper code to use the generalist cell/nuclei segmentation package [**Cellpose**](https://github.com/mouseland/cellpose).
3+
4+
Example of **nuclear segmentation**:
5+
![segmentation__nuclei](img/segmentation__nuclei.png)
6+
7+
8+
Example of **cytoplasmic segmentation**:
9+
![segmentation__cells](img/segmentation__cells.png)
10+
11+

docs/installation.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
# Installation
3+
In order to use the workflows in this repository, you need to follows these steps, which we detail below:
4+
5+
1. **Python**. Recommended with Miniconda:
6+
0. Create a **dedicated environment** with Jupyter to run your code.
7+
1. Install **CellPose**.
8+
2. Install **code from this repositry**.
9+
10+
## Pyton with Miniconda
11+
We recommend installing an [Miniconda distribution of Python](https://docs.conda.io/en/latest/miniconda.html): choose Python 3.7 and your operating system.
12+
13+
We then recommend using the annoconda prompt that is availabel to excecute the different commands listed below.
14+
This guarantees that the necessary terminal scripts are available.
15+
16+
## Create dedicated environment to run Cellpose
17+
We recommend creating a dedicated environment to run Cellpose. To create an environment called `cellpose`, open an anaconda prompt and type. Note that you will also install jupyter, which will allow
18+
to run the jupyter notebooks for easier execution (confirm with `y` when asked if you want to proceed):
19+
20+
```
21+
conda create --name cellpose python=3.7 jupyter
22+
```
23+
24+
Then activate the `cellpose` environment (Note you will always have to run this command when using this workflow):
25+
```
26+
conda activate cellpose
27+
```
28+
29+
## Installing Cellpose
30+
From your `cellpose` environment, install Cellpose and its dependencies with
31+
```
32+
pip install cellpose --upgrade
33+
```
34+
35+
## Installing this package
36+
From your `cellpose` environment, install this package and its dependencies with
37+
```
38+
pip install git+https://github.com/muellerflorian/segmentation/ --upgrade
39+
```
40+
TODO: add commit tag?

docs/licence.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
- **Cellpose** is (general) are BSD-licenced (3 clause)
2+
3+
> Copyright © 2020 Howard Hughes Medical Institute
4+
5+
> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6+
7+
> Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8+
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9+
Neither the name of HHMI nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11+
12+
13+
- The **rest of the code** provided in this repository is BSD-licenced (3 clause):
14+
15+
>Copyright © 2020, Florian Mueller
16+
>All rights reserved.
17+
>
18+
>Redistribution and use in source and binary forms, with or without
19+
>modification, are permitted provided that the following conditions are met:
20+
> * Redistributions of source code must retain the above copyright
21+
notice, this list of conditions and the following disclaimer.
22+
> * Redistributions in binary form must reproduce the above copyright
23+
notice, this list of conditions and the following disclaimer in the
24+
documentation and/or other materials provided with the distribution.
25+
> * Neither the name of the copyright holder nor the names of its
26+
contributors may be used to endorse or promote products derived from
27+
this software without specific prior written permission.
28+
>
29+
>THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
30+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
32+
DISCLAIMED. IN NO EVENT SHALL COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
33+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
36+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
38+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39+
40+
https://fish-quant.github.io/segmentation/imjoy-pre-processing/img/imjoy-preprocess-ui.png

docs/post-processing-fq.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Create FISH-quant [Matlab] outline files
2+
In order to use the segmentation results in the Matlab version of FISH-quant,
3+
FISH-quant outline files have to be created from the mask images.
4+
5+
For this, we provide a Matlab GUI distributed with the [FISH-quant package](https://bitbucket.org/muellerflorian/fish_quant/src/master/). After installing FISH-quant, you can open this GUI from the command window
6+
with `FQ_seg`. The relevant part of the interface is the central panel _Cell Profiler: generate FQ outlines from segmentation_.
7+
8+
![](img/fq-create-outlines.png "fq-create-outlines")
9+
10+
11+
1. **Specify experimental parameters**. These parameters have to be defined – even if the default parameters are good.
12+
Only then the button to generate the outlines will be enabled.
13+
14+
0. **Define naming scheme of original images and segmentation results**. You have to define a few parameters regarding
15+
the naming convention of your files.
16+
1. Unique identifier for the FISH and DAPI images. These identifiers have to be defined in a way that when you take the
17+
full file-name of the FISH image and you replace the identifier for FISH, e.g. `cy3`, by the identifier of the DAPI, e.g. `dapi`, you obtain the DAPI file-name.
18+
2. Then, you have to define the identifier of your segmentation results. For this workflow, `mask__nuclei__` for the nuclei and
19+
`mask__cells__` for the cells.
20+
3. File-extensions of the masks and original file-names, e.g. `tif` for the example data.
21+
22+
0. [Optional] **Generating outline files for a second color**. This option allows to generate outline files for a second color,
23+
e.g. for a dual-color FISH experiment or if the cell segmentation was performed with a different channel than the FISH channel. The outlines for this color will be based on the segmentation results of the first color and the exact cells will be used. This allows a simple comparison between the detection results. As above, the identifier for the second color has to be specified, e.g. `cy5`. You also have to redefine the experimental parameters (most often to adjust the excitation and emission wavelength).
24+
25+
Additionally, you can choose to not create the outlines for the channel that was used for cell segmentation. This option is useful if the first color does not contain actual smFISH data but results of a dedicated cell segmentation stain.
26+
27+
0. Several options exist to **specify the folder** where the results will be saved. By default, the FQ outlines will be stored
28+
in a sub-folder `__FQ_outlines` within the folder containing the segmentation results. You can then move it to another location, e.g. directly into the `analysis` folder as done for the example data.
29+
30+
0. Specify **images that will be analyzed**. You can either choose different images that you want to analyze (`Define images`),
31+
or select an entire folder (`Select folder`). For the latter, you can also specify a recursive search; this means that all subfolders will be searched as well (not recommended for this workflow). The script will only consider images that follow the above explained naming convention – other images will be ignored.
32+
In the example data, the folder `analysis\segmentation-results` contains the relevant data.
33+
34+
0. **Create outlines**. Lastly, press the button `Create FQ outlines`. The script will then automatically search for the files
35+
describing the segmentation of cells and nuclei. For each image an outline file with the reference to the ORIGINAL 3D image will be generated and nuclei assigned to their respective cells.

0 commit comments

Comments
 (0)