Fw: [Insight-users] 3D Registration using my own data (.raw and .mha files)

Luis Ibanez luis.ibanez at kitware.com
Mon May 7 11:58:38 EDT 2007


Hi Lars,


1) Are we still talking about the ImageRegistration8.cxx example ?

2) If so, exchanging the fixed and moving images shouldn't result
    in a memory allocation problem.

3) Unless.... you are very close to the memory limit of your
    machine.


                 How much RAM do you have ?


4) The Image metrics allocate memory for a Gradient image, that
    has the size of the Moving image.  This gradient image has
    a large memory footprint.

    In your case, it seems that when you use the large image
    as the moving image, the memory allocation error happens.


5) One easy experiment is to keep using the Large image as the
    moving image, and to (temporarily) tamper with the MetaImae
    header to make it appear smaller.  E.g. declare that instead
    of having  245 slices, say that it has 200.

    At every modification, try to run the algorithm again. Do this
    until you find the image size that will allow the program to run.


    As you do this, you can check the memory consumption as reported
    by any system monitor program, such as the "Task Manager" in
    Windows, of ksysguard in Linux.



   Regards,


     Luis


--------------------
Lars Nygard wrote:
> Luis,
> 
> Thanks for the mail. I can view both images with ImageViewer and Im pretty
> sure that the MetaData is correct. Today I tried to change the fixed and moving
> images and to my wonder the program worked. Now Im setting the MRA image
> as fixed (DimSize = 512 512 245, ElementSpacing = 0.410156 0.410156 0.599998)
> and the MRT1 image as moving (DimSize = 256 256 180, 
> ElementSpacing = 1.000000 1.000000 1.000000).
> When I set the MRT1 image as fixed I get failed the allocate memory error.
> So now my question is, shouldn't the result be the same when interchanging the fixed
> and moving images? 
> regards,
> Lars Nyard
> 
> 
> ----- Original Message ----
> From: Luis Ibanez <luis.ibanez at kitware.com>
> To: Lars Nygard <lnygard at yahoo.com>
> Cc: Insight Users <insight-users at itk.org>
> Sent: Sunday, May 6, 2007 6:15:33 PM
> Subject: Re: Fw: [Insight-users] 3D Registration using my own data (.raw and .mha files)
> 
> 
> Hi Lars,
> 
> 
>   The ImageRegistration8.cxx example is using "float" as pixel type.
> 
> 
> Therefore, for the purpose of this code, it shouldn't matter whether
> your input images files are of pixel type "char" or of pixel type
> "unsigned short".
> 
> 
> The failure to allocate memory that you are experincing when using your
> own images is *NOT* due to the fact that they have different number of
> pixels along different dimensions.
> 
> 
> 
> The problem is most likely due to an incorrect metaimage header.
> Since you get the message:
> 
> 
>      > MetaImage: M_ReadElements: data not read completely
>      >    ideal = 14218274 : actual = 7109137
> 
> 
> It seems that your metaimage header is "promising" the image to be of
> pixel type "unsigned short", when it actually is of pixel type "char"
> 
> 
>     OR
> 
> 
> it may be that you are promising the image to have 128 slices when
> it actually has only 64 slices.
> 
> 
> 
> Just to clarify this again;
> 
>         *YOU DON'T NEED TO RESAMPLE THE IMAGES*
>         *BEFORE PERFORMING IMAGE REGISTRATION*
> 
> 
> 
> Please verify (and fix) the metaimage header of your images.
> 
> You can do this by simply using the ImageViewer. You can build
> the viewer from the code available in
> 
>             InsightApplications/ImageViewer
> 
> or, you can download a binary version for Windows from:
> 
> 
>     http://public.kitware.com/pub/itk/InsightApplicationsBin/
> 
> 
> forget about the registration, until you fix the header of your
> images. Make sure that you correct the MetaImage headers and
> that you can read the images with the ImageViewer and you can
> go through their slices and see a normal image.
> 
> 
> Once you have fixed the headers, you will be able to go back
> and test the registration again.
> 
> 
> 
> 
>      Regards,
> 
> 
> 
>          Luis
> 
> 
> 
> --------------------
> Lars Nygard wrote:
> 
>>Luis,
>>
>>Thanks for clearing that up. I managed to run ImageRegistration8 with some
>>other data and it works fine when images have same DimSize and Spacing.
>>However when I run the program with two images with different DimSize and
>>ElementType I get the following message:
>>
>>MetaImage: M_ReadElements: data not read completely
>>   ideal = 14218274 : actual = 7109137
>>
>>Is this because one image has ElementType short and the other unsigned char?
>>
>>And now what I don't understand is that when I run it with my own data I get a failed
>>to allocate memory message (see end of this message). Do you think this has
>>something to do with the size of the images( 125 MB for the MRA image and 23 MB
>>for the MRT1 image)??
>>I tried to resample the images because they have different DimSize and Spacing and
>>then the registration works but I don't think the results are good.
>>And as you said, the algorithm is supposed to work without first doing resampling.
>>regards,
>>Lars Nygard
>>
>>the error:
>>*************************************************
>>itk::ExceptionObject (0130F7A0)
>>Location: "class itk::CovariantVector<double,3> *__thiscall itk::ImportImageCont
>>ainer<unsigned long,class itk::CovariantVector<double,3> >::AllocateElements(uns
>>igned long) const"
>>File: c:\documents and settings\nygard\desktop\insight toolkit\source\insighttoo
>>lkit-3.2.0\code\common\itkImportImageContainer.txx
>>Line: 188
>>Description: Failed to allocate memory for image.
>>*************************************************************
>>
>>
>>----- Original Message ----
>>From: Luis Ibanez <luis.ibanez at kitware.com>
>>To: Lars Nygard <lnygard at yahoo.com>
>>Cc: Insight Users <insight-users at itk.org>
>>Sent: Thursday, May 3, 2007 7:46:15 PM
>>Subject: Re: Fw: [Insight-users] 3D Registration using my own data (.raw and .mha files)
>>
>>
>>Hi Lars,
>>
>>Thanks for sending the additional information of your images.
>>
>>They look Ok, for the most part...
>>
>>The spacing of the image N492_MRT1.mha looks very suspicious,
>>a spacing of 1x1x1 usually indicates that the real spacing was
>>not known and the values were filled up with some "innocuous"
>>choice.
>>
>>
>>Note that you *DO NOT* need to have the two images with the
>>same number of pixels. The ITK registration framework will
>>manage that correctly, as long as the origin, and spacing
>>values truly represent the physical reality of the data.
>>
>>So, there is no need for resampling the data before performing
>>the registration.
>>
>>
>>
>>     Regards,
>>
>>
>>
>>        Luis
>>
>>
>>
>>
>>--------------------
>>Lars Nygard wrote:
>>
>>
>>>Hi Luis,
>>>
>>>Thanks for you mails, they really cleared things up for me. I have
>>>the registration program working with the data on the website. However
>>>when I use my own data I still get the same error. I think I also have found
>>>the reason, theyre of different sizes (see header files) and elementspacing. 
>>>I just found out about this. Do you think that this is the problem? I probably 
>>>need to resample the image first so that both have the same dimensions.
>>>regards,
>>>Lars Nygard
>>>
>>>
>>>The header files for my own data are:
>>>
>>>N492_MRA.mha:
>>>
>>>NDims = 3
>>>DimSize = 512 512 245
>>>ElementType = MET_USHORT
>>>ElementSpacing = 0.410156 0.410156 0.599998
>>>ElementByteOrderMSB = True
>>>ElementDataFile = N492_MRA.raw
>>>-------------------------------------
>>>
>>>N492_MRT1.mha:
>>>
>>>NDims = 3
>>>DimSize = 256 256 180
>>>ElementType = MET_USHORT
>>>ElementSpacing = 1.000000 1.000000 1.000000
>>>ElementByteOrderMSB = True
>>>ElementDataFile = N492_MRT1.raw
>>>-----------------------------------------------------------
>>>----- Original Message ----
>>>From: Luis Ibanez <luis.ibanez at kitware.com>
>>>To: Lars Nygard <lnygard at yahoo.com>
>>>Cc: insight-users at itk.org
>>>Sent: Wednesday, May 2, 2007 12:57:55 AM
>>>Subject: Re: [Insight-users] 3D Registration using my own data (.raw and .mha files)
>>>Hi Lars,
>>>
>>>What is the size (in pixels) of the images:
>>>          1)  N492_MRT1.mha  ?
>>>          2)  N492_MRA.mha   ?
>>>
>>>Also, note that you are passing insufficient arguments to this
>>>program, and that two of the arguments that you are passing are
>>>PNG image filenames, where a format capable of storing 3D image
>>>is expected.
>>>
>>>       PNG can only store 2D images.
>>>
>>>The arguments that this program expects are:
>>>
>>>    1) Fixed image (in a 3D file format)
>>>    2) Moving image (in a 3D file format)
>>>    3) Filename for the output resampled
>>>       registered moving image (in a 3D file format)
>>>    3) Filename for the difference between
>>>       fixed image and moving image Before
>>>       registration (in a 3D file format)
>>>    4) Filename for the difference between
>>>       fixed image and moving image After
>>>       registration (in a 3D file format)
>>>    5) Filename for 1 slice of the difference
>>>       between fixed image and moving image
>>>       Before registration (in a 2D file format)
>>>    6) Filename for 1 slice of the difference
>>>       between fixed image and moving image
>>>       After registration (in a 2D file format)
>>>
>>>According to your email, you are missing the argument (3),
>>>and you are passing wrong file formats for (what should have
>>>been) arguments (4) and (5).
>>>A correct command line should look like:
>>>
>>>    ImageRegistration8
>>>      fixedImage.mhd
>>>      movingImage.mhd
>>>      registeredMovingImage.mhd
>>>      differenceBefore.mhd
>>>      differenceAfter.mhd
>>>      sliceDifferenceBefore.png
>>>      sliceDifferenceAfter.png
>>>
>>>Please read the description of this example in the
>>>ITK Software Guide:
>>>
>>>      http://www.itk.org/ItkSoftwareGuide.pdf
>>>in the "Image Registration" chapter.
>>>
>>>You will also find a list of the fileformats supported
>>>in ITK in the Chapter "Reading and Writing Images" in
>>>the ITK Software Guide.
>>>
>>>Regards,
>>>
>>>   Luis
>>>
>>>--------------------
>>>Lars Nygard wrote:
>>>
>>>
>>>
>>>>Hallo,
>>>>
>>>>Im trying to use example eight in the registration part (ImageRegistration8.cxx) to
>>>>register a 3D MR Angiography (moving) to an 3D MR T1 image (fixed).
>>>>When I run it i get an error message (see bottom). Is there anybody who can give me
>>>>a hint on what's happening. 
>>>>I haven't been able to run ImageRegistration8.cxx example with the normal data because
>>>>I can't connect to the ftp site ( ftp://public.kitware.com/pub/itk/Data/BrainWeb).
>>>>Does anybody know where I can download the files brainweb165a10f17.mha and
>>>>brainweb165a10f17Rot10Tx15.mha??
>>>>Ok thanks.
>>>>greets
>>>>Lars Nygard
>>>>
>>>>error message
>>>>------------------------------------------------------------------------------------------------------------------
>>>>C:\Documents and Settings\nygard\Desktop\Insight Toolkit\Examples\Registration\I
>>>>mageRegistration8\debug>ImageRegistration8 N492_MRT1.mha N492_MRA.mha diffbefore
>>>>.png deffafter.png slicebefore.png sliceafter.png
>>>>
>>>>ExceptionObject caught !
>>>>itk::ExceptionObject (0130F7A0)
>>>>Location: "class itk::CovariantVector<double,3> *__thiscall itk::ImportImageCont
>>>>ainer<unsigned long,class itk::CovariantVector<double,3> >::AllocateElements(uns
>>>>igned long) const"
>>>>File: c:\documents and settings\nygard\desktop\insight toolkit\source\insighttoo
>>>>lkit-3.2.0\code\common\itkImportImageContainer.txx
>>>>Line: 188
>>>>Description: Failed to allocate memory for image.
>>>>
>>>>
>>>>    
>>>>_________________________________________________________
>>>>Alt i én. Få Yahoo! Mail med adressekartotek, kalender og
>>>>notisblokk. http://no.mail.yahoo.com
>>>>_______________________________________________
>>>>Insight-users mailing list
>>>>Insight-users at itk.org
>>>>http://www.itk.org/mailman/listinfo/insight-users
>>>>
>>>
>>>
>>>
>>>----- Forwarded Message ----
>>>From: Luis Ibanez <luis.ibanez at kitware.com>
>>>To: Lars Nygard <lnygard at yahoo.com>
>>>Cc: insight-users at itk.org
>>>Sent: Wednesday, May 2, 2007 12:57:55 AM
>>>Subject: Re: [Insight-users] 3D Registration using my own data (.raw and .mha files)
>>>
>>>
>>>Hi Lars,
>>>
>>>
>>>What is the size (in pixels) of the images:
>>>
>>>          1)  N492_MRT1.mha  ?
>>>
>>>          2)  N492_MRA.mha   ?
>>>
>>>
>>>
>>>Also, note that you are passing insufficient arguments to this
>>>program, and that two of the arguments that you are passing are
>>>PNG image filenames, where a format capable of storing 3D image
>>>is expected.
>>>
>>>
>>>       PNG can only store 2D images.
>>>
>>>
>>>The arguments that this program expects are:
>>>
>>>
>>>    1) Fixed image (in a 3D file format)
>>>    2) Moving image (in a 3D file format)
>>>    3) Filename for the output resampled
>>>       registered moving image (in a 3D file format)
>>>    3) Filename for the difference between
>>>       fixed image and moving image Before
>>>       registration (in a 3D file format)
>>>    4) Filename for the difference between
>>>       fixed image and moving image After
>>>       registration (in a 3D file format)
>>>    5) Filename for 1 slice of the difference
>>>       between fixed image and moving image
>>>       Before registration (in a 2D file format)
>>>    6) Filename for 1 slice of the difference
>>>       between fixed image and moving image
>>>       After registration (in a 2D file format)
>>>
>>>
>>>According to your email, you are missing the argument (3),
>>>and you are passing wrong file formats for (what should have
>>>been) arguments (4) and (5).
>>>
>>>A correct command line should look like:
>>>
>>>
>>>    ImageRegistration8
>>>      fixedImage.mhd
>>>      movingImage.mhd
>>>      registeredMovingImage.mhd
>>>      differenceBefore.mhd
>>>      differenceAfter.mhd
>>>      sliceDifferenceBefore.png
>>>      sliceDifferenceAfter.png
>>>
>>>
>>>
>>>Please read the description of this example in the
>>>ITK Software Guide:
>>>
>>>
>>>      http://www.itk.org/ItkSoftwareGuide.pdf
>>>
>>>in the "Image Registration" chapter.
>>>
>>>
>>>You will also find a list of the fileformats supported
>>>in ITK in the Chapter "Reading and Writing Images" in
>>>the ITK Software Guide.
>>>
>>>
>>>
>>>Regards,
>>>
>>>
>>>   Luis
>>>
>>>
>>>
>>>--------------------
>>>Lars Nygard wrote:
>>>
>>>
>>>
>>>>Hallo,
>>>>
>>>>Im trying to use example eight in the registration part (ImageRegistration8.cxx) to
>>>>register a 3D MR Angiography (moving) to an 3D MR T1 image (fixed).
>>>>When I run it i get an error message (see bottom). Is there anybody who can give me
>>>>a hint on what's happening. 
>>>>I haven't been able to run ImageRegistration8.cxx example with the normal data because
>>>>I can't connect to the ftp site ( ftp://public.kitware.com/pub/itk/Data/BrainWeb).
>>>>Does anybody know where I can download the files brainweb165a10f17.mha and
>>>>brainweb165a10f17Rot10Tx15.mha??
>>>>Ok thanks.
>>>>greets
>>>>Lars Nygard
>>>>
>>>>error message
>>>>------------------------------------------------------------------------------------------------------------------
>>>>C:\Documents and Settings\nygard\Desktop\Insight Toolkit\Examples\Registration\I
>>>>mageRegistration8\debug>ImageRegistration8 N492_MRT1.mha N492_MRA.mha diffbefore
>>>>.png deffafter.png slicebefore.png sliceafter.png
>>>>
>>>>ExceptionObject caught !
>>>>itk::ExceptionObject (0130F7A0)
>>>>Location: "class itk::CovariantVector<double,3> *__thiscall itk::ImportImageCont
>>>>ainer<unsigned long,class itk::CovariantVector<double,3> >::AllocateElements(uns
>>>>igned long) const"
>>>>File: c:\documents and settings\nygard\desktop\insight toolkit\source\insighttoo
>>>>lkit-3.2.0\code\common\itkImportImageContainer.txx
>>>>Line: 188
>>>>Description: Failed to allocate memory for image.
>>>>
>>>>
>>>>    
>>>>_________________________________________________________
>>>>Alt i én. Få Yahoo! Mail med adressekartotek, kalender og
>>>>notisblokk. http://no.mail.yahoo.com
>>>>_______________________________________________
>>>>Insight-users mailing list
>>>>Insight-users at itk.org
>>>>http://www.itk.org/mailman/listinfo/insight-users
>>>>
>>>
>>>
>>>
>>>     
>>>_________________________________________________________
>>>Alt i én. Få Yahoo! Mail med adressekartotek, kalender og
>>>notisblokk. http://no.mail.yahoo.com
>>>
>>
>>
>>
>>    
>>    
>>        
>>_________________________________________________________
>>Alt i én. Få Yahoo! Mail med adressekartotek, kalender og
>>notisblokk. http://no.mail.yahoo.com
>>
> 
> 
> 
>       
> _________________________________________________________
> Alt i én. Få Yahoo! Mail med adressekartotek, kalender og
> notisblokk. http://no.mail.yahoo.com
> 


More information about the Insight-users mailing list