[Insight-users] WrapITK issues and article review

Dan Mueller d.mueller at qut.edu.au
Tue Jul 11 01:19:06 EDT 2006


Hi Geatan,

I am in the process of reviewing your Insight Journal article "WrapITK".

While compiling and installing WrapITK I have come across a number of 
issues. For your information my system details are as follows:

    * Operating System=Windows XP SP2
    * CMake=CMake 2.4.2
    * Compiler=Microsoft.NET 2003 (7.1.3088)
    * ITK=InsightToolkit-2.8.1
    * CableSwig=CVS checkout on 10th July 2006, 9:30AM (GMT+10:00)
    * WrapITK=Nightly archive from
      http://voxel.jouy.inra.fr/darcs/contrib-itk/WrapITK/WrapITK.tar.gz
      downloaded on 10th July 2006, 8:45AM (GMT+10:00)
    * Python=Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32
      bit (Intel)] on win32


*1. Error accessing __FUNCSIG__:*
For some reason while compiling _IOPython I received the following error:
In file included from 
C:/Dan/Tools/ITK/src/WrapITK/Modules/IO/wrap_ITKIOBase.cxx:64:
C:/Dan/Tools/ITK/src/InsightToolkit-2.8.1/Code/IO/itkGDCMSeriesFileNames.h: 
In
   member function `void itk::GDCMSeriesFileNames::SetInputDirectory(const
   char*)':
C:/Dan/Tools/ITK/src/InsightToolkit-2.8.1/Code/IO/itkGDCMSeriesFileNames.h:73: 
error: `
   __FUNCSIG__' undeclared (first use this function)
C:/Dan/Tools/ITK/src/InsightToolkit-2.8.1/Code/IO/itkGDCMSeriesFileNames.h:73: 
error: (Each
   undeclared identifier is reported only once for each function it appears
   in.)
Project : error PRJ0019: A tool returned an error code from "Generating 
wrap_ITKIOBase.xml"

When I comment out the offending line, the project compiles fine:
/** Set the directory that contains the DICOM series. */
void SetInputDirectory (const char * name)
{
if( !name )
  {
  itkExceptionMacro(<<"SetInputDirectory() received a NULL string"); 
//<<< commenting this fixes it
  }
std::string fname = name;
this->SetInputDirectory( fname );
}

Note that itkExceptionMacro expands based on itkMacro.h:
#define itkExceptionMacro(x) \
  { \
  ::itk::OStringStream message; \
  message << "itk::ERROR: " << this->GetNameOfClass() \
          << "(" << this << "): " x; \
  ::itk::ExceptionObject e_(__FILE__, __LINE__, 
message.str().c_str(),ITK_LOCATION); \
  throw e_; /* Explicit naming to work around Intel compiler bug.  */ \
  }

and ITK_LOCATION is expanded based on itkMacro.h:
#if defined(ITK_CPP_FUNCTION)
  #if defined(__BORLANDC__)
    #define ITK_LOCATION __FUNC__
  #elif defined(_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
    #define ITK_LOCATION __FUNCSIG__ // <<< this line is obviously being 
used by the macro
  #elif defined(__GNUC__)
    #define ITK_LOCATION __PRETTY_FUNCTION__
  #else
    #define ITK_LOCATION __FUNCTION__
  #endif
#else
  #define ITK_LOCATION "unknown"
#endif

This error is quite interesting (ie. baffling) because I can compile 
other ITK code containing __FUNCSIG__ just fine. I don't understand why 
the __FUNCSIG__ macro is not recognised in this instance. Any 
thoughts/ideas/help?? I don't envisage needing to use 
itk::GDCMSeriesFileNames so it is not a major issue for me.

*2. Object file format limit exceeded:*
During my first attempt to configure/compile WrapITK I used the default 
settings, EXCEPT that I set WRAP_unsigned_short=ON.

