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_AuthorTopic_ConvertBrainImagesToCVBData.m
    path of file: ./repos/CBIG/stable_projects/meta-analysis/Ngo2019_AuthorTopic/utilities/preprocessing
    
    the code of the file until where you have to start completion: function CBIG_AuthorTopic_ConvertBrainImagesToCVBData(dataDir, cvbDataFile)
% CBIG_AuthorTopic_ConvertBrainImagesToCVBData(dataDir, cvbDataFile)
%
% Convert binary-smoothed brain images of activation foci to data input
% for the Collapsed Variational Bayes (CVB) algorithm.
% The binary-smoothed brain images are produced by
% CBIG_AuthorTopic_PreprocessExpDataFromText.m
%
% Input:
%  - dataDir: path to the base directory containing the preprocessed data.
%      "<processedDir>/BinarySmoothedVolumes" contains the brain images of
%      activation foci smoothed with a binary smoothing kernel.
%      All brain images have 1mm resolution.
%  - cvbDataFile: path to the input data file for the CVB algorithm.
%
% Example:
%   dataDir = '/Work/data';
%   cvbDataFile = fullfile(dataDir, 'SelfGeneratedThought_CVBData.mat')
%   CBIG_AuthorTopic_ConvertBrainImagesToCVBData(dataDir, cvbDataFile)
%
%   Convert the smoothed brain images of activation foci under
%   '/Work/data/BinarySmoothedVolumes' to input data for CVB algorithm,
%   saved at '/Work/data/SelfGeneratedThought_CVBData.mat'.
%
% Written by Gia H. Ngo and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md

  disp('Converting brain images to CVB input format');

  % Read brain mask
  baseBrainMaskPath = fullfile(getenv('CBIG_CODE_DIR'), 'stable_projects', 'meta-analysis', 'Ngo2019_AuthorTopic', 'utilities', 'mask', 'MNI_mask_conformed.2mm.0.1.nii.gz');
  brainMask = MRIread(baseBrainMaskPath);
  brainIndex = brainMask.vol(:) == 1;

  experimentsFile = fullfile(dataDir, 'ExperimentsData.mat');

    
function CBIG_AuthorTopic_ConvertBrainImagesToCVBData(dataDir, cvbDataFile)
% CBIG_AuthorTopic_ConvertBrainImagesToCVBData(dataDir, cvbDataFile)
%
% Convert binary-smoothed brain images of activation foci to data input
% for the Collapsed Variational Bayes (CVB) algorithm.
% The binary-smoothed brain images are produced by
% CBIG_AuthorTopic_PreprocessExpDataFromText.m
%
% Input:
%  - dataDir: path to the base directory containing the preprocessed data.
%      "<processedDir>/BinarySmoothedVolumes" contains the brain images of
%      activation foci smoothed with a binary smoothing kernel.
%      All brain images have 1mm resolution.
%  - cvbDataFile: path to the input data file for the CVB algorithm.
%
% Example:
%   dataDir = '/Work/data';
%   cvbDataFile = fullfile(dataDir, 'SelfGeneratedThought_CVBData.mat')
%   CBIG_AuthorTopic_ConvertBrainImagesToCVBData(dataDir, cvbDataFile)
%
%   Convert the smoothed brain images of activation foci under
%   '/Work/data/BinarySmoothedVolumes' to input data for CVB algorithm,
%   saved at '/Work/data/SelfGeneratedThought_CVBData.mat'.
%
% Written by Gia H. Ngo and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md

  disp('Converting brain images to CVB input format');

  % Read brain mask
  baseBrainMaskPath = fullfile(getenv('CBIG_CODE_DIR'), 'stable_projects', 'meta-analysis', 'Ngo2019_AuthorTopic', 'utilities', 'mask', 'MNI_mask_conformed.2mm.0.1.nii.gz');
  brainMask = MRIread(baseBrainMaskPath);
  brainIndex = brainMask.vol(:) == 1;

  experimentsFile = fullfile(dataDir, 'ExperimentsData.mat');

  load(experimentsFile)
  numStudies = length(Experiments);

  % Extract unique tasks
  uniqueTasks = {};
  uniqueTaskCount = 0;
  for i = 1:length(expTasks)
    match = strcmp(expTasks{i}, uniqueTasks);
    if (~any(match))
      uniqueTaskCount = uniqueTaskCount + 1;
      uniqueTasks{uniqueTaskCount} = cell2mat(expTasks{i});
    end