Thanks for your reply.<div><br></div><div>Actually the volumetric image I have is originally an RT dose in dicom format. I need to process it a bit  so I converted it into .vtk file. Now I want to write it back to dicom format. There are 200 slices inside the original dicom file. So I thought what I could do is use the dicom header from the original RT file and use ImageSeriesWriter to write the mutilslice into the new dicom file. I implemented a code, but the problem is that albeit new dicom file contains multiple slices, only the first slice is correct and the rest are just empty (which means no dose value in each pixel). </div>
<div><br></div><div>I saw some discussions on the list. It appears to me that this is doable. would be appreciated if anyone could shed a light. The attached is the code I am using.</div><div><br></div><div><br></div><div>
<div>int main( int argc, char* argv[] ) {</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>// Verify the number of parameters in the command line</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>if( argc &lt; 4 ) {</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>std::cerr &lt;&lt; &quot;Usage: &quot; &lt;&lt; std::endl;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>std::cerr &lt;&lt; argv[0] &lt;&lt; &quot; vtkImage InputDicomImage &quot;;</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>std::cerr &lt;&lt; &quot; OutputImage \n&quot;;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>return EXIT_FAILURE;</div><div>    }</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>// the following is for an input 2D dicom file</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>typedef signed short InputPixelType;</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>const unsigned int   InputDimension = 3;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>typedef itk::Image&lt; InputPixelType, InputDimension &gt; InputImageType;</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>typedef itk::ImageFileReader&lt; InputImageType &gt; InputReaderType;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>InputReaderType::Pointer reader1 = InputReaderType::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>reader1-&gt;SetFileName( argv[1] );</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>typedef itk::GDCMImageIO          InputImageIOType;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>InputImageIOType::Pointer gdcmImageIO = InputImageIOType::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>reader1-&gt;SetImageIO( gdcmImageIO );</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>reader1-&gt;Update();</div><div><br></div><div>
<span class="Apple-tab-span" style="white-space:pre">        </span>std::cout &lt;&lt; &quot; (1) first dicom file is read in successfully ....&quot; &lt;&lt; std::endl;</div><div><br></div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>// the following is for a 3D volume file</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>typedef signed short PixelType;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>const unsigned int   Dimension = 3;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>typedef itk::Image&lt; PixelType, Dimension &gt; ImageType;</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>typedef itk::ImageFileReader&lt; ImageType  &gt;  ReaderType;</div><div>    ReaderType::Pointer reader2 = ReaderType::New();</div><div>    reader2-&gt;SetFileName( argv[2] );</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>reader2-&gt;Update();</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>std::cout &lt;&lt; &quot; (2) the 3D volume file is read in successfully ....&quot; &lt;&lt; std::endl;</div>
<div><br></div><div>    // the following is for an output 2D dicom file</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>typedef signed short OutputPixelType;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>const unsigned int   OutputDimension = 3;</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>typedef itk::Image&lt; OutputPixelType, OutputDimension &gt; OutputImageType;</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>typedef itk::ImageSeriesWriter&lt; ImageType, OutputImageType &gt; OutputWriterType;</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>OutputWriterType::Pointer writer = OutputWriterType::New();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>writer-&gt;SetFileName( argv[3] );</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>writer-&gt;SetInput( reader2-&gt;GetOutput() );</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>writer-&gt;SetMetaDataDictionary( reader1-&gt;GetMetaDataDictionary() );</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>gdcmImageIO-&gt;KeepOriginalUIDOn();</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>writer-&gt;SetImageIO( gdcmImageIO );</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>writer-&gt;Update();</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>std::cout &lt;&lt; &quot; (3) the output dicom file is saved successfully and we are done....&quot; &lt;&lt; std::endl;</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>return 0;</div></div><div><br></div><div><br><br><div class="gmail_quote">On Fri, Oct 30, 2009 at 3:16 AM, Mathieu Malaterre <span dir="ltr">&lt;<a href="mailto:mathieu.malaterre@gmail.com">mathieu.malaterre@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div><div></div><div class="h5">On Thu, Oct 29, 2009 at 8:30 PM, Ming Chao &lt;<a href="mailto:mingchao2005@gmail.com">mingchao2005@gmail.com</a>&gt; wrote:<br>

&gt; Hello ITKers,<br>
&gt; Is it possible to write a 3D volumetric image file into one dicom file in<br>
&gt; itk? Thanks,<br>
<br>
</div></div>Short version: no.<br>
Long version: yes, if you use GDCM 2.x. I am assuming that by<br>
volumetric image, you mean multiframe MR images, or multiframe CT<br>
images ? If so there support in  GDCM 1.x was very poor. So unless you<br>
actually understand what an Enhanced MR/CT Image Storage is, I would<br>
recommend against doing so. If you input is not already in that<br>
format, there is no real interest in doing so. BTW most PACS system I<br>
know of still do not work properly with those new IODs.<br>
<br>
Cheers<br>
--<br>
<font color="#888888">Mathieu<br>
</font></blockquote></div><br></div>