[Insight-users] Cannot debug projects of ITKApplication.

jimmy jimmy_lab at 163.com
Fri Jul 27 03:39:13 EDT 2007


Thank you for your reply.

I use the raw data from BrainWeb.
One data has two files: one is the head file, the other is the raw data.
What I now read by the itk::ImageFileReader is called:  brainweb165a10f17.mha

It includes:
NDims = 3
DimSize = 181 217 180
ElementType = MET_UCHAR
ElementSpacing = 1.0 1.0 1.0
ElementByteOrderMSB = False
ElementDataFile = brainweb165a10f17.raw

So
1) What is the extension of the filename    ->  mha
   that you are trying to read ?

2) Does the rest of the filename has any special characters ?     -> no

3) Could you please post to the list the content of the    -> like the above list
   MetaImage header  ?

With the help of ITK-snap, I can read the original data and the data written by itk::ImageFileWriter correctly.
Unfortunately, I did not receive any warning or error message when Linking.

------------------				 
jimmy
2007-07-27

-------------------------------------------------------------
发件人:Luis Ibanez
发送日期:2007-07-27 01:38:42
收件人:jimmy
抄送:insight-users
主题:Re: [Insight-users] Cannot debug projects of ITKApplication.

Hi Jimmy,


                Thanks a lot !


Your last email now really looks like a technical report.

We *really* appreciate when you describe the problem in a
clear manner.

---

From your nice description, the main suspect is the filename
that you are using. If the error disappears when you provide
the specific ImageIO class, that means that the factory
mechanism is not being able to figure out the fileformat.

1) What is the extension of the filename
   that you are trying to read ?

2) Does the rest of the filename has any special characters ?

3) Could you please post to the list the content of the
   MetaImage header  ?

   We want to see the values of number of pixels along
   each dimension, the dimension of the image, pixel
   spacing and so on.

[It is still unclear why this work on release... though...]

