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 ImagesReader 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
27 // Normally (?) the following lines {== BEGIN == / ==END ==}
28 // are now useless; let here as a reminder/example
29 // Don't remove them . JPRx
31 // ==== BEGIN ======================================================
34 # Dummy way to get only the first image from the chooser
35 # ------------------------------------------------------
37 new ImagesReader chooser
39 new GetVectorVtkImageDataElement reader
41 connect chooser.Out reader.In
44 # Here loads 'hola.mhd'
45 # ---------------------
47 # Don't forget to comment out the following 2 lines
48 # If you want to check someting else.
51 include vtk/boxes/bbLoadHola
55 # uncomment next lines to have a file selector
56 # --------------------------------------------
58 new FileSelector openFileDialog
59 new ImageReader reader
60 connect openFileDialog.Out reader.In
63 # uncomment next lines to use a vtkgdcmReader
64 # -------------------------------------
66 new FileSelector openFileDialog
67 new GetInfoGdcmReader reader
68 connect openFileDialog.Out reader.In
71 # uncomment next lines to use Gimmick
72 # -----------------------------------
78 # uncomment next lines to Read a MHD file (and nothing else !)
79 # ------------------------------------------------------------
81 new FileSelector openFileDialog
82 set openFileDialog.Wildcard "(*.mhd)|*.mhd"
83 new MetaImageReader reader
84 connect openFileDialog.Out reader.In
87 # uncomment the following lines to read a 3D images stack
88 # (only if file name order is meaningfull)
89 # -------------------------------------------------------
91 // To choose the directory
92 new DirectorySelector ds
93 // To get the image names into a vector
94 new FilesFromDirectory fd
95 // To read all the files, as a bbitk::ImagePointer
96 new ImageSeriesReader reader
97 // user choosen directory as input
99 set fd.Recursive false
100 // list of files as input
101 #print "Files found in $ds.Out$\n
102 connect fd.Out reader.FileNames
105 # uncomment the following lines to read a 3D images stack
106 # (if the directory contains a 'XCoherent" Serie)
107 # -------------------------------------------------------
109 // To choose the directory
110 new DirectorySelector ds
111 // To get the image names into a vector
112 new FilesFromDirectory fd
113 // user choosen directory as input
115 // order the files, computes an accurate ZSpacing
116 new GetXCoherentInfoGdcmReader reader
117 connect fd.Out reader.In
120 # uncomment the following lines to read a 3D images stack
121 # (with DICOMDirReader)
122 # -------------------------------------------------------
124 include itk/boxes/bbDICOMDirReader
125 // To choose the directory
126 new DirectorySelector ds
127 new DICOMDirReader reader
128 connect ds.Out reader.In
131 // ==== END ======================================================
135 new CommandButton cb1
136 connect cb1.Widget main.Widget1
137 set cb1.Label "1) Select File"
138 set cb1.WinDialog true
140 connect cb1.BoxChange reader.BoxExecute
143 connect cb.Widget main.Widget2
144 set cb.Label "2) Write (no '.mhd' extention needed!"
145 set cb.WinDialog true
147 # Choose where you want to write
148 # ------------------------------
149 new FileSelector fileDialog
150 set fileDialog.OpenSave Save
151 set fileDialog.Wildcard "*.mhd"
154 connect fileDialog.Out mfn.File
155 set mfn.Extent ".mhd"
160 new MetaImageWriter writer
161 connect reader.Out writer.In
162 connect mfn.Out writer.Filename
163 connect cb.BoxChange writer.BoxExecute