[Insight-users] Reading DICOM image ( Debug Assertion Failed!)
Antonio Gómez Barquero
agb1 at alu.upct.es
Fri Nov 25 08:48:18 EST 2011
Hi to all ITK users!,
I want to read a Series of DICOM image to convert them into a 3D image.
I follow the example in the documentation: "
Examples/IO/DicomSeriesReadImageWrite2.cxx" .
I get the following error in debug mode while execution:
" Debug Assertion Failed ! . Vector Iterator not derefencable"
The code is the below ( I also send the files attached to the e-mail for
easy checking), first the header:
#ifndef Reg_mono3D_H
#define Reg_mono3D_H
// Antonio Gómez Barquero ( GTTS-UPCT)
// @: agb1 at alu.upct.es
// 25/11/2011
// reg mono 3D header
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include "math.h"
#include "itkImage.h"
#include "fftw3.h"
// for reading DICOM IMAGES
#include "itkGDCMImageIO.h"
#include "itkGDCMSeriesFileNames.h"
#include "itkImageSeriesReader.h"
#include "itkImageFileWriter.h"
using namespace std;
class Reg_mono_3D
{
// Variables
public:
typedef double PixelType;
typedef itk::Image< PixelType, 3 > ImageType; // 3D image
// Instancia el tipo del lector de series
typedef itk::ImageSeriesReader< ImageType > ReaderType;
typedef itk::GDCMImageIO ImageIOType; // para el funcionamiento
interno del formato DICOM
typedef itk::GDCMSeriesFileNames NamesGeneratorType; //for using
additional DICOM information to distinguish unique volumes
//within the directory
typedef std::vector< std::string > SeriesIdContainer; // para los
ID-SERIES de las imagenes DICOM
typedef std::vector< std::string > FileNamesContainer; // para los
nombres de los archivos asociados a las series de imagenes
Reg_mono_3D::Reg_mono_3D(); // Constructor
~Reg_mono_3D(void); // Destructor
void ejecuta_programa();
};
#endif //
And the 'cpp' file :
#include "Reg_mono_3D.h"
#include <iostream>
#include <limits>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "fftw3.h"
#include "math.h"
// Antonio Gómez Barquero ( GTTS-UPCT)
// @: agb1 at alu.upct.es
// 25/11/2011
// reg mono 3D
using namespace std;
#define PI 3.14159265
Reg_mono_3D::Reg_mono_3D()
{
}
Reg_mono_3D::~Reg_mono_3D(void)
{
}
int main()
{
cout<<" REGISTRO MONOMODAL EN 3D [GTTS-UPCT]"<<endl;
Reg_mono_3D reg;
reg.ejecuta_programa();
}
void Reg_mono_3D::ejecuta_programa(){
// Reading a 2D DICOM Series and Writing a Volume -- HACER UN MÉTODO
CUANDO FUNCIONE
ReaderType::Pointer reader = ReaderType::New();
ImageIOType::Pointer dicomIO = ImageIOType::New(); //This object is
the one that is aware of the internal intricacies of the DICOM format.
reader->SetImageIO( dicomIO );
NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();
nameGenerator->SetUseSeriesDetails( true );
nameGenerator->SetDirectory( "C:\\Documents and Settings\\GTTS\\Mis
documentos\\Visual Studio
2008\\Projects\\Reg_mono3D\\Reg_mono3D\\DICOM_SERIES\\T\\");
//The GDCMSeriesFileNames object first identifies the list of DICOM
series that are present in
//the given directory. We receive that list in a reference to a
container of strings
const SeriesIdContainer & seriesUID = nameGenerator->GetSeriesUIDs();
SeriesIdContainer::const_iterator seriesItr = seriesUID.begin();
SeriesIdContainer::const_iterator seriesEnd = seriesUID.end();
while( seriesItr != seriesEnd )
{
std::cout << seriesItr->c_str() << std::endl;
seriesItr++;
}
std::string seriesIdentifier;
seriesIdentifier = seriesUID.begin()->c_str();
//We pass the series identifier to the name generator and ask for all
the filenames associated to
//that series. This list is returned in a container of strings by the
GetFileNames() method
FileNamesContainer fileNames;
fileNames = nameGenerator->GetFileNames( seriesIdentifier );
reader->SetFileNames( fileNames );
try
{
reader->Update();
}
catch (itk::ExceptionObject &ex)
{
cout << ex << std::endl;
}
} //fin ejecuta programa
Thanks for the help!!!
Antonio Gómez Barquero
Ingeniero de Telecomunicaciones -Becario Investigador asociado a Actividades
de I+D+I
GTTS ( Grupo de Tratamiento y Teoría de la Señal)[ <http://gtts.upct.es/>
http://gtts.upct.es/]
UPCT (Universidad Politécnica de Cartagena)[ <http://www.upct.es/>
http://www.upct.es/]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20111125/1f3ef976/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Reg_mono_3D.h
Type: application/octet-stream
Size: 2269 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20111125/1f3ef976/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Reg_mono3D.cpp
Type: application/octet-stream
Size: 3039 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20111125/1f3ef976/attachment-0001.obj>
More information about the Insight-users
mailing list