[Insight-users] An overlap invariant mutual information metric
Luis Ibanez
luis . ibanez at kitware . com
Mon, 08 Dec 2003 22:47:29 -0500
Hi Jessica,
You declarations for the RegionOfInterestImageFilter
look fine.
You don't have any variable named sizeF, or startF though...
Are you still having trouble with this code ?
If so, could you please post the current file along
with the error messages ?
About the spacing, this is critical for the
image resampling. It seems that your input
images are getting a pixel spacing of 1mm
and you are later resampling them using 0.0148mm.
The safe way of resampling the moving image is
by using the spacing of the fixed image, since
this is how the registration was performed.
Given that your processing has several stages, it
is better to check every one of them independently.
First make sure that the RegionOfInterestImageFilters
are producing reasonable results. You can add
something like
filter->GetOutput()->Print( std::cout );
for verifying the output of the filters. Look closely
at the origin and spacing of the printed out data.
Please let us know what you find.
Thanks
Luis
-----------------------
Jessica de Ryk wrote:
>>Hi Jessica,
>>
>>Thanks for your additional details,
>>
>>Note that for cropping your input images you don't need to
>>go down to use ImageIterators. You can simply use the
>>RegionOfInterestImageFilter as explained in the SoftwareGuide
>>
>> http://www . itk . org/ItkSoftwareGuide . pdf
>>
>>Section 7.4, pdf-page 225, paper-page 251.
>>
>
> I have tried using this method, however the two images have different sizes
> so I defined a FixedROI and a MovingROI, I must be missing something though
> as I get undeclaired identifier for the sizeF, sizeM, startF and startM
> After initial pixel and image type declaration etc;
>
> typedef itk::ImageFileReader< FixedImageType > FixedImageReaderType;
> typedef itk::ImageFileReader< MovingImageType > MovingImageReaderType;
>
> FixedImageReaderType::Pointer fixedImageReader =
> FixedImageReaderType::New();
> MovingImageReaderType::Pointer movingImageReader =
> MovingImageReaderType::New();
>
> fixedImageReader->SetFileName( argv[1] );
> movingImageReader->SetFileName( argv[2] );
>
> // Settings for the region of interest filter for the moving and fixed
> images
> typedef itk::RegionOfInterestImageFilter< FixedImageType,
> ROIFixedImageType > FixedROIFilterType;
> typedef itk::RegionOfInterestImageFilter< MovingImageType,
> ROIMovingImageType > MovingROIFilterType;
>
> FixedROIFilterType::Pointer fixedROI = FixedROIFilterType::New();
> MovingROIFilterType::Pointer movingROI = MovingROIFilterType::New();
>
> ROIFixedImageType::IndexType start;
> start[0] = 1040;
> start[1] = 0;
> ROIFixedImageType::SizeType size;
> size[0] = 260;
> size[1] = 1030;
> ROIMovingImageType::IndexType startM;
> startM[0] = 0;
> startM[1] = 0;
> ROIMovingImageType::SizeType sizeM;
> sizeM[0] = 260;
> sizeM[1] = 1030;
>
> ROIFixedImageType::RegionType desiredFixedRegion;
> desiredFixedRegion.SetIndex( start );
> desiredFixedRegion.SetSize( size );
>
> ROIMovingImageType::RegionType desiredMovingRegion;
> desiredMovingRegion.SetIndex( startM );
> desiredMovingRegion.SetSize( sizeM );
>
>
>>----
>>
>>If you already have an observer connected to the optimizer
>>and the error message is appearing before any iteration is
>>printed, that points to the initialization of the Transform
>>as the main suspect.
>>
>>Can you verify that you are calling SetInitialTransformParamters()
>>in the registration method class. Also, print out the components
>>of the array that you pass in this methods, just to double check
>>that the values are what you expected.
>
>
> I have this already in my code:
> typedef RegistrationType::ParametersType ParametersType;
> ParametersType initialParameters( transform->GetNumberOfParameters() );
>
>
> initialParameters[0] = 0; // Initial offset in mm along X
> initialParameters[1] = 0; // Initial offset in mm along Y
>
> registration->SetInitialTransformParameters( initialParameters );
>
>
>>About the spacing and origin, those are pointers to double, you
>>must have to do
>> std::cout << spacing[0] << ", " << spacing[1];
>> std::cout << ", " << spacing[2] << std::endl;
>>instead of plain
>> std::cout << spacing << std::endl;
>
>
> When I made those changes it gave me 1,1 as the spacing and 0,0 as the
> origin
>
>
>>About the spacing values:
>>
>>are you passing 14.88 ?
>>that is, are you using "microns" as implicit units ?
>>or are you passing the equivalent millimeters ? like 0.01488 ?
>
>
> When I try passing;
> double spacing[ Dimension ];
> spacing[0] = 0.014884; // pixel spacing in millimeters along X
> spacing[1] = 0.014884; // pixel spacing in millimeters along Y
> filter->SetOutputSpacing( spacing );
>
> I get a completely black image. Could this spacing issue be affecting my
> registration (I have got reasonable results using the both of the other
> mutual information metrics however I was hoping this NMIM could provide me
> with greater accuracy)
> Thanks
> Jessica
>
>