Wiki

Version 57 (Annamaria Kiss, 30/05/2017 17:07)

1 51 Annamaria Kiss
*Table of Contents*
2 51 Annamaria Kiss
3 1 Annamaria Kiss
{{TOC}}
4 45 Annamaria Kiss
5 46 Annamaria Kiss
h1. lsm3d - Tools for segmenting 3D images of plant tissues at multiple scales using the level set method
6 45 Annamaria Kiss
7 45 Annamaria Kiss
One of the main technical challenges in the reconstruction of plant tissues from 3D confocal images remains the faithful segmentation at the cellular level. A typical issue with segmentation based on watershed methods is the weaker staining of some outer periclinal walls. This systematically causes segmentation errors as holes on the tissue surface.
8 45 Annamaria Kiss
9 45 Annamaria Kiss
We detect the outer surface of the tissue using level set method (lsm_contour). We enhance the signal of the outer periclinal walls by the detected outer surface. Also, we propose a new edge function, based on second order derivatives of the image, for a level set used to segment the tissue at cellular level (lsm_cells).
10 1 Annamaria Kiss
11 47 Annamaria Kiss
The "lsm3d" tools:
12 45 Annamaria Kiss
13 45 Annamaria Kiss
- *lsm_contour* --> detects the outer surface of the tissue
14 45 Annamaria Kiss
- *lsm_cells* --> used to cellular segmentation or nuclei detection
15 45 Annamaria Kiss
16 54 Annamaria Kiss
The code for both tools is written in C++, uses the CImg image processing library, and is distributed in a standalone version under the Free Software licence CeCILL v2 Licence, are included in the supplementary matters of the present article together with the description of the installation procedure as well as usage advises.
17 52 Annamaria Kiss
18 45 Annamaria Kiss
h2. Dependencies
19 1 Annamaria Kiss
20 52 Annamaria Kiss
The CImg image processing C++ library needs the Xlib library. Furthermore, the lsm_cells tool is parallelized using OpenMP.
21 45 Annamaria Kiss
22 45 Annamaria Kiss
In particular, if you do not have Xlib on your computer, you may add it:
23 45 Annamaria Kiss
* on Ubuntu:
24 45 Annamaria Kiss
<pre>
25 45 Annamaria Kiss
sudo apt-get install libx11-dev
26 45 Annamaria Kiss
</pre>
27 45 Annamaria Kiss
* on Mac OS:
28 45 Annamaria Kiss
install xQuartz from www.xquartz.org
29 45 Annamaria Kiss
30 45 Annamaria Kiss
h2. Download
31 45 Annamaria Kiss
32 45 Annamaria Kiss
In a terminal go to the directory where you wish to download and install the tool
33 45 Annamaria Kiss
<pre>
34 45 Annamaria Kiss
cd Path_to_your_directory
35 45 Annamaria Kiss
</pre> and then download using svn
36 45 Annamaria Kiss
<pre>
37 45 Annamaria Kiss
svn --username $USER checkout http://forge.cbp.ens-lyon.fr/svn/levelsetmethod/lsm3D
38 45 Annamaria Kiss
</pre>
39 45 Annamaria Kiss
40 45 Annamaria Kiss
41 45 Annamaria Kiss
h2. Compile
42 45 Annamaria Kiss
43 45 Annamaria Kiss
<pre>
44 45 Annamaria Kiss
cd lsm3D
45 45 Annamaria Kiss
./lsm3D_compile.sh
46 45 Annamaria Kiss
</pre>
47 45 Annamaria Kiss
48 45 Annamaria Kiss
The binaries will be in the lsm3D/bin folder. Add this folder to your PATH by adding in your .bashrc file
49 45 Annamaria Kiss
<pre>
50 45 Annamaria Kiss
export PATH=$PATH:Path_to_your_directory/lsm3D/bin
51 45 Annamaria Kiss
</pre>
52 45 Annamaria Kiss
53 49 Annamaria Kiss
Troubleshooting if problems with compilation :
54 49 Annamaria Kiss
In the file lsm3d/lsm3D_compile.sh
55 49 Annamaria Kiss
- you might have to choose an appropriate compiler, which supports OpenMP.
56 49 Annamaria Kiss
- you might need to precise the location of the X11 library in the compilation options.
57 45 Annamaria Kiss
58 49 Annamaria Kiss
59 48 Annamaria Kiss
h2. Methods and usage
60 6 Annamaria Kiss
61 30 Annamaria Kiss
The main idea of the level set method in image segmentation is to evolve a contour until it fits a desired object in the image. A  level set function (LSF) is defined on the image (one value per pixel), and the contour is defined as it's zero crossing points. The function is positive inside the contour and negative outside of it. At each time step, the values of the LSF are updated in each pixel, and thus the zero crossing points change and the contour evolves. The LSF's evolution is such that an energy is minimized, which in turn is usually based on the image properties (gradient, intensity...) and the geometrical aspects of the contour (curvature, size...).
62 1 Annamaria Kiss
63 6 Annamaria Kiss
64 6 Annamaria Kiss
h3. lsm_contour --> detects the outer surface of the tissue 
65 1 Annamaria Kiss
66 31 Annamaria Kiss
67 23 Annamaria Kiss
!>lsm_contour_100.png!The LSF is initialized with a linear threshold, which roughly separates the background from the cells. The threshold is linear in order to adjust for the image intensity variation along the z-axis. The function takes +c0 values inside the initial contour and -c0 outside, the area in the contour being the background. The contour evolves attracted mainly by the maximum gradient, corresponding to the edge of the cell walls. There are also a curvature term, to obtain a smoother contour, and an accelerating area term to push the contour towards the boundaries. At each time step, the background growth is measured. The algorithm stops when the growth stays in a small interval near zero for ten consecutive iterations.
68 1 Annamaria Kiss
69 49 Annamaria Kiss
*Usage*
70 10 Annamaria Kiss
71 10 Annamaria Kiss
In order to check the syntax, just lounch the binary without any argument. It will give as output
72 22 Annamaria Kiss
<pre>
73 29 Annamaria Kiss
Usage : lsm_contour img t_up t_down a b smooth perUp perDown
74 6 Annamaria Kiss
Examples for parameter values:
75 6 Annamaria Kiss
------------------------------
76 6 Annamaria Kiss
img : grayscale image of cells, (.inr or .inr.gz)
77 6 Annamaria Kiss
Upper threshold : t_up = 20
78 6 Annamaria Kiss
Down threshold : t_down = 5
79 6 Annamaria Kiss
Area term : a = 0 (0.5, 1)
80 6 Annamaria Kiss
Curvature term : b = 0 (1)
81 6 Annamaria Kiss
Gaussian filter : smooth = 1 (0, if image already filtered)
82 6 Annamaria Kiss
Stop criteria : the contour evolution is in [perDown,perUp] for 10 consecutive iterations
83 6 Annamaria Kiss
     perUp = 0.002, perDown = -0.002
