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: spm_vb_contrasts.m
    path of file: ./repos/spm12
    
    the code of the file until where you have to start completion: function SPM = spm_vb_contrasts(SPM,XYZ,xCon,ic)
% Compute and write posterior standard deviation image of given contrast
% FORMAT SPM = spm_vb_contrasts(SPM,XYZ,xCon,ic)
%
% SPM   - SPM data structure
% XYZ   - voxel list
% xCon  - contrast info
% ic    - contrast number
%
% Get approximate posterior covariance for given contrast ic using 
% Taylor-series approximation
%__________________________________________________________________________
% Copyright (C) 2005-2012 Wellcome Trust Centre for Neuroimaging

% Will Penny 
% $Id: spm_vb_contrasts.m 5160 2012-12-21 16:58:38Z guillaume $

        
%-Get number of sessions, beta's and voxels
%--------------------------------------------------------------------------
nsess   = length(SPM.Sess);
nbeta   = size(SPM.xX.X,2);
nvox    = size(XYZ,2);

%-Get contrast vector

    
function SPM = spm_vb_contrasts(SPM,XYZ,xCon,ic)
% Compute and write posterior standard deviation image of given contrast
% FORMAT SPM = spm_vb_contrasts(SPM,XYZ,xCon,ic)
%
% SPM   - SPM data structure
% XYZ   - voxel list
% xCon  - contrast info
% ic    - contrast number
%
% Get approximate posterior covariance for given contrast ic using 
% Taylor-series approximation
%__________________________________________________________________________
% Copyright (C) 2005-2012 Wellcome Trust Centre for Neuroimaging

% Will Penny 
% $Id: spm_vb_contrasts.m 5160 2012-12-21 16:58:38Z guillaume $

        
%-Get number of sessions, beta's and voxels
%--------------------------------------------------------------------------
nsess   = length(SPM.Sess);
nbeta   = size(SPM.xX.X,2);
nvox    = size(XYZ,2);

%-Get contrast vector
%--------------------------------------------------------------------------
c       = xCon(ic).c;

%-Get posterior SD beta's
%--------------------------------------------------------------------------
sd_beta = zeros(nbeta,nvox);
for k=1:nbeta
    sd_beta(k,:) = spm_get_data(SPM.VPsd(k),XYZ);
end