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: calculateThresholdsPF.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 calculateThresholdsPF(Params)

% 
%
%


Priv = Params.PrivateParams;  
Pub = Params.PublicParams;
freqComps = ((Priv.maxScale+2)^2-(Priv.maxScale+2))/2;

% for s = 1:Priv.nrSessions
%     for k = 1:freqComps
%         Fi = [Priv.PFDestination 'session' num2str(s) 'valsPFfreqComp' num2str(k) '.mat'];
%         if exist(Fi) == 2
%             disp(['File ' Fi ' already exists, skipping threshold calculation...'])
%             return

    
function calculateThresholdsPF(Params)

% 
%
%


Priv = Params.PrivateParams;  
Pub = Params.PublicParams;
freqComps = ((Priv.maxScale+2)^2-(Priv.maxScale+2))/2;

% for s = 1:Priv.nrSessions
%     for k = 1:freqComps
%         Fi = [Priv.PFDestination 'session' num2str(s) 'valsPFfreqComp' num2str(k) '.mat'];
%         if exist(Fi) == 2
%             disp(['File ' Fi ' already exists, skipping threshold calculation...'])
%             return
%         end
%     end
% end

critVals = [0.05 0.005 0.001];
r = 0;
for s = 1:Priv.nrSessions
  for k = 1:freqComps
    try
      load([Priv.PFDestination 'session' num2str(s) 'valsPFfreqComp' num2str(k)])
      vals1 = vals1(:)';
      vals2 = vals2(:)';
      vals = [vals1 vals2];
      vals = fliplr(sort(vals));
      for m = 1:length(critVals)
        Th(m) = vals(1 + floor(length(vals)*critVals(m)));
      end