<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.&nbsp; 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.&nbsp; 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>
&nbsp;&nbsp;&nbsp; typedef float&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PixelType;<br>
&nbsp;&nbsp;&nbsp; const&nbsp;&nbsp; unsigned int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dimension = 3;<br>
&nbsp;&nbsp;&nbsp; typedef itk::Image&lt;PixelType, Dimension&gt;&nbsp;&nbsp;&nbsp; ImageType;<br>
<br>
&nbsp;&nbsp;&nbsp; typedef itk::ImageFileReader&lt;ImageType&gt;&nbsp;&nbsp;&nbsp;&nbsp; ReaderType;<br>
&nbsp;&nbsp;&nbsp; typedef itk::ImageFileWriter&lt;ImageType&gt;&nbsp;&nbsp;&nbsp;&nbsp; WriterType;<br>
<br>
&nbsp;&nbsp;&nbsp; typedef itk::MINC2ImageIO&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ImageIOType;<br>
}<br>
<br>
int main(int argc, char ** argv) {<br>
&nbsp;&nbsp;&nbsp; // Verify the number of parameters in the command line<br>
&nbsp;&nbsp;&nbsp; if ( argc &lt; 3 ) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; "Usage: " &lt;&lt; std::endl;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; argv[0] &lt;&lt; " inputImageFile outputImageFile " &lt;&lt; std::endl;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return EXIT_FAILURE;<br>
&nbsp;&nbsp;&nbsp; }<br>
<br>
&nbsp;&nbsp;&nbsp; ReaderType::Pointer reader = ReaderType::New();<br>
&nbsp;&nbsp;&nbsp; ImageIOType::Pointer minc2ImageIO = ImageIOType::New();<br>
&nbsp;&nbsp;&nbsp; reader-&gt;SetImageIO( minc2ImageIO );<br>
&nbsp;&nbsp;&nbsp; const char* inputFilename&nbsp; = argv[1];<br>
&nbsp;&nbsp;&nbsp; reader-&gt;SetFileName(inputFilename);<br>
<br>
<br>
&nbsp;&nbsp;&nbsp; WriterType::Pointer writer = WriterType::New();<br>
&nbsp;&nbsp;&nbsp; const char* outputFilename = argv[2];<br>
&nbsp;&nbsp;&nbsp; writer-&gt;SetFileName(outputFilename);<br>
<br>
<br>
&nbsp;&nbsp;&nbsp; writer-&gt;SetInput(reader-&gt;GetOutput());<br>
<br>
<br>
&nbsp;&nbsp;&nbsp; try { <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writer-&gt;Update(); <br>
&nbsp;&nbsp;&nbsp; } catch(itk::ExceptionObject &amp; err) { <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; "ExceptionObject caught !" &lt;&lt; std::endl; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; err &lt;&lt; std::endl; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return EXIT_FAILURE;<br>
&nbsp;&nbsp;&nbsp; } <br>
<br>
&nbsp;&nbsp;&nbsp; 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>&nbsp; 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&nbsp; 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 &gt; 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 &gt; 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.&nbsp; 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.&nbsp; 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?&nbsp; 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>