Hi Roberta,<br><br><br> Welcome to ITK !<br><br><br>Please tell of more about what happens<br>when you run the code.<br><br>Do you get any error messages ?<br><br>What is the size of your image ?<br>(number of pixels along X, Y and Z)<br>
<br>You may want to try the example:<br><br>Insight/Examples/IO/<br> ImageReadDicomSeriesWrite.cxx<br><br>(without any modifications) first,<br>and verify that it can read your image<br>and write it as a series of DICOM slices.<br>
<br><br> Thanks<br><br><br> Luis<br><br><br>-------------------------------------------------------<br><div class="gmail_quote">On Thu, Jun 24, 2010 at 5:59 AM, Roberta Beneduce <span dir="ltr"><<a href="mailto:bluangel_br@hotmail.it">bluangel_br@hotmail.it</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div>
<font color="#008000" size="2"><font color="#008000" size="2">
<font color="#000000">Hi, </font><br>
<font color="#000000">I'm Roberta and I'm an biomedical engineer and a unskilled itk user. I have to converter and write an 3D image in a DICOM series. I' m following the itk guide exsamples. Even if the code compiles, the writing isn' t done. I wrote the following code, it's only a method in a project not implemented by me. I olso added the necessary typedef to understand the problem.</font><br>
<font color="#000000">I'm waiting for useful informations.</font><br>
<font color="#000000">Thank you for availability.</font><br>
<font color="#000000">(I'm sorry for my english and for my computer science knowledge).</font><br>
<font color="#000000"></font> <br><font color="#000000"><font color="#0000ff" size="2"><font color="#0000ff" size="2">
#define</font></font><font size="2"> DataType </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">unsigned</font></font><font size="2"> </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">short</font></font><font size="2"> <br>
</font></font>
<font color="#000000"></font> <br><font color="#000000"><font size="2"><font color="#0000ff" size="2"><font color="#0000ff" size="2">
class</font></font><font size="2"> MbElementConverter <br>
{ <br>
</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">public</font></font><font size="2">: <br></font><font size="2">
</font><font color="#008000" size="2"><font color="#008000" size="2">//Itk Input Image<br></font></font><font size="2">
</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">typedef</font></font><font size="2"> Image <DataType , 3 > DataImageType;</font><br>
<font size="2">.........<br></font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2"></font></font>
<font color="#0000ff"></font> <br><font color="#0000ff"><font color="#0000ff" size="2"><font color="#0000ff" size="2">
class</font></font><font color="#000000" size="2"> MbDifference : </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">public</font></font><font size="2"><font color="#000000"> MbProgrammableAlgo</font><br>
{<br></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">
protected</font></font><font size="2"><font color="#000000">:</font><br></font></font>
<font color="#0000ff" size="2"><font color="#0000ff" size="2">typedef</font></font><font size="2"> </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">unsigned</font></font><font size="2"> </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">short</font></font><font size="2"> PixelType;<br>
</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">typedef</font></font><font size="2"> itk::Image< PixelType, Dimension2 > ImageType2D;<br>
</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">typedef</font></font><font size="2"> itk::Image< </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">float</font></font><font size="2">, Dimension3 > ImageType3DF;<br>
</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">typedef</font></font><font size="2"> MbElementConverter::DataImageType ImageType3D; <br>
</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">typedef</font></font><font size="2"> MbElementConverter::DataImageType FixedImageType;<br>
</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">typedef</font></font><font size="2"> MbElementConverter::DataImageType MovingImageType;<br>
</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">typedef</font></font><font size="2"> itk::ImageFileWriter< ImageType3D > WriterType3D;<br>
</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">typedef</font></font><font size="2"> itk::ImageSeriesWriter<ImageType3D, ImageType2D > SeriesWriterType;<br>
</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">typedef</font></font><font size="2"> itk::ImageSeriesReader< ImageType3D > ReaderType3D;<br></font><font size="2">
</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">typedef</font></font><font size="2"> OrientImageFilter<ImageType3D,ImageType3D> ImageOrienter;<br></font><font size="2">
</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">typedef</font></font><font size="2"> itk::GDCMImageIO GDCMImageIOType;<br>
</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">typedef</font></font><font size="2"> itk::GDCMSeriesFileNames NamesGeneratorType;<br>
</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">typedef</font></font><font size="2"> itk::NumericSeriesFileNames NamesGeneratorType2;<br>
</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">typedef</font></font><font size="2"> std::vector< std::string > SeriesIdContainer;<br>
</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">typedef</font></font><font size="2"> std::vector< std::string > FileNamesContainer;<br>
</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">typedef</font></font><font size="2"> OrientImageFilter<ImageType3D,ImageType3D> tOrienter;</font><br>
<font size="2">..........<br>
</font> </font><br>
<br>
<br>
<font color="#000000">void MbDifference::writeImageDICOM(char* outputDirectory, ImageType3D::Pointer inputImage)</font><br>
<font color="#000000">{</font><br>
<font color="#000000"> itksys::SystemTools::MakeDirectory(outputDirectory);</font><br>
<font color="#000000"> GDCMImageIOType::Pointer gdcmIO = GDCMImageIOType::New();</font><br>
<font color="#000000"> SeriesWriterType::Pointer seriesWriter = SeriesWriterType::New();</font><br>
<font color="#000000"> NamesGeneratorType2::Pointer nameGenerator = NamesGeneratorType2::New();</font><br>
<font color="#000000"> FileNamesContainer fileNames;</font><br>
<font color="#000000"> std::string format = outputDirectory;</font><br>
<font color="#000000"> format += "/%08d";</font><br>
<font color="#000000"> // format += "dicom"; // filename extension</font><br>
<font color="#000000"> nameGenerator->SetSeriesFormat( format.c_str() );</font><br>
<font color="#000000"> ImageType3D::RegionType region = inputImage->GetLargestPossibleRegion();</font><br>
<font color="#000000"> ImageType3D::IndexType start = region.GetIndex(); </font><br>
<font color="#000000"> ImageType3D::SizeType size = region.GetSize(); </font><br>
<font color="#000000"> const unsigned int firstSlice = start[2];</font><br>
<font color="#000000"> const unsigned int lastSlice = start[2] + size[2] - 1;</font><br>
<font color="#000000"> nameGenerator->SetStartIndex( firstSlice );</font><br>
<font color="#000000"> nameGenerator->SetEndIndex( lastSlice );</font><br>
<font color="#000000"> nameGenerator->SetIncrementIndex( 1 );</font><br>
<font color="#000000"> fileNames = nameGenerator->GetFileNames();</font><br>
<br>
<font color="#000000">seriesWriter->SetFileNames( nameGenerator->GetFileNames() );</font><br>
<font color="#000000"> seriesWriter->SetInput( inputImage );</font><br>
<font color="#000000"> gdcmIO->LoadPrivateTagsOn();</font><br>
<font color="#000000"> gdcmIO->GetLoadPrivateTags();</font><br>
<font color="#000000"> gdcmIO->KeepOriginalUIDOn();</font><br>
<font color="#000000"> seriesWriter->SetImageIO( gdcmIO );</font><br>
<font color="#000000"> // seriesWriter->SetMetaDataDictionaryArray(reader->GetMetaDataDictionaryArray());</font><br>
<font color="#000000"> try</font><br>
<font color="#000000"> {</font><br>
<font color="#000000"> seriesWriter->Update();</font><br>
<font color="#000000"> }</font><br>
<font color="#000000"> catch( itk::ExceptionObject & excp )</font><br>
<font color="#000000"> {</font><br>
<font color="#000000"> std::cerr << "Exception thrown while writing the series " << std::endl;</font><br>
<font color="#000000"> </font><br>
<font color="#000000"> std::cerr << excp << std::endl;</font><br>
<font color="#000000"> }</font><br>
<font color="#000000">}</font><br></font></font>                                            <br><hr>Importa i tuoi contatti di Facebook. <a href="http://www.windowslive.it/importaAmici.aspx" target="_blank">Chiacchiera su Messenger!</a></div>
<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.html" target="_blank">http://www.kitware.com/products/protraining.html</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://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br>