README.md 2.95 KB
Newer Older
Christoph Sommer's avatar
Christoph Sommer committed
1
2
3
## Seg2dendrite:
#### Automatic 3D Dendritic Spine Quantification with ilastik and Imaris
---
4

Christoph Sommer's avatar
Christoph Sommer committed
5
<img src="assets/dendrite+spines_5_1200x400.jpg" alt="Morse and Watson (Jonas group, unpublished)" width="768" style="width:768px;"/>
Christoph Sommer's avatar
Christoph Sommer committed
6
7
8

Morse and Watson (Jonas group, unpublished)

Christoph Sommer's avatar
Christoph Sommer committed
9
### 1. Convert your images (.ims; or other) to hdf5 (.h5) for pixel classification in ilastik
Christoph Sommer's avatar
Christoph Sommer committed
10
---
Christoph Sommer's avatar
Christoph Sommer committed
11

Christoph Sommer's avatar
Christoph Sommer committed
12
Use the ImageJ macro `img2h5.ijm` to convert .ims files to ilastik .h5 files. Note,
13
14
that the `ilastik` update site needs to be enabled in Fiji.

Christoph Sommer's avatar
Christoph Sommer committed
15
16
Choose a folder with images and a filetype (e. g. .ims). If your data is stored in
multi-resolution, choose a resolution level (1: original resolution; 2 (default): down scaling by factor of 2).
17

Christoph Sommer's avatar
Christoph Sommer committed
18
### 2. Use ilastik pixel classification
Christoph Sommer's avatar
Christoph Sommer committed
19
---
Christoph Sommer's avatar
Christoph Sommer committed
20

21
22
23
Use `Pixel Classification` workflow.
* Choose dendrite class as first class in training (yellow color)
* Make sure probability maps are exported as uint8 and renormalized to 0-255
Christoph Sommer's avatar
Christoph Sommer committed
24
25
Note, if the Pixel Classification workflow is not working with your data, try
the `Autocontext` workflow.
26
27

### 3. Convert probability maps to dendrite objects and save as .swc for import in Imaris
Christoph Sommer's avatar
Christoph Sommer committed
28
---
Christoph Sommer's avatar
Christoph Sommer committed
29
#### Command line tool:
Christoph Sommer's avatar
Christoph Sommer committed
30

Christoph Sommer's avatar
Christoph Sommer committed
31
Extract the dentritic spine skeletons graph from ilastik probability maps and export to .swc for import in Imaris
Christoph Sommer's avatar
Christoph Sommer committed
32

33
```
Christoph Sommer's avatar
Christoph Sommer committed
34
35
36
usage: seg2dendrite.py [-h] [-ms MIN_SIZE] [-rl RESOLUTION_LEVEL] [-s SMOOTH_SIGMA SMOOTH_SIGMA SMOOTH_SIGMA]
                       [-t THRESHOLD]
                       ilastik_h5 [ilastik_h5 ...]
Christoph Sommer's avatar
Christoph Sommer committed
37

Christoph Sommer's avatar
Christoph Sommer committed
38
Extract the dentritic spine skeletons graph from ilastik probability maps and export to .swc for import in Imaris
Christoph Sommer's avatar
Christoph Sommer committed
39
40

positional arguments:
Christoph Sommer's avatar
Christoph Sommer committed
41
42
  ilastik_h5            ilastik probability map(s), if not single channel the 1st channel is used. Data type must be
                        8-bit
Christoph Sommer's avatar
Christoph Sommer committed
43
44
45
46

optional arguments:
  -h, --help            show this help message and exit
  -ms MIN_SIZE, --min_size MIN_SIZE
47
48
49
50
                        Minimum object size in pixel
  -rl RESOLUTION_LEVEL, --resolution_level RESOLUTION_LEVEL
                        Resolution level used
  -s SMOOTH_SIGMA SMOOTH_SIGMA SMOOTH_SIGMA, --smooth_sigma SMOOTH_SIGMA SMOOTH_SIGMA SMOOTH_SIGMA
Christoph Sommer's avatar
Christoph Sommer committed
51
                        Smooth probability maps before thresholding. Gaussian sigma in px for ZYX
52
  -t THRESHOLD, --threshold THRESHOLD
Christoph Sommer's avatar
Christoph Sommer committed
53
                        Probability map threshold in range [0,1].
Christoph Sommer's avatar
Christoph Sommer committed
54
```
Christoph Sommer's avatar
Christoph Sommer committed
55
56
57
58
#### Jupyter:
See Jupyter notebook file

### 4. Import results to Imaris
Christoph Sommer's avatar
Christoph Sommer committed
59
60
---

Christoph Sommer's avatar
Christoph Sommer committed
61
62
####
Install the [.swc importer](./imaris_swc_impex) as a Imaris Python extension.
63
64
65
66
67

#### Example:
After pixel classification with ilastik on resolution level 2, which created a probability map volume_Probabilities.h5, use

```
Christoph Sommer's avatar
Christoph Sommer committed
68
python seg2dendrite.py volume_Probabilities.h5 --smooth 0.5 1 1 --threshold 0.5 -min_sizes 12000 --resolution_level 2
69
70
```

Christoph Sommer's avatar
Christoph Sommer committed
71
it will smooth the probability map with sigma ZYX of 0.5 x 1 x 1 and threshold at probability 0.5, filter dendrite objects for minimum size of 12000px.
72

Christoph Sommer's avatar
Christoph Sommer committed
73
### Dependencies (pip-installable)
Christoph Sommer's avatar
Christoph Sommer committed
74
Python >3.6
Christoph Sommer's avatar
Christoph Sommer committed
75
76
77
78
79
* h5py
* skan
* numpy
* networkx
* skimage