84 6 Annamaria Kiss
</pre>
85 6 Annamaria Kiss
86 33 Annamaria Kiss
In order to test it on an image file "sample-stack.inr.gz", lounch the binary with parameters :
87 6 Annamaria Kiss
88 1 Annamaria Kiss
<pre>
89 33 Annamaria Kiss
lsm_contour sample-stack.inr.gz 20 10 0 0 1 0.002 -0.002
90 1 Annamaria Kiss
</pre>
91 1 Annamaria Kiss
92 33 Annamaria Kiss
The detected contour is in the directory "sample-stack_LSMcont20-10a0b0s1".
93 1 Annamaria Kiss
94 26 Annamaria Kiss
95 50 Annamaria Kiss
h3. lsm_cells --> for cellular or nuclear segmentation
96 1 Annamaria Kiss
97 1 Annamaria Kiss
!>lsm_cells_100.png!The detection of cell-shapes is done in 3 steps :
98 15 Annamaria Kiss
- eroding the watershed segmentation and initialize a function for each cell
99 15 Annamaria Kiss
- evolve independently each cell's contour, attract by the maximal gradient (the inside edge of the cell walls)
100 12 Annamaria Kiss
- evolve simultaneously every cell's contour, attract by the maximal intensity (center of the cell walls)
101 1 Annamaria Kiss
In the last step, every cell evolves for one iteration and then possible overlap is checked. An overlap region is considered not segmented. A cell can't evolve in an other cell area : overlap can only happen in a same iteration. At each iteration, the growth of the segmented areas is measured, and the algorithm stops when this growth becomes null.
102 6 Annamaria Kiss
103 49 Annamaria Kiss
*Usage*
104 6 Annamaria Kiss
105 11 Annamaria Kiss
You can recall the syntax any time by lounching the binary without any argument:
106 6 Annamaria Kiss
<pre>
107 6 Annamaria Kiss
Usage : lsm_cells img img_wat img_contour erosion [a b smooth lsm_type]
108 6 Annamaria Kiss
----------------- 
109 6 Annamaria Kiss
img : grayscale image of cells, (.inr or .inr.gz)
110 6 Annamaria Kiss
img_wat : image of seeds, (.inr or .inr.gz)
111 6 Annamaria Kiss
img_contour : mask, where cells do not evolve, (.inr or .inr.gz)
112 6 Annamaria Kiss
              if 'None', then cells can evolve on the whole image
113 6 Annamaria Kiss
erosion : amount of erosion of seeds for initialisation (uint8) --> -2, 0, 2
114 6 Annamaria Kiss
              if 0, then no erosion or dilation
115 6 Annamaria Kiss
              if negative, then a dilation is performed
116 6 Annamaria Kiss
a : area term (float) --> 0 or 0.5 or 1 (the default is 0.5)
117 6 Annamaria Kiss
              if negative, the object retracts
118 6 Annamaria Kiss
              if positive, the object inflates
119 6 Annamaria Kiss
b : curvature term (float) --> 0 or 1 (the default is 0)
120 6 Annamaria Kiss
gamma : scale parameter (float>0) --> 0.5 or 1 (the default is 1)
121 6 Annamaria Kiss
smooth : gaussian blur to apply to the image (int) --> 0 or 1 (the default is 0)
122 6 Annamaria Kiss
lsm_type : image, gradient or hessien based evolution --> 'i', 'g' or 'h' (the default is g)
123 6 Annamaria Kiss
</pre>
124 6 Annamaria Kiss
125 33 Annamaria Kiss
Applying it to the image "sample-stack.inr.gz" as the level sets are initialised by the watershed segmentation of the same image
126 1 Annamaria Kiss
<pre>
127 34 Annamaria Kiss
lsm_cells sample-stack.inr.gz sample-stack-watershed.inr.gz 'None' 2 0.3 0 0.2 1 'h'
128 57 Annamaria Kiss
</pre> you will get the new segmentation in the "sample-stack-watershed_cellLSM-d2-a0.3-b0-g0.2-s1-h" folder. Or if you would like to use a mask image as background, you can make the test with the previously detected contour as a mask, by replacing 'None' in the previous command by 'sample-stack_LSMcont20-10a0b0s1/sample-stack_LSMcont20-10a0b0s1.inr.gz'.