2 description "Reads and image file / stack of image files, writes it as a MHD file"
3 author "jpr@creatis.insa-lyon.fr"
4 category "tool, read/write"
16 # Use new box (choose the way you want to select images)
17 # -----------------------------------------------------
19 new ImagesChooserDialogBox chooser
21 # Concatenate all the supposed-to-be consistent 2D images into a single vtkImageData
22 # WARNING : File names alphabetical order is suposed to be meaningful ...
24 new ConcatImages reader
25 connect chooser.Out reader.In
30 // Normally (?) the following lines {== BEGIN == / ==END ==}
31 // are now useless; let here as a reminder/example
32 // Don't remove them. JPRx
34 // ==== BEGIN ======================================================
37 # Dummy way to get only the first image from the chooser
38 # ------------------------------------------------------
40 new ImagesChooserDialogBox chooser
42 new GetVectorVtkImageDataElement reader
44 connect chooser.Out reader.In
47 # Here loads 'hola.mhd'
48 # ---------------------
50 # Don't forget to comment out the following 2 lines
51 # If you want to check someting else.
54 include vtk/boxes/bbLoadHola
58 # uncomment next lines to have a file selector
59 # --------------------------------------------
61 new FileSelector openFileDialog
62 new ImageReader reader
63 connect openFileDialog.Out reader.In
66 # uncomment next lines to use a vtkgdcmReader
67 # -------------------------------------
69 new FileSelector openFileDialog
70 new GetInfoGdcmReader reader
71 connect openFileDialog.Out reader.In
74 # uncomment next lines to use Gimmick
75 # -----------------------------------
81 # uncomment next lines to Read a MHD file (and nothing else !)
82 # ------------------------------------------------------------
84 new FileSelector openFileDialog
85 set openFileDialog.Wildcard "(*.mhd)|*.mhd"
86 new MetaImageReader reader
87 connect openFileDialog.Out reader.In
90 # uncomment the following lines to read a 3D images stack
91 # (only if file name order is meaningfull)
92 # -------------------------------------------------------
94 // To choose the directory
95 new DirectorySelector ds
96 // To get the image names into a vector
97 new FilesFromDirectory fd
98 // To read all the files, as a bbitk::ImagePointer
99 new ImageSeriesReader reader
100 // user choosen directory as input
102 set fd.Recursive false
103 // list of files as input
104 #print "Files found in $ds.Out$\n
105 connect fd.Out reader.FileNames
108 # uncomment the following lines to read a 3D images stack
109 # (if the directory contains a 'XCoherent" Serie)
110 # -------------------------------------------------------
112 // To choose the directory
113 new DirectorySelector ds
114 // To get the image names into a vector
115 new FilesFromDirectory fd
116 // user choosen directory as input
118 // order the files, computes an accurate ZSpacing
119 new GetXCoherentInfoGdcmReader reader
120 connect fd.Out reader.In
123 # uncomment the following lines to read a 3D images stack
124 # (with DICOMDirReader)
125 # -------------------------------------------------------
127 include itk/boxes/bbDICOMDirReader
128 // To choose the directory
129 new DirectorySelector ds
130 new DICOMDirReader reader
131 connect ds.Out reader.In
134 // ==== END ======================================================
139 new CommandButton cb1
140 set cb1.Label "1) Select File"
141 set cb1.WinDialog true
142 connect cb1.Widget main.Widget1
144 connect cb1.BoxChange reader.BoxExecute
147 set slc.Orientation 2
148 set slc.SliderReactiveOnTrack 1
149 connect reader.Out slc.In
150 // It doesn't work ?!?, needs to "exec slc" // JPR
151 connect reader.BoxChange slc.BoxExecute
156 connect cb.Widget main.Widget2
157 set cb.Label "2) Write (no '.mhd' extention needed!"
158 set cb.WinDialog true
160 new CommandButton next
161 connect next.Widget main.Widget3
162 set next.Label "Next !"
163 set next.WinDialog true
164 // It doesn't work : <<the black box "main" is still connected">>
165 set next.In "delete main"
167 # Choose where you want to write
168 # ------------------------------
169 new FileSelector fileDialog
170 set fileDialog.OpenSave Save
171 set fileDialog.Wildcard "*.mhd"
174 connect fileDialog.Out mfn.File
175 set mfn.Extent ".mhd"
180 new MetaImageWriter writer
181 connect reader.Out writer.In
182 connect mfn.Out writer.Filename
183 connect cb.BoxChange writer.BoxExecute