Hi, whenever I try using landmarks I get a matrix multiplication error:
*******************************************************************************
??? Error using ==> times
Matrix dimensions must agree.
Error in ==> affine_registration_error>affine_point_error at 255
errordis=sum(distance.*PStrength);
Error in ==> affine_registration_error>affine_registration_error_2d at 161
e=e+affine_point_error(M,I1,Points1, Points2, PStrength);
Error in ==> affine_registration_error at 107
e=affine_registration_error_2d(par,I1,I2,type,O_trans,Spacing,MaskI1,MaskI2,Points1,Points2,PStrength);
Error in ==>
register_images>@(x)affine_registration_error(x,scale,ITmoving,ITstatic,type,O_trans,Spacing,MASKmoving,MASKstatic,Points1t,Points2t,PStrengtht)
Error in ==> fminlbfgs>gradient_function at 729
[fval, grad]=feval(funfcn,reshape(x,data.xsizes));
Error in ==> fminlbfgs at 154
[data,fval,grad]=gradient_function(data.xInitial,funfcn, data, optim);
Error in ==> register_images at 230
x=fminlbfgs(@(x)affine_registration_error(x,scale,ITmoving,ITstatic,type,O_trans,Spacing,MASKmoving,MASKstatic,Points1t,Points2t,PStrengtht),x,optim);
*******************************************************************************
I am using three landmark points; i.e. Points1 and Points2 are 3 by 2 matrices and PStrength is a 3 by 1 matrix.
@Tripp, I have found that bug too, I think it suffice to replace M=[] with M=eye(4).
There is however another bug I am afraid. I have not gone deep into the code yet but it seems that, when doing 3D NonRigid registration only 1 direction out of 3 is computed, i.e. the resulting grid only has the estimated deformation in the third component, and components 1 and 2 remain unchanged. Ani hint on how to fix this?
Great submission!
I believe there is a slight bug in the 3D registration if one does non-rigid registration only. I get the following error:
??? Attempted to access M(1,1); index out of bounds because size(M)=[0,0].
Error in ==> make_init_grid at 63
O_trans(:,:,:,1) = mean(1) + M(1,1) * xd + M(1,2) *yd + M(1,3) *zd + M(1,4)* 1;
Error in ==> image_registration>Make_Initial_Grid at 475
O_trans=make_init_grid(Spacing,size(Imoving),M);
Error in ==> image_registration at 219
[O_trans,Spacing,MaxItt]=Make_Initial_Grid(O_trans,Spacing,Options,Imoving,M,IS3D);
If I had to guess, it seems like M (inverse transformation from rigid registration) isn't initialized in the 3D, non-rigid case. I do not get this error when running 2D non-rigid. I also do not get this error when running 3D rigid + non-rigid.
Hi Dirk, very good work and thank you. I think there is a minor bug here.
In the file "affine_registration_error.m You should have if(~exist('Spacing','var')),Spacing=[]; end
Or else, when you run rigid or affine registration, you will always ave to specify the space which is only necessary when bspline registration is used.
Dear Dirk, I want to know if this algo can register a 2d image to a 3d Volume? According to my limited understanding, such registrations are done using projection based methods.. Any suggestion on this. Many thanks.
Comment only