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: permutationPFAcrossSessions.m
    path of file: ./repos/bspm/thirdparty/bramila/external/ISC_toolbox/ISCanalysis
    
    the code of the file until where you have to start completion: function permutationPFAcrossSessions(Params,nrBand,sessBlock)
% This function generates null distribution for sum ZPF
% statistic. The sign of the ZPF statistic of the subject
% pairs is randomly flipped and summed up several times. At
% single iteration, same randomization is used across all brain
% voxels and maximum across the voxels is selected to obtain final
% realization. This procedure takes automatically care of the multiple

    
function permutationPFAcrossSessions(Params,nrBand,sessBlock)
% This function generates null distribution for sum ZPF
% statistic. The sign of the ZPF statistic of the subject
% pairs is randomly flipped and summed up several times. At
% single iteration, same randomization is used across all brain
% voxels and maximum across the voxels is selected to obtain final
% realization. This procedure takes automatically care of the multiple
% comparisons.
%
% See also: RUNANALYSIS, INITPARAMS

% Last updated: 21.6.2011 by Jukka-Pekka Kauppi
% Tampere University of Technology
% Department of Signal Processing
% e-mail: jukka-pekka.kauppi@tut.fi


showTime(1);

Priv = Params.PrivateParams;
Pub = Params.PublicParams;



if Pub.sessionCompOn == 0
    disp('Sum ZPF map computation across sessions not selected...')
    return
end

if ~Pub.corOn
    disp('Correlation coefficient needs to be selected in order to compute sum ZPF maps...')
    return
end

if ~Pub.calcStandard
    disp('Correlation coefficient needs to be selected in order to compute sum ZPF maps...')
    return
end

for xx = 1:Priv.nrSessions
    za(xx) = Priv.dataSize(xx,4);
end
if length(unique(za)) ~= 1
    disp('Each session must have same number of data points in order to compute sum ZPF maps across sessions, calculation skipped...')
    return
end

if Priv.nrSessions < 2
    disp('Only one session specified, sumZPF across sessions cannot be computed...')
    return
end

for fc = 1:length(sessBlock)
    Fi = [Priv.PFsessionDestination 'band' num2str(nrBand) 'valsPFsessComp' num2str(sessBlock(fc)) '.mat'];
    if exist(Fi) == 2
        disp(['File ' Fi ' already exists, sum ZPF permutation test skipped...'])
        return
    end
end



load([Pub.dataDestination 'memMaps'])

nrPerm = Pub.permutSessionComp;
nrSubjectPairs = (Priv.nrSubjects^2-Priv.nrSubjects)/2;

% load mask:
if Pub.useTemplate
  bmask = load_nii(Priv.brainMask);
  bmask = single(bmask.img);
else
  bmask = load(Priv.brainMask);
  fiel = fields(bmask);
  bmask = bmask.(fiel{1});
  bmask = single(bmask);
end