Hi Luis,<div><br></div><div>Exactly. My problem was that in the output 3D dicom file only one slice showed the correct information. The rest were just empty. Is this due to the MetaDataDictionary from a single DICOM slice? Thanks,</div>
<div><br></div><div>Ming<br><br><div class="gmail_quote">On Sun, Nov 1, 2009 at 5:11 PM, Luis Ibanez <span dir="ltr"><<a href="mailto:luis.ibanez@kitware.com">luis.ibanez@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi Ming,<br>
<br>
It looks like you are taking the MetaDataDictionnary from reading a single<br>
DICOM slice with "reader1", and then passing it to the series writer.<br>
<br>
You may want to read the original series, in order to take the<br>
MetaDataDictionnary from it.<br>
<br>
See the example in:<br>
<br>
Insight/Examples/IO/<br>
DicomSeriesReadSeriesWrite.cxx<br>
<br>
<br>
Regards,<br>
<br>
<br>
Luis<br>
<br>
<br>
----------------------------------------------------------------------------------------------<br>
<div><div></div><div class="h5">On Fri, Oct 30, 2009 at 8:35 AM, Ming Chao <<a href="mailto:mingchao2005@gmail.com">mingchao2005@gmail.com</a>> wrote:<br>
> Thanks for your reply.<br>
> Actually the volumetric image I have is originally an RT dose in dicom<br>
> format. I need to process it a bit so I converted it into .vtk file. Now I<br>
> want to write it back to dicom format. There are 200 slices inside the<br>
> original dicom file. So I thought what I could do is use the dicom header<br>
> from the original RT file and use ImageSeriesWriter to write the mutilslice<br>
> into the new dicom file. I implemented a code, but the problem is that<br>
> albeit new dicom file contains multiple slices, only the first slice is<br>
> correct and the rest are just empty (which means no dose value in each<br>
> pixel).<br>
> I saw some discussions on the list. It appears to me that this is doable.<br>
> would be appreciated if anyone could shed a light. The attached is the code<br>
> I am using.<br>
><br>
> int main( int argc, char* argv[] ) {<br>
> // Verify the number of parameters in the command line<br>
> if( argc < 4 ) {<br>
> std::cerr << "Usage: " << std::endl;<br>
> std::cerr << argv[0] << " vtkImage InputDicomImage ";<br>
> std::cerr << " OutputImage \n";<br>
> return EXIT_FAILURE;<br>
> }<br>
> // the following is for an input 2D dicom file<br>
> typedef signed short InputPixelType;<br>
> const unsigned int InputDimension = 3;<br>
> typedef itk::Image< InputPixelType, InputDimension > InputImageType;<br>
> typedef itk::ImageFileReader< InputImageType > InputReaderType;<br>
> InputReaderType::Pointer reader1 = InputReaderType::New();<br>
> reader1->SetFileName( argv[1] );<br>
> typedef itk::GDCMImageIO InputImageIOType;<br>
> InputImageIOType::Pointer gdcmImageIO = InputImageIOType::New();<br>
> reader1->SetImageIO( gdcmImageIO );<br>
> reader1->Update();<br>
> std::cout << " (1) first dicom file is read in successfully ...." <<<br>
> std::endl;<br>
><br>
> // the following is for a 3D volume file<br>
> typedef signed short PixelType;<br>
> const unsigned int Dimension = 3;<br>
> typedef itk::Image< PixelType, Dimension > ImageType;<br>
> typedef itk::ImageFileReader< ImageType > ReaderType;<br>
> ReaderType::Pointer reader2 = ReaderType::New();<br>
> reader2->SetFileName( argv[2] );<br>
> reader2->Update();<br>
> std::cout << " (2) the 3D volume file is read in successfully ...." <<<br>
> std::endl;<br>
> // the following is for an output 2D dicom file<br>
> typedef signed short OutputPixelType;<br>
> const unsigned int OutputDimension = 3;<br>
> typedef itk::Image< OutputPixelType, OutputDimension > OutputImageType;<br>
> typedef itk::ImageSeriesWriter< ImageType, OutputImageType ><br>
> OutputWriterType;<br>
> OutputWriterType::Pointer writer = OutputWriterType::New();<br>
> writer->SetFileName( argv[3] );<br>
> writer->SetInput( reader2->GetOutput() );<br>
> writer->SetMetaDataDictionary( reader1->GetMetaDataDictionary() );<br>
> gdcmImageIO->KeepOriginalUIDOn();<br>
> writer->SetImageIO( gdcmImageIO );<br>
> writer->Update();<br>
> std::cout << " (3) the output dicom file is saved successfully and we are<br>
> done...." << std::endl;<br>
> return 0;<br>
><br>
><br>
> On Fri, Oct 30, 2009 at 3:16 AM, Mathieu Malaterre<br>
> <<a href="mailto:mathieu.malaterre@gmail.com">mathieu.malaterre@gmail.com</a>> wrote:<br>
>><br>
>> On Thu, Oct 29, 2009 at 8:30 PM, Ming Chao <<a href="mailto:mingchao2005@gmail.com">mingchao2005@gmail.com</a>> wrote:<br>
>> > Hello ITKers,<br>
>> > Is it possible to write a 3D volumetric image file into one dicom file<br>
>> > in<br>
>> > itk? Thanks,<br>
>><br>
>> 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>
>> Mathieu<br>
><br>
><br>
</div></div>> _____________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Kitware offers ITK Training Courses, for more information visit:<br>
> <a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
><br>
> Please keep messages on-topic and check the ITK FAQ at:<br>
> <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
><br>
><br>
</blockquote></div><br></div>