<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
</style>
</head>
<body class='hmmessage'>
Hi all.<br><br>I've enabled the MINC2 IO review code and rebuilt ITK. Now I'd like to actually test this functionality, but am having trouble setting up the code and CMakeLists.txt necessary to do so.<br><br>I started with the basic ImageReadWrite example code, and modified it based on the results of various web searches. A seemingly helpful example is here:<br><br>http://en.wikibooks.org/wiki/MINC/Tutorials/part2<br><br>The result is this code:<br><br>My current code:<br>
<br>
*****************************************************<br>
<br>
#include "itkImageFileReader.h"<br>
#include "itkImageFileWriter.h"<br>
#include "itkImage.h"<br>
<br>
#include "itkImageIOFactory.h"<br>
#include "itkMINC2ImageIOFactory.h"<br>
#include "itkMINC2ImageIO.h"<br>
<br>
<br>
namespace {<br>
typedef float PixelType;<br>
const unsigned int Dimension = 3;<br>
typedef itk::Image<PixelType, Dimension> ImageType;<br>
<br>
typedef itk::ImageFileReader<ImageType> ReaderType;<br>
typedef itk::ImageFileWriter<ImageType> WriterType;<br>
<br>
typedef itk::MINC2ImageIO ImageIOType;<br>
}<br>
<br>
int main(int argc, char ** argv) {<br>
// Verify the number of parameters in the command line<br>
if ( argc < 3 ) {<br>
std::cerr << "Usage: " << std::endl;<br>
std::cerr << argv[0] << " inputImageFile outputImageFile " << std::endl;<br>
return EXIT_FAILURE;<br>
}<br>
<br>
ReaderType::Pointer reader = ReaderType::New();<br>
ImageIOType::Pointer minc2ImageIO = ImageIOType::New();<br>
reader->SetImageIO( minc2ImageIO );<br>
const char* inputFilename = argv[1];<br>
reader->SetFileName(inputFilename);<br>
<br>
<br>
WriterType::Pointer writer = WriterType::New();<br>
const char* outputFilename = argv[2];<br>
writer->SetFileName(outputFilename);<br>
<br>
<br>
writer->SetInput(reader->GetOutput());<br>
<br>
<br>
try { <br>
writer->Update(); <br>
} catch(itk::ExceptionObject & err) { <br>
std::cerr << "ExceptionObject caught !" << std::endl; <br>
std::cerr << err << std::endl; <br>
return EXIT_FAILURE;<br>
} <br>
<br>
return EXIT_SUCCESS;<br>
}<br>
<br>
******************************************************<br>
<br>I tried building this using my existing CMakeLists.txt that works for the same code without the minc-related parts...<br><br>******************************************************<br><br># This is the root ITK CMakeLists file.<br>CMAKE_MINIMUM_REQUIRED(VERSION 2.4)<br>IF(COMMAND CMAKE_POLICY)<br> CMAKE_POLICY(SET CMP0003 NEW)<br>ENDIF(COMMAND CMAKE_POLICY)<br><br><br># This project is designed to be built outside the Insight source tree.<br>PROJECT(IOExamples)<br><br># Find ITK.<br>FIND_PACKAGE(ITK REQUIRED)<br>INCLUDE(${ITK_USE_FILE})<br><br>ADD_EXECUTABLE(ImageReadWrite ImageReadWrite.cxx )<br>TARGET_LINK_LIBRARIES(ImageReadWrite ITKIO)<br><br>*******************************************************<br><br>After re-running ccmake and running make, I got errors about missing headers:<br><br>*******************************************************<br><br>/work/geoff/itk/iotest > make<br>[100%] Building CXX object CMakeFiles/ImageReadWrite.dir/ImageReadWrite.o<br>In file included from /work/geoff/itk/iotest/ImageReadWrite.cxx:8:<br>/work/geoff/InsightToolkit-3.12.0/Code/Review/itkMINC2ImageIO.h:37:19: minc2.h: No such file or directory<br>In file included from /work/geoff/itk/iotest/ImageReadWrite.cxx:8:<br>/work/geoff/InsightToolkit-3.12.0/Code/Review/itkMINC2ImageIO.h:100: error: `midimhandle_t' has not been declared<br>/work/geoff/InsightToolkit-3.12.0/Code/Review/itkMINC2ImageIO.h:100: error: ISO C++ forbids declaration of `hdims' with no type<br>/work/geoff/InsightToolkit-3.12.0/Code/Review/itkMINC2ImageIO.h:145: error: `mihandle_t' has not been declared<br>/work/geoff/InsightToolkit-3.12.0/Code/Review/itkMINC2ImageIO.h:145: error: ISO C++ forbids declaration of `volume' with no type<br>/work/geoff/InsightToolkit-3.12.0/Code/Review/itkMINC2ImageIO.h:149: error: `mihandle_t' has not been declared<br>/work/geoff/InsightToolkit-3.12.0/Code/Review/itkMINC2ImageIO.h:149: error: ISO C++ forbids declaration of `volume' with no type<br>make[2]: *** [CMakeFiles/ImageReadWrite.dir/ImageReadWrite.o] Error 1<br>make[1]: *** [CMakeFiles/ImageReadWrite.dir/all] Error 2<br>make: *** [all] Error 2<br>/work/geoff/itk/iotest > ccmake .<br><br>****************************************************<br><br>So I hit net searched a bit more, and found some promising looking alterations to the previous CMakeLists.txt, starting after the INCLUDE(${ITK_USE_FILE}) line:<br><br>****************************************************<br><br>FIND_PACKAGE(MINC2)<br>INCLUDE_DIRECTORIES(${MINC2_INCLUDE_PATH} ${HDF5_INCLUDE_PATH} ${NETCDF_INCLUDE_PATH})<br><br>ADD_EXECUTABLE(ImageReadWrite ImageReadWrite.cxx )<br>TARGET_LINK_LIBRARIES(ImageReadWrite ITKIO ITKIOMINC2 ${MINC2_LIB} ${HDF5_LIB} ${NETCDF_LIB})<br><br>*****************************************************<br><br>After doing this, when I run ccmake, I have an extra line where I need to enter the location of MINC2_DIR. I give it the same directory as I used to build ITK after turning on MINC and related options, but after pressing c to configure, I get an error message:<br><br>CMake Error: MINC2_DIR is set to "/opt/minc2", which is not a directory containing MINC2Config.cmake<br><br>I've searched for a file by that name in my ITK binary or code directories.<br><br>I also tried without the FIND_PACKAGE(MINC2) line, but just got the same missing headers error during compiling.<br><br>I don't know how else to point ccmake to the location of the minc2 headers. Can someone suggest what modifications need to be made to CMakeLists.txt so the compiler can find the necessary headers to build a program using the MINC ITK IO classes, or whatever else I need to be doing? Is this documented somewhere I haven't found?<br><br>Thanks,<br>Geoff Topping<br>
<br><br><br /><hr />Windows Live Messenger makes it easier to stay in touch - <a href='http://go.microsoft.com/?linkid=9650731' target='_new'>learn how!</a></body>
</html>