[Insight-users] DICOM and Nrrd registration
Guilhem Chéron
ptitguigui at aliceadsl.fr
Sun Dec 30 11:33:15 EST 2012
Hi,I'm trying to register one set of DICOM and one Nrrd file.I’ve used the exemple : ImageRegistration8, which use “mha” files.I just want to replace the two mha files by my DICOM serie and my nrrd file.So I replace this part of code :typedef itk::ImageFileReader< FixedImageType > FixedImageReaderType;
typedef itk::ImageFileReader< MovingImageType > MovingImageReaderType;
FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New();
MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New();
fixedImageReader->SetFileName( argv[1] );
movingImageReader->SetFileName( argv[2] );
registration->SetFixedImage( fixedImageReader->GetOutput() );
registration->SetMovingImage( movingImageReader->GetOutput() );
fixedImageReader->Update();
registration->SetFixedImageRegion(
fixedImageReader->GetOutput()->GetBufferedRegion() );
By this (loading) part : typedef itk::ImageSeriesReader< FixedImageType > FixedImageReaderType;
typedef itk::ImageFileReader< MovingImageType > MovingImageReaderType;
FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New();
MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New();
/* fixedImageReader->SetFileName( argv[1] );
movingImageReader->SetFileName( argv[2] );*/
registration->SetFixedImage( fixedImageReader->GetOutput() );
registration->SetMovingImage( movingImageReader->GetOutput() );
// lecture première image (DICOM)
std::cout << "Le fichier " << argv[1] << " est une serie de DICOM " << std::endl;
typedef itk::GDCMImageIO ImageIOType; // une image DICOM
typedef itk::GDCMSeriesFileNames InputNamesGeneratorType;
// DICOM LOADING
ImageIOType::Pointer gdcmIO = ImageIOType::New();
// on crée le générateur de noms de fichier
InputNamesGeneratorType::Pointer namesGenerator = InputNamesGeneratorType::New();
// on indique au générateur de nom le dossier d'entrée
namesGenerator->SetInputDirectory( argv[1] );
// on récupère à présent la liste des fichiers à lire
const FixedImageReaderType::FileNamesContainer & filenames =
namesGenerator->GetInputFileNames();
// on lui indique que ce sont des DICOM
fixedImageReader->SetImageIO( gdcmIO );
// on lui fournit la liste des fichiers à charger
fixedImageReader->SetFileNames( filenames );
try
{// on lance le processus de lecture
fixedImageReader->Update();
}
catch (itk::ExceptionObject &excp)
{
std::cerr << "Exception thrown while reading the series" << std::endl;
std::cerr << excp << std::endl;
}
std::cout << "The input series in directory " << argv[1]
<< " has " << fixedImageReader->GetFileNames().size() << " files "
<< " of size " << fixedImageReader->GetOutput()->GetBufferedRegion().GetSize()
<< std::endl;
// lecture deuxieme image (nrrd)
typedef itk::NrrdImageIO nrrdType; // une image nrrd
std::cout << "Le fichier " << argv[2] << " est un nrrd" << std::endl;
// nrrd LOADING
nrrdType::Pointer nrrdIO = nrrdType::New();
// on lui indique que ce sont des nrrd
movingImageReader->SetImageIO( nrrdIO );
// on lui fournit la liste des fichiers à charger
movingImageReader->SetFileName( argv[2] );
try
{// on lance le processus de lecture
movingImageReader->Update();
}
catch (itk::ExceptionObject &excp)
{
std::cerr << "Exception thrown while reading the series" << std::endl;
std::cerr << excp << std::endl;
}
fixedImageReader->Update();
registration->SetFixedImageRegion(
fixedImageReader->GetOutput()->GetBufferedRegion() );
//////////////////////////// end of loading
when I use these loading I had a bad alloc error at calling “update()” methode of the registration...
when I try to register the nrrd on the other same nrrd, I’ve no problem : the soft do one iteration and stop with error = 0.
So the problem seem to come from the DICOM...
I join you my code,
Regards,
Guilhem
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20121230/4371cfb9/attachment.htm>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: main.cpp
URL: <http://www.itk.org/pipermail/insight-users/attachments/20121230/4371cfb9/attachment.asc>
More information about the Insight-users
mailing list