[Community] [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://public.kitware.com/pipermail/community/attachments/20131027/87f61525/attachment-0001.html>
-------------- next part --------------
_____________________________________
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.php
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 Community
mailing list