You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: ft_omri_align_scan.m
    path of file: ./repos/fieldtrip/realtime/online_mri
    
    the code of the file until where you have to start completion: function [model, mat_r, mat_a, Va] = ft_omri_align_scan(model, Vo)


    
function [model, mat_r, mat_a, Va] = ft_omri_align_scan(model, Vo)

% function [model, mat_r, mat_a, Va] = ft_omri_align_scan(model, Vo)
%
% Estimate 6-DOF motion parameters and align volume Vo with reference model.
%
% INPUTS
% model - data structure containing reference image and flags
% Vo    - original image (to be registered to the reference model
%
% OUTPUTS
% model - same as input, but with modified voxel mask (for keeping track of "missing voxels")
% Va    - aligned image (possibly rotated + translated version of Vo)
% mat_r - parameters of 6-dof transformation in homogenous matrix form
%         transformation from world coordinates of Vo to world coordinates of reference
% mat_a - pixel to world coordinate matrix of Vo (absolute "position" of Vo)

% Basic code taken from SPM8, adapted for online use 2010, S.Klanke

startTime = tic;

%-----------------------------------------------------------------------
V  = smooth_vol(Vo, model.interp, model.wrap, model.fwhm, model.mat);
d  = [size(V) 1 1];
d  = d(1:3);
ss = Inf;
countdown = -1;

mat_a = model.mat;

for iter=1:64,
	[y1,y2,y3] = coords([0 0 0  0 0 0],model.mat, mat_a, model.x1, model.x2, model.x3);
	msk        = find((y1>=1 & y1<=d(1) & y2>=1 & y2<=d(2) & y3>=1 & y3<=d(3)));
	if length(msk)<32
		error 'Too little information left';
	end