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

Ming Chao mingchao2005 at gmail.com
Fri Oct 30 09:35:37 EDT 2009


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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20091030/38ab69e4/attachment-0001.htm>


More information about the Insight-users mailing list