[Insight-users] difficulty to converter image to DICOM series

Roberta Beneduce bluangel_br at hotmail.it
Thu Jun 24 05:59:18 EDT 2010



Hi, 

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.

I'm waiting for useful informations.

Thank you for availability.

(I'm sorry for my english and for my computer science knowledge).

 

#define DataType unsigned short 

 

class MbElementConverter 

{ 

public: 

//Itk Input Image

typedef Image <DataType , 3 > DataImageType;

.........

 

class MbDifference : public MbProgrammableAlgo

{

protected:

typedef unsigned short PixelType;

typedef itk::Image< PixelType, Dimension2 > ImageType2D;

typedef itk::Image< float, Dimension3 > ImageType3DF;

typedef MbElementConverter::DataImageType ImageType3D; 

typedef MbElementConverter::DataImageType FixedImageType;

typedef MbElementConverter::DataImageType MovingImageType;

typedef itk::ImageFileWriter< ImageType3D > WriterType3D;

typedef itk::ImageSeriesWriter<ImageType3D, ImageType2D > SeriesWriterType;

typedef itk::ImageSeriesReader< ImageType3D > ReaderType3D;

typedef OrientImageFilter<ImageType3D,ImageType3D> ImageOrienter;

typedef itk::GDCMImageIO GDCMImageIOType;

typedef itk::GDCMSeriesFileNames NamesGeneratorType;

typedef itk::NumericSeriesFileNames NamesGeneratorType2;

typedef std::vector< std::string > SeriesIdContainer;

typedef std::vector< std::string > FileNamesContainer;

typedef OrientImageFilter<ImageType3D,ImageType3D> tOrienter;

..........

 

 

 

void MbDifference::writeImageDICOM(char* outputDirectory, ImageType3D::Pointer inputImage)

{

 itksys::SystemTools::MakeDirectory(outputDirectory);

 GDCMImageIOType::Pointer gdcmIO = GDCMImageIOType::New();

 SeriesWriterType::Pointer seriesWriter = SeriesWriterType::New();

 NamesGeneratorType2::Pointer nameGenerator = NamesGeneratorType2::New();

 FileNamesContainer fileNames;

 std::string format = outputDirectory;

 format += "/%08d";

 // format += "dicom"; // filename extension

 nameGenerator->SetSeriesFormat( format.c_str() );

 ImageType3D::RegionType region = inputImage->GetLargestPossibleRegion();

 ImageType3D::IndexType start = region.GetIndex(); 

 ImageType3D::SizeType size = region.GetSize(); 

 const unsigned int firstSlice = start[2];

 const unsigned int lastSlice = start[2] + size[2] - 1;

 nameGenerator->SetStartIndex( firstSlice );

 nameGenerator->SetEndIndex( lastSlice );

 nameGenerator->SetIncrementIndex( 1 );

 fileNames = nameGenerator->GetFileNames();

 

 seriesWriter->SetFileNames( nameGenerator->GetFileNames() );

 seriesWriter->SetInput( inputImage );

 gdcmIO->LoadPrivateTagsOn();

 gdcmIO->GetLoadPrivateTags();

 gdcmIO->KeepOriginalUIDOn();

 seriesWriter->SetImageIO( gdcmIO );

 // seriesWriter->SetMetaDataDictionaryArray(reader->GetMetaDataDictionaryArray());

 try

 {

 seriesWriter->Update();

 }

 catch( itk::ExceptionObject & excp )

 {

 std::cerr << "Exception thrown while writing the series " << std::endl;

 

 std::cerr << excp << std::endl;

 }

}
 		 	   		  
_________________________________________________________________
Tanti account di posta? Unisci tutto sotto Hotmail
http://www.windowslive.it/hotmail/GestisciAltriAccount.aspx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100624/ce095420/attachment-0001.htm>


More information about the Insight-users mailing list