Doing this caused the follow error during compilation of _BasePython:
c:\dan\tools\itk\src\insighttoolkit-2.8.1\code\common\itksmartpointer.h(55) 
: fatal error C1128: object file format limit exceeded : more than 
65,279 sections

The Microsoft documentation says the following about C1128:
An .obj file exceeded the number of allowable sections, a COFF object 
file format limitation.
Reaching this section limitation can be the result of using /Gy and a 
debug build; /Gy causes functions to go into their own COMDAT sections. 
In a debug build, there is a debug info section for each COMDAT function.
C1128 can also be caused when there are too many inline functions.
To correct this error, divide your source file into multiple source code 
files.

I reset the project to use the default CMake settings (ie. 
WRAP_unsigned_short=OFF) and this error went away. Perhaps when wrapping 
with lots of types (eg. default types + 1) I am reaching the object file 
limitations?? Maybe breaking _BasePython into 2 or more projects would 
solve the issue (if possible)?

*3. **Ambiguous call to overloaded function 'sqrt':*
While compiling _DistanceMapPython I encountered the following error:
wrap_itkSignedMaurerDistanceMapImageFilterPython.cxx
c:\Dan\Tools\ITK\src\InsightToolkit-2.8.1\Code\BasicFilters\itkSignedMaurerDistanceMapImageFilter.txx(241) 
: error C2668: 'sqrt' : ambiguous call to overloaded function
        C:\Program Files\Microsoft Visual Studio .NET 
2003\Vc7\include\math.h(626): could be 'long double sqrt(long double)'
        C:\Program Files\Microsoft Visual Studio .NET 
2003\Vc7\include\math.h(578): or       'float sqrt(float)'
        C:\Program Files\Microsoft Visual Studio .NET 
2003\Vc7\include\math.h(200): or       'double sqrt(double)'
        while trying to match the argument list '(unsigned short)'
        C:\Program Files\Microsoft Visual Studio .NET 
2003\Vc7\include\xmemory(156) : while compiling class-template member 
function 'void 
itk::SignedMaurerDistanceMapImageFilter<TInputImage,TOutputImage>::GenerateData(void)'
        with
        [
            TInputImage=itk::Image<short,3>,
            TOutputImage=itk::Image<short,3>
        ]
        wrap_itkSignedMaurerDistanceMapImageFilterPython.cxx(10865) : 
see reference to class template instantiation 
'itk::SignedMaurerDistanceMapImageFilter<TInputImage,TOutputImage>' 
being compiled
        with
        [
            TInputImage=itk::Image<short,3>,
            TOutputImage=itk::Image<short,3>
        ]

I fixed this by editing itkSignedMaurerDistanceMapImageFilter.txx to 
explicitly casting to double before the call to sqrt.

*4. C**annot access protected member **EnlargeOutputRequestedRegion:*
While compiling _SegmentationAndThresholdPython I encountered the 
following error:
wrap_itkScalarConnectedComponentImageFilterPython.cxx(11151) : error 
C2248: 
'itk::ConnectedComponentImageFilter<TInputImage,TOutputImage,TMaskImage>::EnlargeOutputRequestedRegion' 
: cannot access protected member declared in class 
'itk::ConnectedComponentImageFilter<TInputImage,TOutputImage,TMaskImage>'
        with
        [
            TInputImage=itk::Image<short,2>,
            TOutputImage=itk::Image<short,2>,
            TMaskImage=itk::Image<short,2>
        ]
        and
        [
            TInputImage=itk::Image<short,2>,
            TOutputImage=itk::Image<short,2>,
            TMaskImage=itk::Image<short,2>
        ]
        
c:\Dan\Tools\ITK\src\InsightToolkit-2.8.1\Code\BasicFilters\itkConnectedComponentImageFilter.h(149) 
: see declaration of 
'itk::ConnectedComponentImageFilter<TInputImage,TOutputImage,TMaskImage>::EnlargeOutputRequestedRegion'
        with
        [
            TInputImage=itk::Image<short,2>,
            TOutputImage=itk::Image<short,2>,
            TMaskImage=itk::Image<short,2>
        ]

