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: CBIG_AuthorTopicEM_RunEM.m
    path of file: ./repos/CBIG/stable_projects/meta-analysis/Yeo2015_AuthorTopicEM/utilities/inference
    
    the code of the file until where you have to start completion: function CBIG_AuthorTopicEM_RunEM(seed, K, input_file, brain_mask2mm, alpha, eta, init_type, init_file)
% CBIG_AuthorTopicEM_RunEM(seed, K, input_file, brain_mask2mm, alpha, eta, init_type, init_file)
%
% Wrapper function to estimate the author-topic model's parameters using the Expectation-Maximization (EM)
% inference algorithm for a given initialization seed
%
% Input:
%   - seed          = seed used by Matlab's random number generator
%   - K             = number of components to be estimated
%   - input_file    = input data file for the EM algorithm, generated by
%                     CBIG_AuthorTopicEM_ConvertActToEMFormat
%   - brain_mask2mm = struct containing a brain mask at 2mm resolution (read by MRIread)
%   - alpha & eta   = hyperparameters of the author topic model's Dirichlet
%                     priors.
%   - init_type     = a string used to determine how the auxiliary parameter
%                     of the model is generated. 'RAND' if the auxiliary
%                     parameter is randomly generated, 'GIBBS' if the auxiliary
%                     parameter is the output of Gibbs sampling
%   - init_file     = if init_type = 'GIBBS', the output of GIBBS sampling from
%                     init_file is used
% Output:
%   Output of EM algorithm is saved at 
%   EM_outputs_<init_type>_init/K<K>/alpha<alpha>_eta<eta>/seed<seed>.mat
%
% Example:
%   input_file = '~/Work/em_at_data.mat';
%   brain_mask2mm = MRIread(fullfile(getenv('CBIG_CODE_DIR'), 'stable_projects', ...
%       'meta-analysis', 'Yeo2015_AuthorTopicEM', 'utilities', ...
%       'mask', 'MNI_mask_conformed.2mm.0.1.nii.gz'));
%   init_file = '~/Work/GIBBS_outputs/K2/alpha100_eta0.01/seed42/seed42.burn2.int2.sample1.mat';
%   CBIG_AuthorTopicEM_RunEM(42, 2, input_file, brain_mask2mm, 100, 0.01, 'GIBBS', init_file)

    
function CBIG_AuthorTopicEM_RunEM(seed, K, input_file, brain_mask2mm, alpha, eta, init_type, init_file)
% CBIG_AuthorTopicEM_RunEM(seed, K, input_file, brain_mask2mm, alpha, eta, init_type, init_file)
%
% Wrapper function to estimate the author-topic model's parameters using the Expectation-Maximization (EM)
% inference algorithm for a given initialization seed
%
% Input:
%   - seed          = seed used by Matlab's random number generator
%   - K             = number of components to be estimated
%   - input_file    = input data file for the EM algorithm, generated by
%                     CBIG_AuthorTopicEM_ConvertActToEMFormat
%   - brain_mask2mm = struct containing a brain mask at 2mm resolution (read by MRIread)
%   - alpha & eta   = hyperparameters of the author topic model's Dirichlet
%                     priors.
%   - init_type     = a string used to determine how the auxiliary parameter
%                     of the model is generated. 'RAND' if the auxiliary
%                     parameter is randomly generated, 'GIBBS' if the auxiliary
%                     parameter is the output of Gibbs sampling
%   - init_file     = if init_type = 'GIBBS', the output of GIBBS sampling from
%                     init_file is used
% Output:
%   Output of EM algorithm is saved at 
%   EM_outputs_<init_type>_init/K<K>/alpha<alpha>_eta<eta>/seed<seed>.mat
%
% Example:
%   input_file = '~/Work/em_at_data.mat';
%   brain_mask2mm = MRIread(fullfile(getenv('CBIG_CODE_DIR'), 'stable_projects', ...
%       'meta-analysis', 'Yeo2015_AuthorTopicEM', 'utilities', ...
%       'mask', 'MNI_mask_conformed.2mm.0.1.nii.gz'));
%   init_file = '~/Work/GIBBS_outputs/K2/alpha100_eta0.01/seed42/seed42.burn2.int2.sample1.mat';
%   CBIG_AuthorTopicEM_RunEM(42, 2, input_file, brain_mask2mm, 100, 0.01, 'GIBBS', init_file)
%
%   Perform model parameters estimate with EM algorithm for seed 42 with 2 components, initialized
%   with alpha = 100, eta = 0.01 and outputs from the Gibbs sampler.
%
% Written by B.T.Thomas Yeo and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md

  if(nargin < 8)
      if (strcmp(init_type, 'GIBBS'))
          error('Missing initialization from Gibbs sampling');
      end