Have you verified that the image is read correctly ?
(e.g. not just the the program doesn't crash ?)

A good way is to take the image from the reader, pass it
to a writer and save it in a file. In that way we can be
certain that the image in Release mode is actually working
fine all the way down the pipeline.



BTW : Did you received *ANY* error or warning error messages
      at LINK time ?


  Thanks


     Luis


-----------------
jimmy wrote:
> Dear Mr Luis Ibanez:
>  
>         What I mean is that:  
>             I can build the project in both Debug mode and Release mode 
> successfully.   And the release version could be run correctly.
>         But in the Debug mode,  whatever I use F5 or F10, etc in the 
> debug tool,  the windows system will throw the error with a Error 
> Dilaogue including:  (at *itk::ImageFileReader* [reader]->Update(); )
>       
>           "Debug Assertion Failed!
>             Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
>           "
>  
>           And the call stack of the debugger in VS2003 shows that:
>           
>          itk::ImageIOFactory::CreateImageIO(const char * 
> path=0x0139d870, itk::ImageIOFactory::FileModeType 
> mode=ReadMode)  Line75 + 0x57
>          >      if((*k)->CanReadFile(path))
>          >     {
>          >         return *k;
>          >     }
>     
>         itk::ImageFileReader<itk::Image<unsigned 
> short,2>,itk::DefaultConvertPixelTraits<unsigned short> 
>  >::GenerateOutputInformation()  Line109 + 0x27
>         ITKCommon.dll!itk::ProcessObject::UpdateOutputInformation()  Line760
>         itk::ImageBase<2>::UpdateOutputInformation()  Line177 + 0x3e
>         ITKCommon.dll!itk::DataObject::Update()  Line343
>          
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> Here is the code what I use:
>  
> typedef   itk::Image<unsigned short,3>     InputImageType;
> typedef   itk::ImageFileReader< InputImageType >    FixedImageReaderType;
> FixedImageReaderType::Pointer          reader;
> reader               = FixedImageReaderType::New();
>  
> reader->SetFileName( filename );
>  
>  try
>  {
>       reader->Update();    *<- HERE:  Error occurs    ( why does it only 
> occur under the DEBUG mode,  however,  Release mode is okay? )*
>  }
>  catch(itk::ExceptionObject & err )
>  {
>   std::cout<< "ExceptionObject caught !" << std::endl;
>   std::cout<< err << std::endl;
>   std::cout<< "while reading fixed image"<<std::endl;
>  }
>       
> **BUT**
> *If I add three statements in the above code block.  The error 
> disappeared.    Like:*
>  
> typedef   itk::Image<unsigned short,3>     InputImageType;
> typedef   itk::ImageFileReader< InputImageType >    FixedImageReaderType;
> FixedImageReaderType::Pointer          reader;
> reader               = FixedImageReaderType::New();
>  
> reader->SetFileName( filename );
>  
> *itk::ImageIOBase::Pointer pio;
> pio = itk::MetaImageIO::New();
> reader->SetImageIO( pio );*
>  try
>  {
>       reader->Update();    *<- NO error HERE*
>  }
>  catch(itk::ExceptionObject & err )
>  {
>   std::cout<< "ExceptionObject caught !" << std::endl;
>   std::cout<< err << std::endl;
>   std::cout<< "while reading fixed image"<<std::endl;
>  }
>  
> Could you tell me the reason of that?
>  
> 
> Thank you very much indeed.
>    
> ------------------------------------------------------------------------
> jimmy
> 2007-07-26
> ------------------------------------------------------------------------
> *发件人:* Luis Ibanez
> *发送时间:* 2007-07-25 20:40:25
> *收件人:* jimmy
> *抄送:* insight-users
> *主题:* Re: Re: [Insight-users] Cannot debug projects of ITKApplication.
>  
> 
> Hi Jimmy,
> 
> 
> Can you please do the following:
> 
> 
> 1) In your binary version of ITK, run CMake again and Enable
> 
>                          BUILD_TESTING
>                          BUILD_EXAMPLES
> 
> 
> 2) Go to advanced mode (by selecting the check box on the top right)
>     and search down for the "SITE" variable. Make sure that it has the
>     correct name of your computer.
> 
> 
> 3) Click on the Configure button and then in the OK button.
> 
> 
> 4) Build ITK again, this time it will compile the 1,200 programs
>     of the testing suit. Make sure that you do this build for the
>    "Debug" compilation mode. The build could take 1 to 3
>    hours depending on the speed of your machine.
> 
> 
> 5) Once the build finishes, open a console window (MS_DOS or Cygwin)
>    and run the "ctest" command with the option  -D Experimental
> 
>     in most machines this will look like:
> 
>     C:\Program File\CMake 2.4\bin\ctest   -D Experimental  -C Debug
> 
> 
>    Make sure that you add the "-C Debug" at the end, so the testing
>    will be executed for the Debug compilation mode.
> 
>    This will trigger the execution of the testing framework and will send
>    the results to the public ITK Dashboard.
> 
> 
> 6) When the submission is complete, please let us know, so we
>     can take a look at the results of your submission in the Dashboard.
> 
> 
> This will let us know if you build is working correctly on Debug mode.
> 
> 
> BTW: When you say that you
> 
>                "cannot DEBUG in *ITKApplication*"
> 
> Do you mean that:
> 
>   1) you can't build in Debug mode an ITK application of your own ?
> 
>   2) you can't build in Debug mode InsightApplications ?
> 
>   3) you can build in Debug, but then when using F5, the applications
>       does not start ?
> 
>   4) Do you get any error messages ?
>       If so, please post to the list the *EXACT* error message that you 
> are getting. 
> 
> 
> 
> We will appreciate a more detailed and precise description of your problem.
> 
> 
> When you send emails to the mailing list, you should describe your
> problem as a list of step by step instructions  that will allow another
> person to replicate the problem that you are encountering.
> 
> 
> 
>       Thanks
> 
> 
>            Luis
> 
> 
> -----------------------------------------------------------------------------
> On 7/23/07, *jimmy* < jimmy_lab at 163.com <mailto:jimmy_lab at 163.com>> wrote:
> 
>     Hi, Luis:
> 
>             Thank you for your suggestion.
>             I am sorry that I have not describe my problem clearly.
>             I have already generate the MetaImage head (.mhd) beforehand.
>             And I used ImageFileReader correctly and access the data
>     successfully by my own codes.( It also could be debugged )
> 
>             However what confused me is that I cannot DEBUG in
>     *ITKApplication* as I mentioned before, but the RLEASE mode is okay.
>             Could you give me any other suggestion?
> 
>     Thank you very much indeed.
> 
>     Sincerely,
>     Jimmy
> 
>     ------------------
>     jimmy
>     2007-07-23
> 
>     -------------------------------------------------------------
>     发件人:Luis Ibanez
>     发送日期:2007-07-23 21:35:51
>     收件人:jimmy
>     抄送:insight-users
>     主题:Re: [Insight-users] Cannot debug projects of ITKApplication.
> 
> 
>     Hi Jimmy,
> 
>     You should have mentioned from the beginning that you
>     were attempting to read a RAW image file.
> 
> 
>             You *CANNOT* read a RAW image file
>             directly with the ImageFileReader.
> 
> 
> 
>     You have the following options:
> 
>       a) Create a MetaImage header for the RAW file.
>       b) Use explicitly the RAWImageIO class in your code.
> 
> 
>      From these two options, method (a) is the recommended one
>     because method (b) results in hard-coding the image
>     parameters in your program.
> 
> 
>     The easiest way of creating a MetaImage header for your
>     raw image is to use the program:
> 
> 
>        InsightApplications/MetaImageImporter
> 
> 
>     It is a command-line dialog that will guide you through
>     the process by asking you questions about your image.
> 
> 
>     The filename extension of your MetaImage header must be
>     ".mhd".
> 
>     Once you have created this header, you can pass it as
>     the filename to be read by the ImageFileReader.
> 
> 
>        Regards,
> 
> 
>           Luis
> 
> 
>     ============================
>     jimmy wrote:
>      > Here is an example of this problem:
>      >
>      > I use itk::ImageFileReader [reader] to read a Raw data.  After
>     the file name is set, and it runs to
>      > [reader]->Update();    Error occurs.
>      >
>      > The following is call stack of Debugger:
>      >
>      >       itk::ImageIOFactory::CreateImageIO(const char *
>     path=0x0139d870, itk::ImageIOFactory::FileModeType
>     mode=ReadMode)  Line75 + 0x57
>      >       if((*k)->CanReadFile(path))
>      >     {
>      >         return *k;
>      >     }
>      >
>      >       itk::ImageFileReader<itk::Image<unsigned
>     short,2>,itk::DefaultConvertPixelTraits<unsigned short>
>      >::GenerateOutputInformation()  Line109 + 0x27
>      >      
>     ITKCommon.dll!itk::ProcessObject::UpdateOutputInformation()  Line760
>      >       itk::ImageBase<2>::UpdateOutputInformation()  Line177 + 0x3e
>      >       ITKCommon.dll!itk::DataObject::Update()  Line343
>      >
>      >
>      > Thanks in advance.
>      > ------------------
>      > jimmy
>      > 2007-07-23
>      >
>      > -------------------------------------------------------------
>      > 发件人:Luis Ibanez
>      > 发送日期:2007-07-22 22:57:00
>      > 收件人:jimmy
>      > 抄送:insight-users
>      > 主题:Re: [Insight-users] Cannot debug projects of ITKApplication.
>      >
>      > Hi Jimmy,
>      >
>      > Can you look at the call stack in the debugger ?
>      >
>      > Could you trace what is the ITK file, and line
>      > that is triggering the error ?
>      >
>      > Please let us know,
>      >
>      >
>      >   Thanks
>      >
>      >
>      >     Luis
>      >
>      >
>      > ----------------
>      > jimmy wrote:
>      >
>      >>Hi, everyone.
>      >>
>      >>I have met a very strange problem when using ITKApplication:
>      >>I cannot debug or run Applications (e.g. ImageRegistration2D
>     ,IntensityBased2D3DRegistration ) under the DEBUG mode in VS 2003.
>      >>Here is the Error message:
>      >>"
>      >>Debug Assertion Failed!
>      >>Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
>      >>"
>      >>at [m_FixedImageReader or other object]->Update();
>      >>
>      >>On the contrary, the project can be run very smoothly under
>     RELEASE mode.
>      >>
>      >>Can anyone help me?  Thanks in advance.
>      >>
>      >>--------------
>      >>jimmy
>      >>2007-07-21
>      >>
>      >>
>      >>_______________________________________________
>      >>Insight-users mailing list
>      >>Insight-users at itk.org <mailto:Insight-users at itk.org>
>      >> http://www.itk.org/mailman/listinfo/insight-users
>      >>
>      >
>      >
> 
> 



More information about the Insight-users mailing list