To temporarily fix this and continue with the compile I renamed 
wrap_itkScalarConnectedComponentImageFilter.cmake to ensure it was not 
included. After re-configuring with CMake this project compiled correctly.

*5. Python installation:*
When I install WrapITK (ie. build the INSTALL project) it copies the 
created files to the CMAKE_INSTALL_PREFIX / WRAP_ITK_INSTALL_PREFIX 
folder (in my case C:/Program 
Files/WrapITK/lib/InsightToolkit/WrapITK/Python).

However, the Python site-packages WrapITK.pth file does not contain the 
correct paths for usage. The generated WrapITK.pth file is:
# Python pth file to add WrapITK's path to sys.path.
C:/Program Files/WrapITK//lib/InsightToolkit/WrapITK/Python
which does not allow Python access to all the files. I manually changed 
WrapITK.pth to:
# Python pth file to add WrapITK's path to sys.path.
C:/Program Files/WrapITK/lib/InsightToolkit/WrapITK/Python
C:/Program Files/WrapITK/lib/InsightToolkit/WrapITK/lib
to make it work correctly.

Also, the SwigRuntimePython.dll file is copied to the C:/Program 
Files/WrapITK/bin folder and is not accessible to Python. I had to 
manually copy this file to C:/Program 
Files/WrapITK/lib/InsightToolkit/WrapITK/Python to ensure Python finds it.

Finally, some required Python files (itk.py, itkBase.py, itkTemplate.py, 
itktesting.py, and itkTypes.py) were not copied to the installation 
folder. I manually copied these in order for Python to automatically 
detect WrapITK.

*6. String formatting:*
It seems the formatting for the itkExtras function auto_progress(bool) 
is not correct. I'm not a Python guru, so perhaps it's something at my 
end? The follow results don't look very nice to me:
 >>> imagetype = itk.Image[itk.UC, 2]
 >>> reader = 
itk.ImageFileReader[imagetype].New(FileName="c:/temp/input.png")
 >>> itk.auto_progress(True)
 >>> filter = itk.GradientMagnitudeImageFilter[imagetype, 
imagetype].New(Input=reader.GetOutput())
 >>> filter.Update()
 ?[2000D?[KitkGradientMagnitudeImageFilterIUC2IUC2: 0.000000 
?[2000D?[KitkGradie
ntMagnitudeImageFilterIUC2IUC2: 0.009979 
?[2000D?[KitkGradientMagnitudeImageFilt
erIUC2IUC2: 0.019958 ?[2000D?[KitkGradientMagnitudeImageFilterIUC2IUC2: 
0.029938
 ?[2000D?[KitkGradientMagnitudeImageFilterIUC2IUC2: 0.039917 
?[2000D?[KitkGradie
ntMagnitudeImageFilterIUC2IUC2: 0.049896 
?[2000D?[KitkGradientMagnitudeImageFilt
erIUC2IUC2: 0.059875 ?[2000D?[KitkGradientMagnitudeImageFilterIUC2IUC2: 
0.069855
 ?[2000D?[KitkGradientMagnitudeImageFilterIUC2IUC2: 0.079834 
?[2000D?[KitkGradie
...

Also, the output of the below example is not correct:
 >>> print itk.size(reader)
ÓýB?e [256, 256]>

The above example should be:
 >>> print itk.size(reader)
<Size [256, 256]>

Perhaps I have the wrong string encoding specified? Or perhaps print 
does not work on Python win32? Any thoughts/help?


Geatan, please feel free to contact me if you require any further 
clarification on the issues described above.

Besides these minor issues, WrapITK is fantastic - thanks for the nice 
addition to ITK! I'll be posting my review to the article soon.

Cheers

Dan Mueller
PhD Student
Queensland University of Technology (QUT)
Brisbane, Australia
CRICOS No: 00213J
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20060711/73be34ba/attachment-0001.htm


More information about the Insight-users mailing list