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: cat_main_amap.m
    path of file: ./repos/ExploreASL/External/SPMmodified/toolbox/cat12
    
    the code of the file until where you have to start completion: function [prob,indx,indy,indz] = cat_main_amap(Ymi,Yb,Yb0,Ycls,job,res)
% ______________________________________________________________________
%
% AMAP segmentation:
% Most corrections were done before and the AMAP routine is used with 
% a low level of iterations and no further bias correction, because
% some images get tile artifacts. 
%
% [prob,indx,indy,indz] = cat_main_amap(Ymi,Yb,Yb0,Ycls,job,res)
%
% prob .. new AMAP segmenation (4D)
% ind* .. index elements to asign a subvolume
% Ymi  .. local intensity normalized source image
% Yb   .. brain mask
% Yb0  .. origina brain mask 
% Ycls .. SPM segmentation 
% job  .. SPM/CAT parameter structure
% res  .. SPM segmentation structure
% ______________________________________________________________________
%

    
function [prob,indx,indy,indz] = cat_main_amap(Ymi,Yb,Yb0,Ycls,job,res)
% ______________________________________________________________________
%
% AMAP segmentation:
% Most corrections were done before and the AMAP routine is used with 
% a low level of iterations and no further bias correction, because
% some images get tile artifacts. 
%
% [prob,indx,indy,indz] = cat_main_amap(Ymi,Yb,Yb0,Ycls,job,res)
%
% prob .. new AMAP segmenation (4D)
% ind* .. index elements to asign a subvolume
% Ymi  .. local intensity normalized source image
% Yb   .. brain mask
% Yb0  .. origina brain mask 
% Ycls .. SPM segmentation 
% job  .. SPM/CAT parameter structure
% res  .. SPM segmentation structure
% ______________________________________________________________________
%
% Robert Dahnke, Christian Gaser 
% Structural Brain Mapping Group
% University Jena 
% ______________________________________________________________________
% $Id: cat_main_amap.m 1552 2020-01-17 10:19:24Z dahnke $ 


  % this function adds noise to the data to stabilize processing and we
  % have to define a specific random pattern to get the same results each time
  if exist('rng','file') == 2, rng('default'); rng(0); else, rand('state',0); randn('state',0); end