<div dir="ltr">I'm able to write individual slices from a mha or mhd file, is that the same as nifti file? if so, I can send you the code, I think it's a copy/paste from one of the examples out there.</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 23, 2015 at 12:11 PM, AI <span dir="ltr"><<a href="mailto:audrey.istace@imavie.fr" target="_blank">audrey.istace@imavie.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
I would like to write Dicom files from a nifti image files using<br>
DCMTKImageIO. In the code below, I read a nifti file using<br>
itkImageFileReader, and then try to write dicom files using<br>
itkImageSeriesWriter. I was not able to do it, probably because of the<br>
SetMetaDataDictionaryArray method, that I don’t know how to use since I<br>
don’t read dicom series as input. Can you help me with that ?<br>
<br>
Thank you very much,<br>
<br>
Audrey<br>
<br>
#include "itkDCMTKImageIO.h"<br>
#include "itkNumericSeriesFileNames.h"<br>
#include "itkImageFileReader.h"<br>
#include "itkImageSeriesWriter.h"<br>
<br>
int main(int argc, char *argv[])<br>
{<br>
               typedef signed short<br>
PixelType;<br>
               const unsigned int<br>
Dimension = 3;<br>
               typedef itk::Image< PixelType, Dimension ><br>
ImageType;<br>
               typedef itk::Image< PixelType, 2 ><br>
OutputImageType;<br>
               typedef itk::ImageFileReader< ImageType ><br>
ReaderType;<br>
               typedef itk::DCMTKImageIO<br>
ImageIOType;<br>
               typedef itk::NumericSeriesFileNames<br>
NamesGeneratorType;<br>
               typedef itk::ImageSeriesWriter< ImageType, OutputImageType ><br>
WriterType;<br>
<br>
               ImageIOType::Pointer dcmtkIO = ImageIOType::New();<br>
               NamesGeneratorType::Pointer namesGenerator =<br>
NamesGeneratorType::New();<br>
               ReaderType::Pointer reader = ReaderType::New();<br>
               WriterType::Pointer writer = WriterType::New();<br>
<br>
               reader->SetFileName( "../../out.nii" );<br>
               reader->Update();<br>
<br>
<br>
<br>
               itksys::SystemTools::MakeDirectory( "../../OutputDicom/" );<br>
<br>
               std::string seriesFormat = "../../OutputDicom/IM%d.dcm";<br>
               namesGenerator->SetSeriesFormat (seriesFormat.c_str());<br>
               namesGenerator->SetStartIndex (1);<br>
               namesGenerator->SetEndIndex (166);<br>
<br>
<br>
               writer->SetInput( reader->GetOutput() );<br>
               writer->SetImageIO( dcmtkIO );<br>
               writer->SetFileNames( namesGenerator->GetFileNames() );<br>
//           writer->SetMetaDataDictionaryArray(<br>
reader->GetMetaDataDictionaryArray() );<br>
               writer->Update();<br>
}<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://itk-insight-users.2283740.n2.nabble.com/itk-Writing-dicom-files-from-single-3D-file-tp7587034.html" target="_blank">http://itk-insight-users.2283740.n2.nabble.com/itk-Writing-dicom-files-from-single-3D-file-tp7587034.html</a><br>
Sent from the ITK Insight Users mailing list archive at Nabble.com.<br>
_____________________________________<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.php" target="_blank">http://www.kitware.com/products/protraining.php</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://public.kitware.com/mailman/listinfo/insight-users" target="_blank">http://public.kitware.com/mailman/listinfo/insight-users</a><br>
</blockquote></div><br></div>