]> Creatis software - bbtk.git/blob - packages/demo/bbs/appli/exampleViewing1-1.bbs
Feature #1774
[bbtk.git] / packages / demo / bbs / appli / exampleViewing1-1.bbs
1  # ---------------------------------------------------------------------
2  #
3  # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4  #                        pour la SantÈ)
5  # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6  # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7  # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8  #
9  #  This software is governed by the CeCILL-B license under French law and
10  #  abiding by the rules of distribution of free software. You can  use,
11  #  modify and/ or redistribute the software under the terms of the CeCILL-B
12  #  license as circulated by CEA, CNRS and INRIA at the following URL
13  #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14  #  or in the file LICENSE.txt.
15  #
16  #  As a counterpart to the access to the source code and  rights to copy,
17  #  modify and redistribute granted by the license, users are provided only
18  #  with a limited warranty  and the software's author,  the holder of the
19  #  economic rights,  and the successive licensors  have only  limited
20  #  liability.
21  #
22  #  The fact that you are presently reading this means that you have had
23  #  knowledge of the CeCILL-B license and that you accept its terms.
24  # ------------------------------------------------------------------------ */
25  
26 description "3 slicers and a 3D view"
27 author "jpr@creatis.insa-lyon.fr"
28 category "example, tool"
29
30 // To show how easy it is to add smthing
31 // =====================================
32
33 load vtk
34 include wxvtk
35 load std
36 load itk
37 include vtk
38 include wx
39 load itkvtk
40 load gdcmvtk
41
42 include wxvtk/boxes/bbSimpleSlicer
43
44 new LayoutX4 main
45
46 new LayoutLine  upright
47 new LayoutLine  upleft
48 new LayoutLine  downleft
49 new LayoutSplit downright
50    set downright.Proportion 85
51
52 connect upright.Widget   main.Widget1
53 connect upleft.Widget    main.Widget2
54 connect downleft.Widget  main.Widget3
55 connect downright.Widget main.Widget4
56
57 # Use new box (choose the way you want to select images)
58 # -----------------------------------------------------
59 load creaImageIO
60 new ImagesChooserDialogBox chooser
61
62 # Concatenate all the supposed-to-be consistent 2D images into a single vtkImageData
63 # WARNING : File names alphabetical order is suposed to be meaningful ...
64
65 new ConcatImages reader
66    connect chooser.Out reader.In
67
68 // Normally (?) the following lines {== BEGIN == / ==END ==}
69 // are now useless; let here as a reminder/example
70 // Don't remove them . JPRx
71
72 // ==== BEGIN ======================================================
73
74 /* 
75 # Dummy way to get only the first image from the chooser
76 # ------------------------------------------------------
77 load creaImageIO
78 new ImagesChooserDialogBox chooser
79
80 new GetVectorVtkImageDataElement reader
81    set reader.I 0
82    connect chooser.Out reader.In
83 */
84
85 # Here loads 'hola.mhd'
86 # ---------------------
87
88 # Don't forget to comment out the following 2 lines
89 # If you want to check someting else.
90
91 /*
92 include vtk/boxes/bbLoadHola
93 new LoadHola reader
94 */
95
96 # uncomment next lines to have a file selector
97 # --------------------------------------------
98 /*
99 new FileSelector openFileDialog
100 new ImageReader reader
101   connect openFileDialog.Out reader.In
102 */
103
104 # uncomment next lines to use a vtkgdcmReader
105 # -------------------------------------
106 /*
107 new FileSelector openFileDialog
108 new GetInfoGdcmReader reader
109   connect openFileDialog.Out reader.In
110 */
111
112 # uncomment next lines to use Gimmick
113 # -----------------------------------
114 /*
115 load creaImageIO
116 new Gimmick reader
117 */
118
119 # uncomment next lines to Read a MHD file (and nothing else !)
120 # ------------------------------------------------------------
121 /*
122 new FileSelector openFileDialog
123  set openFileDialog.Wildcard  "(*.mhd)|*.mhd"
124 new MetaImageReader reader
125    connect openFileDialog.Out reader.In
126 */
127
128 # uncomment the following lines to read a 3D images stack
129 # (only if file name order is meaningfull)
130 # -------------------------------------------------------
131 /*
132 // To choose the directory
133 new DirectorySelector ds
134 // To get the image names into a vector
135 new FilesFromDirectory fd
136 // To read all the files, as a bbitk::ImagePointer
137 new ImageSeriesReader reader
138 // user choosen directory as input
139 connect ds.Out fd.In
140 set fd.Recursive false
141 // list of files as input
142 #print "Files found in $ds.Out$\n
143 connect fd.Out reader.FileNames
144 */
145
146 # uncomment the following lines to read a 3D images stack
147 # (if the directory contains a 'XCoherent" Serie)
148 # -------------------------------------------------------
149 /*
150 // To choose the directory
151 new DirectorySelector ds
152 // To get the image names into a vector
153 new FilesFromDirectory fd
154 // user choosen directory as input
155 connect ds.Out fd.In 
156 // order the files, computes an accurate ZSpacing
157 new GetXCoherentInfoGdcmReader reader
158 connect fd.Out reader.In
159 */
160
161 # uncomment the following lines to read a 3D images stack
162 # (with DICOMDirReader)
163 # -------------------------------------------------------
164 /*
165 include itk/boxes/bbDICOMDirReader
166 // To choose the directory
167 new DirectorySelector ds
168 new DICOMDirReader reader
169    connect ds.Out reader.In
170 */
171
172 // ==== END ======================================================
173
174 // We need that to set Sliders sizes
175
176 #Get image dimensions, ...
177 new ImageProperties mc
178    connect reader.Out mc.In
179
180 #Get number of column (X)
181 new GetVectorIntElement gveX
182    connect mc.Size gveX.In
183    set gveX.I 0
184
185 #Get number of rows (Y)
186 new GetVectorIntElement gveY
187    connect mc.Size gveY.In
188    set gveY.I 1
189
190 #Get number of planes  (Z)
191 new GetVectorIntElement gveZ
192    connect mc.Size gveZ.In
193    set gveZ.I 2
194 //print "Dim Z $gveZ.Out"
195
196 #Compute the number of the 'middle' slice on X axis
197 new Div div0
198   connect   gveX.Out div0.In1
199   set div0.In2 2
200
201 #Compute the number of the 'middle' slice on Y axis
202 new Div div1
203   connect   gveY.Out div1.In1
204   set div1.In2 2
205
206 #Compute the number of the 'middle' slice on Z axis
207 new Div div2
208   connect   gveZ.Out div2.In1
209   set div2.In2 2
210
211 // For X axis
212 new SimpleSlicer viewerUL
213   connect reader.Out viewerUL.In
214   connect viewerUL.Widget upleft.Widget1
215   #initial slice is the middle one
216   connect div0.Out viewerUL.Slice
217   #Slider size is the number of planes
218   connect  gveX.Out viewerUL.SliderSize
219   set viewerUL.SliderReactiveOnTrack 1
220   set viewerUL.Orientation 0
221   set viewerUL.SliderOrientation H
222   set viewerUL.SliderTitle "Planes YZ"
223
224 // For Y axis
225 new SimpleSlicer viewerUR
226   connect reader.Out viewerUR.In
227   connect viewerUR.Widget upright.Widget1
228   #initial slice is the middle one
229   connect div1.Out viewerUR.Slice
230   #Slider size is the number of planes
231   connect  gveY.Out viewerUR.SliderSize
232   set viewerUR.SliderReactiveOnTrack 1
233   set viewerUR.SliderOrientation H
234   set viewerUR.Orientation 1
235   set viewerUR.SliderTitle "Planes XZ"
236
237 // For Z axis
238 new SimpleSlicer viewerTD
239   connect reader.Out viewerTD.In
240   connect viewerTD.Widget downleft.Widget1
241   #initial slice is the middle one
242   connect div2.Out viewerTD.Slice
243   #Slider size is the number of planes
244   connect  gveZ.Out viewerTD.SliderSize
245   set viewerTD.SliderReactiveOnTrack 1
246   set viewerTD.SliderOrientation H
247   set viewerTD.Orientation 2
248   set viewerTD.SliderTitle "Planes XY"
249
250 //For 3D Viewer
251
252 new ImagePlanes planes
253   connect reader.Out planes.In
254
255 new Viewer3D viewer
256   connect planes.PlaneX viewer.Obs1
257   connect planes.PlaneY viewer.Obs2
258   connect planes.PlaneZ viewer.Obs3
259
260 new CheckBox   chkbox
261   set chkbox.Title "Interpolate Pixels (in '2D' images)"
262   set chkbox.In 1
263   connect chkbox.BoxChange   viewerUL.BoxExecute
264   connect chkbox.BoxChange   viewerUR.BoxExecute
265   connect chkbox.BoxChange   viewerTD.BoxExecute
266
267   connect viewer.Widget downright.Widget1
268   connect chkbox.Widget downright.Widget2
269
270   connect chkbox.Out viewerUL.Interpolate
271   connect chkbox.Out viewerUR.Interpolate
272   connect chkbox.Out viewerTD.Interpolate
273
274 set main.WinTitle "demoViewing1"
275 exec main
276 exec viewerTD