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: loadProjectionImages.m
    path of file: ./repos/OMEGA/source
    
    the code of the file until where you have to start completion: function [projData] = loadProjectionImages(nProjections,varargin)
%LOADPROJECTIONIMAGES Automatically loads projection images from TIFF or
%BMP images
%   This function loads the projection data from TIFF or BMP images. When
%   ran, it will prompt for a single projection image. All projection
%   images in the same folder with the same naming pattern will then be
%   loaded. Images are assumed to be numbered as e.g. _0001, _0002, etc.
%   but the number of zeros can be any, only the underline has to be
%   present before the numbers (i.e. _001, _00001, _01, types are all fine.
%   nProjections number of images are loaded (i.e. files from e.g.
%   _0001,...,_nProjections). Optionally, the user can also input a binning
%   factor. The projection images are then binned from both dimensions
%   according to the binning factor (e.g. with binning = 4, an 1024x1536
%   image becomes 256x384). No further modifications are performed.
%   
%   Examples:
%       projData = loadProjectionImages(nProjections);
%       projData = loadProjectionImages(nProjections, binning);
%       projData = loadProjectionImages(nProjections, binning, saveData,
%       fileName);
%   Inputs:
%       nProjections = The total number of images (projections) that are
%       loaded. 
%       binning = (Optional) The binning factor.
%       saveData = (Optional) If set to true, will save the projection
%       images in a mat file with the filename specified with fileName.
%       fileName = (Optional) The name of the mat-file where the projection
%       images are stored. Required if saveData is set to true.
%
% See also loadProjectionData, loadInveonCTData
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Copyright (C) 2021 Ville-Veikko Wettenhovi
%

    
function [projData] = loadProjectionImages(nProjections,varargin)
%LOADPROJECTIONIMAGES Automatically loads projection images from TIFF or
%BMP images
%   This function loads the projection data from TIFF or BMP images. When
%   ran, it will prompt for a single projection image. All projection
%   images in the same folder with the same naming pattern will then be
%   loaded. Images are assumed to be numbered as e.g. _0001, _0002, etc.
%   but the number of zeros can be any, only the underline has to be
%   present before the numbers (i.e. _001, _00001, _01, types are all fine.
%   nProjections number of images are loaded (i.e. files from e.g.
%   _0001,...,_nProjections). Optionally, the user can also input a binning
%   factor. The projection images are then binned from both dimensions
%   according to the binning factor (e.g. with binning = 4, an 1024x1536
%   image becomes 256x384). No further modifications are performed.
%   
%   Examples:
%       projData = loadProjectionImages(nProjections);
%       projData = loadProjectionImages(nProjections, binning);
%       projData = loadProjectionImages(nProjections, binning, saveData,
%       fileName);
%   Inputs:
%       nProjections = The total number of images (projections) that are
%       loaded. 
%       binning = (Optional) The binning factor.
%       saveData = (Optional) If set to true, will save the projection
%       images in a mat file with the filename specified with fileName.
%       fileName = (Optional) The name of the mat-file where the projection
%       images are stored. Required if saveData is set to true.
%
% See also loadProjectionData, loadInveonCTData
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Copyright (C) 2021 Ville-Veikko Wettenhovi
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <https://www.gnu.org/licenses/>.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if nargin >= 2 && ~isempty(varargin) && ~isempty(varargin{1})
    binning = varargin{1};
else
    binning = 1;
end