[Insight-users] how to write a 3D volumetric image file into one dicom file?

Luis Ibanez luis.ibanez at kitware.com
Sun Nov 1 17:11:43 EST 2009


Hi Ming,

It looks like you are taking the MetaDataDictionnary from reading a single
DICOM slice with "reader1", and then passing it to the series writer.

You may want to read the original series, in order to take the
MetaDataDictionnary from it.

See the example in:

         Insight/Examples/IO/
                             DicomSeriesReadSeriesWrite.cxx


    Regards,


              Luis


----------------------------------------------------------------------------------------------
On Fri, Oct 30, 2009 at 8:35 AM, Ming Chao <mingchao2005 at gmail.com> wrote:
> Thanks for your reply.
> 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).
> 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.
>
> int main( int argc, char* argv[] ) {
> // Verify the number of parameters in the command line
> if( argc < 4 ) {
> std::cerr << "Usage: " << std::endl;
> std::cerr << argv[0] << " vtkImage InputDicomImage ";
> std::cerr << " OutputImage \n";
> return EXIT_FAILURE;
>     }
> // the following is for an input 2D dicom file
> typedef signed short InputPixelType;
> const unsigned int   InputDimension = 3;
> typedef itk::Image< InputPixelType, InputDimension > InputImageType;
> typedef itk::ImageFileReader< InputImageType > InputReaderType;
> InputReaderType::Pointer reader1 = InputReaderType::New();
> reader1->SetFileName( argv[1] );
> typedef itk::GDCMImageIO          InputImageIOType;
> InputImageIOType::Pointer gdcmImageIO = InputImageIOType::New();
> reader1->SetImageIO( gdcmImageIO );
> reader1->Update();
> std::cout << " (1) first dicom file is read in successfully ...." <<
> std::endl;
>
> // the following is for a 3D volume file
> typedef signed short PixelType;
> const unsigned int   Dimension = 3;
> typedef itk::Image< PixelType, Dimension > ImageType;
> typedef itk::ImageFileReader< ImageType  >  ReaderType;
>     ReaderType::Pointer reader2 = ReaderType::New();
>     reader2->SetFileName( argv[2] );
> reader2->Update();
> std::cout << " (2) the 3D volume file is read in successfully ...." <<
> std::endl;
>     // the following is for an output 2D dicom file
> typedef signed short OutputPixelType;
> const unsigned int   OutputDimension = 3;
> typedef itk::Image< OutputPixelType, OutputDimension > OutputImageType;
> typedef itk::ImageSeriesWriter< ImageType, OutputImageType >
> OutputWriterType;
> OutputWriterType::Pointer writer = OutputWriterType::New();
> writer->SetFileName( argv[3] );
> writer->SetInput( reader2->GetOutput() );
> writer->SetMetaDataDictionary( reader1->GetMetaDataDictionary() );
> gdcmImageIO->KeepOriginalUIDOn();
> writer->SetImageIO( gdcmImageIO );
> writer->Update();
> std::cout << " (3) the output dicom file is saved successfully and we are
> done...." << std::endl;
> return 0;
>
>
> On Fri, Oct 30, 2009 at 3:16 AM, Mathieu Malaterre
> <mathieu.malaterre at gmail.com> wrote:
>>
>> On Thu, Oct 29, 2009 at 8:30 PM, Ming Chao <mingchao2005 at gmail.com> wrote:
>> > Hello ITKers,
>> > Is it possible to write a 3D volumetric image file into one dicom file
>> > in
>> > itk? Thanks,
>>
>> Short version: no.
>> Long version: yes, if you use GDCM 2.x. I am assuming that by
>> volumetric image, you mean multiframe MR images, or multiframe CT
>> images ? If so there support in  GDCM 1.x was very poor. So unless you
>> actually understand what an Enhanced MR/CT Image Storage is, I would
>> recommend against doing so. If you input is not already in that
>> format, there is no real interest in doing so. BTW most PACS system I
>> know of still do not work properly with those new IODs.
>>
>> Cheers
>> --
>> Mathieu
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>


More information about the Insight-users mailing list