[Insight-users] Is it silly to attempt this ?

Luis Ibanez luis.ibanez at kitware.com
Sun Mar 9 23:06:24 EDT 2008


Hi Emma,

Thanks a lot for uploading your deformation field.

The VTK file of this deformation field has a problem
that might be indeed a bug in the itkVTKImageIO class.


Your .vtk file (created with ITK) has a header with
the line:

            VECTORS vectors float

This line should have been


           SCALARS scalars float 3



When I replace this line with a text editor (e.g. Vim),
your program runs fine, and it takes only 5 seconds on
a conventional machine.


This is a bug in ITK CVS, because the reading portion
of the itkVTKImageIO.cxx file doesn't have an "if"
case for "VECTORS", it only has the case for "SCALARS"
in line 286.


Please enter this as a bug in the MANTIS bug tracker.

     http://public.kitware.com/Bug/index.php


We will try to address it before cutting the release
of ITK 3.6.


    Thanks


        Luis



----------------
Emma Ryan wrote:
> Hi Luis,
> 
>   Thank you for your reply. I generated the VTK file using ITK itself, 
> i.e the deformation field is dumped to a .vtk extension from another 
> program.  So I am guessing that ITK can automatically read the extension 
> (.mha or ,mhd, or ,vtk ) from the command prompt and generate the 
> appropriate output file.
> 
> I then use this file as input to the program I sent you. Incidentially, 
> I cannot read this .vtk file in Paraview either.
> 
> I have uploaded the file. Its a 24MB file. It is called def.vtk
> 
> Emma
> 
> 
> ----- Original Message ----
> From: Luis Ibanez <luis.ibanez at kitware.com>
> To: Emma Ryan <eryanvtk at yahoo.com>
> Sent: Sunday, February 24, 2008 3:35:34 PM
> Subject: Re: [Insight-users] Is it silly to attempt this ?
> 
> 
> Hi Emma,
> 
> Could you please upload your VTK file to the following address:
> 
>     http://www.kitware.com/KitwareScripts/uploadfile.cgi
> 
> In the field "Intended for" please put my name.
> 
> 
> Please send me email when you have uploaded the file
> I'll take a look at the file to see if it is compatible
> with ITK.
> 
> 
>     Thanks
> 
> 
>         Luis
> 
> 
> ------------------
> Emma Ryan wrote:
>  > Hello Luis,
>  >
>  >  Thank you for your reply. My image is 256 x 256 x 32. I have 512Mb
>  > ram. No computer does not seem to swapping memory.
>  > I used .mha file instead of .vtk for the deformation field and it was
>  > quick and correct.
>  >
>  > So, does the warper not accept .vtk files ?  I tried to debug the code
>  > to see where the program  takes forever and it seemed to be in the
>  > ImageFilereader (deformation field type)
>  >
>  > The imageReader should expect a certain byte size and I am sure there
>  > are that  many bytes in the file, so I'm not sure what the problem is.
>  >
>  > Emma
>  >
>  >
>  > ----- Original Message ----
>  > From: Luis Ibanez <luis.ibanez at kitware.com 
> <mailto:luis.ibanez at kitware.com>>
>  > To: Emma Ryan <eryanvtk at yahoo.com <mailto:eryanvtk at yahoo.com>>
>  > Cc: insight-users at itk.org <mailto:insight-users at itk.org>
>  > Sent: Saturday, February 23, 2008 8:00:34 PM
>  > Subject: Re: [Insight-users] Is it silly to attempt this ?
>  >
>  >
>  >
>  > Hi Emma,
>  >
>  > The source code that you posted seems to be reasonable.
>  >
>  >
>  > However, a duration of 2 hours for warping an image
>  > sounds like an excesive time.
>  >
>  >
>  > 1) How big is your image ?
>  >      pixels along X
>  >      pixels along Y
>  >      pixels along Z
>  >
>  >
>  > 2) How much RAM do you have ?
>  >
>  >
>  > 3) Have you checked if your computer
>  >    is not swapping memory ?
>  >
>  >    (you can check this on Windows by looking
>  >    at the Task Manager, or in Linux by using
>  >    the top tool, or the system information tool.)
>  >
>  >
>  > Please let us know,
>  >
>  >
>  >  Thanks
>  >
>  >
>  >    Luis
>  >
>  >
>  > ----------------
>  > Emma Ryan wrote:
>  >  > Hi,
>  >  >
>  >  >  I am trying to read in a 3D deformationField.vtk file and apply it to
>  >  > a 3D image. To read the deformation field, I use ImageFileReader
>  >  > <deformafieldType>  and then connect the output of this to the warper.
>  >  >
>  >  > The code for this is available below.  It seems to take forever to 
> read
>  >  > the deformation field file.  Even after 2 hours, the reading is not
>  >  > complete. What is going on ?  Any clues ?
>  >  >
>  >  > Thanks,
>  >  > Emma
>  >  >
>  >  >
>  >  > #if defined(_MSC_VER)
>  >  > #pragma warning ( disable : 4786 )
>  >  > #endif
>  >  >
>  >  > #include "itkImageFileReader.h"
>  >  > #include "itkImageFileWriter.h"
>  >  >
>  >  > #include "itkImageRegionIterator.h"
>  >  >
>  >  >
>  >  > #include "itkCastImageFilter.h"
>  >  > #include "itkWarpImageFilter.h"
>  >  > #include "itkLinearInterpolateImageFunction.h"
>  >  >
>  >  > #include "itkSquaredDifferenceImageFilter.h"
>  >  > #include "itkCheckerBoardImageFilter.h"
>  >  > #include "itkTimeProbe.h"   
>  >  >
>  >  > #include "itkImageRegionIteratorWithIndex.h"
>  >  > #include "itkPointSet.h"
>  >  > #include <fstream>
>  >  >
>  >  >
>  >  >
>  >  > int main( int argc, char *argv[] )
>  >  > {
>  >  >    if( argc < 4 )
>  >  >    {
>  >  >        std::cerr << "Missing Parameters " << std::endl;
>  >  >        std::cerr << "Usage: " << argv[0];
>  >  >        std::cerr << " fixedImagefile movingImageFile 
> deformField.vtk ";
>  >  >        std::cerr << " outputImageFile " << std::endl;
>  >  >        return 1;
>  >  >    }
>  >  >
>  >  > 
>  >  >    const unsigned int Dimension = 3;
>  >  >    typedef unsigned char PixelType;
>  >  >
>  >  >
>  >  >    typedef itk::Image< PixelType, Dimension >  FixedImageType;
>  >  >    typedef itk::ImageFileReader< FixedImageType > 
> FixedImageReaderType;
>  >  >    FixedImageReaderType::Pointer fixedImageReader =
>  >  > FixedImageReaderType::New();
>  >  >    fixedImageReader->SetFileName( argv[1] );
>  >  >
>  >  > 
>  >  >    typedef itk::Image< PixelType, Dimension >  MovingImageType;
>  >  >    typedef itk::ImageFileReader< MovingImageType > 
> MovingImageReaderType;
>  >  >    MovingImageReaderType::Pointer movingImageReader =
>  >  > MovingImageReaderType::New();
>  >  >    movingImageReader->SetFileName( argv[2] );
>  >  >
>  >  >        typedef itk::Vector< float, Dimension >    VectorPixelType;
>  >  >    typedef itk::Image<  VectorPixelType, Dimension >
>  > DeformationFieldType;
>  >  >
>  >  >    typedef itk::ImageFileReader< DeformationFieldType >  
> FieldReaderType;
>  >  >    FieldReaderType::Pointer fieldReader = FieldReaderType::New();
>  >  >
>  >  >    fieldReader->SetFileName( argv[3] );
>  >  >
>  >  >
>  >  >    try {
>  >  >
>  >  >    fieldReader->Update();
>  >  >    }
>  >  >
>  >  >    catch ( itk::ExceptionObject & err )
>  >  >    {
>  >  >    std::cerr << "ExceptionObject caught !" << std::endl;
>  >  >    std::cerr << err << std::endl;
>  >  >    return -1;
>  >  >    }
>  >  >
>  >  >
>  >  > 
>  >  >    typedef itk::WarpImageFilter<MovingImageType,
>  >  > MovingImageType,DeformationFieldType  >    WarperType;
>  >  >    typedef itk::LinearInterpolateImageFunction<MovingImageType, 
> double
>  >  >  >  InterpolatorType;
>  >  >    WarperType::Pointer warper = WarperType::New();
>  >  >    InterpolatorType::Pointer interpolator = InterpolatorType::New();
>  >  >    FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput();
>  >  >
>  >  >
>  >  >    warper->SetInput( movingImageReader->GetOutput() );
>  >  >    warper->SetInterpolator( interpolator );
>  >  >    warper->SetOutputSpacing( fixedImage->GetSpacing() );
>  >  >    warper->SetOutputOrigin( fixedImage->GetOrigin() );
>  >  >
>  >  >    warper->SetDeformationField( fieldReader->GetOutput() );
>  >  >
>  >  >
>  >  >    typedef  unsigned char  OutputPixelType;
>  >  >    typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
>  >  >    typedef itk::CastImageFilter<
>  >  >        MovingImageType,
>  >  >        OutputImageType > CastFilterType;
>  >  >    typedef itk::ImageFileWriter< OutputImageType >  WriterType;
>  >  >
>  >  >
>  >  >    WriterType::Pointer      writer =  WriterType::New();
>  >  >    CastFilterType::Pointer  caster =  CastFilterType::New();
>  >  >
>  >  >    writer->SetFileName( argv[4] );
>  >  >
>  >  > 
>  >  >    caster->SetInput( warper->GetOutput() );
>  >  >    writer->SetInput( caster->GetOutput()  );
>  >  >    writer->Update();
>  >  >
>  >  >
>  >  >    return 0;
>  >  > }
>  >  >
>  >  >
>  >  >
>  >  > 
> ------------------------------------------------------------------------
>  >  > Looking for last minute shopping deals? Find them fast with Yahoo!
>  >  > Search.
>  >  >
>  > 
> <http://us.rd.yahoo.com/evt=51734/*http://tools.search.yahoo.com/newsearch/category.php?category=shopping>
>  >  >
>  >  >
>  >  > 
> ------------------------------------------------------------------------
>  >  >
>  >  > _______________________________________________
>  >  > Insight-users mailing list
>  >  > Insight-users at itk.org <mailto:Insight-users at itk.org> 
> <mailto:Insight-users at itk.org <mailto:Insight-users at itk.org>>
>  >  > http://www.itk.org/mailman/listinfo/insight-users
>  >
>  >
>  > ------------------------------------------------------------------------
>  > Looking for last minute shopping deals? Find them fast with Yahoo!
>  > Search.
>  > 
> <http://us.rd.yahoo.com/evt=51734/*http://tools.search.yahoo.com/newsearch/category.php?category=shopping>
> 
> 
> ------------------------------------------------------------------------
> Looking for last minute shopping deals? Find them fast with Yahoo! 
> Search. 
> <http://us.rd.yahoo.com/evt=51734/*http://tools.search.yahoo.com/newsearch/category.php?category=shopping>


More information about the Insight-users mailing list