function [ bil ] = registerbil( bil,registrationmode )
%Registers images in a bil file
%Generates a monomodal optimization routine for contrast-based image
%registration with a suitable metric. Registers all input images relative
%to the first image by translation only, and reports the registered images 
%into the specified matrix.
%
%NB you must use the [] output brackets with one variable in order to
%output the images back into the workspace. After Registration, it is 
%recommended that you crop a border prior to PCA to remove killed edge 
%pixels, and also that you overwrite the input matrix to save memory.
%
%OUTPUTS: bil file with all images translationally registered
[optimizer,metric]=imregconfig('multimodal');
images=size(bil,3);
fprintf('|');
for n=2:images
bil(:,:,n)=imregister(bil(:,:,n),bil(:,:,1),registrationmode,optimizer,metric);
fprintf('|');
end
fprintf(' ');
end