% registration_example_script.m
% compile all auxilary files
mex -v computeEMST.c
mex -v derivativeEMST.c
mex -v sort_out_samples_double.c
mex -v volumeRigidRegisterEMSTwStochSampling.c
mex -v volumeRigidWarp.c

load ./volumes_single.mat

figure, 
imshow(squeeze(double(vol_t1(:,:,90))));
title('T1-weighted MR volume');

warped_vol_t1 = volumeRigidWarp(single(vol_t1), [10 -7 0 0 20 0]);
figure, 
subplot(2,2,1);
imshow(squeeze(double(warped_vol_t1(:,:,90))));
title('INPUT T1-weighted MR volume');

[T_final , time] = rigidRegisterEngine3D_EMST(single(warped_vol_t1), single(vol_t2), 1.9, 4);

subplot(2,2,2);
imshow(squeeze(double(vol_t2(:,:,90))));
title('INPUT T2-weighted MR volume');

warped_vol_t2 = volumeRigidWarp(single(vol_t2), T_final);
subplot(2,2,3);, imshow(squeeze(double(warped_vol_t2(:,:,90))));
title('ALIGNED T2-weighted MR volume');
