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_dartel_norm_fun.m
    path of file: ./repos/bspm/thirdparty/spm12/toolbox/DARTEL
    
    the code of the file until where you have to start completion: function out = spm_dartel_norm_fun(job)
% Spatially normalise and smooth fMRI/PET data to MNI space, using Dartel flow fields
% FORMAT out = spm_dartel_norm_fun(job)
% job - a structure generated by the configuration file
%   job.template - Dartel template for aligning to MNI space
%   job.subj(n)  - Subject n
%       subj(n).flowfield - Dartel flow field
%       subj(n).images    - Images for this subject
%   job.vox      - Voxel sizes for spatially normalised images
%   job.bb       - Bounding box for spatially normalised images
%   job.preserve - How to transform
%                  0 = preserve concentrations
%                  1 = preserve integral (cf "modulation")
%
% Normally, Dartel generates warped images that align with the average-
% shaped template.  This routine includes an initial affine regisration
% of the template (the final one generated by Dartel), with the TPM data
% released with SPM.
%
% "Smoothed" (blurred) spatially normalised images are generated in such a
% way that the original signal is preserved. Normalised images are
% generated by a "pushing" rather than a "pulling" (the usual) procedure.
% Note that trilinear interpolation is used, and no masking is done.  It
% is therefore essential that the images are realigned and resliced
% before they are spatially normalised.  Alternatively, contrast images
% generated from unsmoothed native-space fMRI/PET data can be spatially
% normalised for a 2nd level analysis.
%
% Two "preserve" options are provided.  One of them should do the
% equavalent of generating smoothed "modulated" spatially normalised

    
function out = spm_dartel_norm_fun(job)
% Spatially normalise and smooth fMRI/PET data to MNI space, using Dartel flow fields
% FORMAT out = spm_dartel_norm_fun(job)
% job - a structure generated by the configuration file
%   job.template - Dartel template for aligning to MNI space
%   job.subj(n)  - Subject n
%       subj(n).flowfield - Dartel flow field
%       subj(n).images    - Images for this subject
%   job.vox      - Voxel sizes for spatially normalised images
%   job.bb       - Bounding box for spatially normalised images
%   job.preserve - How to transform
%                  0 = preserve concentrations
%                  1 = preserve integral (cf "modulation")
%
% Normally, Dartel generates warped images that align with the average-
% shaped template.  This routine includes an initial affine regisration
% of the template (the final one generated by Dartel), with the TPM data
% released with SPM.
%
% "Smoothed" (blurred) spatially normalised images are generated in such a
% way that the original signal is preserved. Normalised images are
% generated by a "pushing" rather than a "pulling" (the usual) procedure.
% Note that trilinear interpolation is used, and no masking is done.  It
% is therefore essential that the images are realigned and resliced
% before they are spatially normalised.  Alternatively, contrast images
% generated from unsmoothed native-space fMRI/PET data can be spatially
% normalised for a 2nd level analysis.
%
% Two "preserve" options are provided.  One of them should do the
% equavalent of generating smoothed "modulated" spatially normalised
% images.  The other does the equivalent of smoothing the modulated
% normalised fMRI/PET, and dividing by the smoothed Jacobian determinants.
%
%__________________________________________________________________________
% Copyright (C) 2009 Wellcome Trust Centre for Neuroimaging

% John Ashburner
% $Id: spm_dartel_norm_fun.m 7182 2017-10-06 10:37:31Z christophe $

% If there is no passed tpm field (ie the default behaviour), then use the default.
if isfield(job,'tpm')
    tpm  = job.tpm.fn;
    K    = job.tpm.k;
else
    K    = 6;
    tpm  = fullfile(spm('Dir'),'tpm','TPM.nii');
end