[Insight-users] setSpacing() Ignored writing to files

Felix Bollenbeck bollen at ipk-gatersleben.de
Mon Jan 28 06:24:19 EST 2008


Hi Luis,

I am using serial section light mircoscopy stains.

I set up a centered2dtransform mulitresolution registration for 2d image 
pairs with squared differences metric.

I set up a prototype of the whole thing in matlab now porting to C for 
obvious reasons.

registering two raw images at the raw data 72dpi works perfekt (Due to 
the excellent documentation in the SWGuide!).

The result is written to a tiff-file, and subsequently used as the 
reference for the next stack image.

Since itk TIFFIO doesnt support a spacing tag as Bill said, im changing 
the spacing after the image is read using ChangeInformationImageFilter 
so that both images are uniform again.

Only after this is done, the initialization or translation evaluation is 
wrong, which i dont understand!

strangely, when i set all raw images to [1 1] mm beforehand to match 
itks tiffio default everything is fine too!?

Yes a 'proper' image format is proberly the best solution!

Thanks for your time,

Felix.









Luis Ibanez wrote:
>
> Hi Felix,
>
>
> My suggestion:
>
>
>    a) Make a backup of your code
>    b) Hide the backup in the corner of a dark room
>    c) Delete your current code
>    d) Forget everything you have done so far
>    e) Start from scratch
>
>
> From your email it seems that you are
>
>
>    1) Working with 2D images of plants
>    2) Performing registration with these images
>
>
> Is that right ?
>
>
> If so, let's go from the beginning:
>
>
>     A) What is the image modality that you
>        are using ?
>
>         - Microscopy ?
>         - Satellite images of forest ?
>         - Video cameras ?
>
>
>     B) It seems that you have some freedom
>        to choose your image file format.
>
>        Is that right ?
>
>        If so we suggest you to use one of
>        the following:
>
>         a) MetaImage     .mha
>         b) Nifti         .nii
>         c) Nrrd          .nrrd
>         e) VTK           .vtk
>
>
>      C) Before you attempt to do any registration,
>         you should verify that you are able to
>         read and write your images, and preserve
>         the information related to:
>
>             - Image Origin
>             - Image Spacing
>             - Image Orientation
>
>         DO NOT Attempt to do any registration until
>         you are sure that you have mastered the above.
>
>
>      D) Once you are ready for registration you
>         should first read the "Image Registration"
>         chapter of the ITK Software Guide
>
>         http://www.itk.org/ItkSoftwareGuide.pdf
>
>
>      E) You must start by using a proper Transform
>         initialization. The error that you were
>         getting from the MeanSquareMetric is usually
>         due to a poor initialization of the Transform.
>
>
>
>   Please let us know your answers to the questions above,
>   and from there we will be able to advice you on a proper
>   way to setup your image registration problem.
>
>
>
>        Regards,
>
>
>
>             Luis
>
>
>
>
>
> ------------------------
> Felix Bollenbeck wrote:
>> Hi Bill,
>>
>> i couldnt get along with the ChangeInformationImageFilter as suggested:
>>
>> I used ChangeInformationImageFilter to set both moving and fixed 
>> image (only fixed image snipped) to unit-spacing as below
>>
>>  typedef itk::ChangeInformationImageFilter<FixedImageType>  
>> SpacingFilterType;
>>  SpacingFilterType::Pointer fixedSpacingFilter= 
>> SpacingFilterType::New();
>>  fixedSpacingFilter->ChangeSpacingOn();
>>  fixedSpacingFilter->SetInput(fixedImageReader->GetOutput());
>>  double unitSpacing[2];
>>  unitSpacing[0] = 1.0;
>>  unitSpacing[1] = 1.0;
>>  fixedSpacingFilter->SetOutputSpacing(unitSpacing);
>>  fixedSpacingFilter->Update();
>>  FixedImageType::Pointer fixedImage=fixedSpacingFilter->GetOutput();
>>
>> However doesnt seem to work
>> /
>> SIZE spacing-fixed 1    1                                          # ok
>> SIZE spacing-moving 1   1                                       //# ok/
>> /0   5938.29   [5.41628, 800, 600, 13.8069, -2.2433]
>> 1   12.1176   [10.7422, 798.529, 591.101, 22.6854, -8.28141]
>> ExceptionObject caught !
>>
>> itk::ExceptionObject (0xbb8720)
>>
>> ...
>>
>> File: 
>> /home/felix/Desktop/InsightToolkit-3.4.0/Code/Algorithms/itkMeanSquaresImageToImageMetric.txx 
>>
>> Line: 369
>> Description: itk::ERROR: MeanSquaresImageToImageMetric(0xba11d0): All 
>> the points mapped to outside of the moving image/
>>
>> which means something with the set spacing is completely wrong-but 
>> what? -Im clueless.
>>
>> Setting the spacing of the written out-image is ignored, as you said. 
>> I dont see any workarround.
>>
>> I also tried to set the pixel-res in the data generation side, to 
>> match ITK's default [1 1] spacing, obtaining different values than I 
>> expected, which should be due to the inch/mm confusion-Ill check on 
>> that.
>>
>> But i would rather like to handle this on the  ITK side. Would you 
>> perhaps also suggest the use of a different file format? Im not 
>> working with medical images (but plants) so changing image properties 
>> is not that critical to me.
>>
>> Thanks in advance & Best regards,
>>
>>    Felix.
>>
>
>


-- 
Felix Bollenbeck             Email: bollen at ipk-gatersleben.de
Pattern Recognition Group       Phone: +49 (0)39482 5344
Leibniz Institute of Plant     Fax  : +49 (0)39482 5137
Genetics and Crop Plant Research
Correnstr.3                     http://www.ipk-gatersleben.de
06466 Gatersleben,Germany
  



More information about the Insight-users mailing list