[Insight-users] itk::ImageSeriesWriter problem

Luca Pamparana luca.pamparana at gmail.com
Sun Oct 27 10:32:26 EDT 2013


Hello all,

I am trying to apply some ITK filters to input DICOM images and I am
writing DICOM back. However, there is an issue with the
ImageOrientationPatient (IOP) tag. So, the way I am writing DICOM back is
as follows:

typedef itk::NumericSeriesFileNames NamesGeneratorType;
NamesGeneratorType::Pointer namesGenerator = NamesGeneratorType::New();
std::string seriesFormat = current_out_dir + "/" + "IM_%d.dcm";
namesGenerator->SetSeriesFormat (seriesFormat.c_str());
namesGenerator->SetStartIndex(1);
namesGenerator->SetEndIndex(120);
typedef itk::Image<VoxelType, 2> OutputImageType;
typedef itk::ImageSeriesWriter<ImageType, OutputImageType >
SeriesWriterType;

SeriesWriterType::Pointer seriesWriter = SeriesWriterType::New();
// Output is from the itkTileFilter object
seriesWriter->SetInput(tileFilter->GetOutput());
seriesWriter->SetImageIO(dicomIO); //GDCMImageIO
seriesWriter->SetFileNames(namesGenerator->GetFileNames());

// Now I generate the metadatadictionary array

ReaderType::DictionaryRawPointer inputDict =
(*(itkReaders[itkReaders.size()-1]->GetMetaDataDictionaryArray()))[0];
ReaderType::DictionaryArrayType outputArray;

for (int d = 0; d < 120; ++d) {

            ReaderType::DictionaryRawPointer dict = new
ReaderType::DictionaryType;

            CopyDictionary(*inputDict, *dict);

            std::string test;

            itk::ExposeMetaData<std::string>(*dict, "0020|0037", test);

            // This outputs the correct IOP (1/0/0/0/0/-1)
            std::cout << test << std::endl;

            outputArray.push_back(dict);

        }

        seriesWriter->SetMetaDataDictionaryArray(&outputArray);
        seriesWriter->Update();

Now, even though the metadata says the IOP should be 1/0/0/0/0/-1, the
files that are generated by the last line have the IOP set to 1/0/0/0/1/0.

I am not sure what I need to do to get the IOP to the correct value. I will
appreciate any help you can give me as I am quite stuck here!

Many thanks,

Luca
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20131027/87f61525/attachment.htm>


More information about the Insight-users mailing list