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_RF_compute_surf2vol_avgMapping.m
    path of file: ./repos/CBIG/stable_projects/registration/Wu2017_RegistrationFusion/registration_fusion/utilities
    
    the code of the file until where you have to start completion: function CBIG_RF_compute_surf2vol_avgMapping(sub_list, input_dir, input_prefix, output_dir, output_prefix)
% CBIG_RF_compute_surf2vol_avgMapping(sub_list, input_dir, input_prefix, output_dir, output_prefix)
%
% This function computes surface-to-volume avgerage mapping of x/y/z index 
% across a given list of subjects.
%
% Input:
%     - sub_list    :
%                      absolute/relative path to subject list file,
%                        which contains a subject name each line
%     - input_dir   :
%                      absolute/relative path to directory where input can be found
%                      inputs are index files projected to a volumetric atlas space, 
%                        which can be read by MRIread()
%     - input_prefix:
%                      a fixed prefix for each subject's mapping,
%                        which may specify the approach and template used
%                      For example, an index file projected from left hemisphere of fsaverage 
%                        through Subject 0001 to the volumetric atlas space is named: 
%                        lh.xIndex_fsaverage_to_Sub0001_Ses1_FS_to_input_prefix.nii.gz
%     - output_dir:
%                      absolute/relative path to directory where output should be stored
%     - output_prefix:
%                      desired prefix for the outputs
%
% Output:
%     - There is no function output.
%     - a mapping file is created in output_dir:
%           [output_prefix]_avgMapping.prop.mat
%     - a count map file is created in output_dir:

    
function CBIG_RF_compute_surf2vol_avgMapping(sub_list, input_dir, input_prefix, output_dir, output_prefix)
% CBIG_RF_compute_surf2vol_avgMapping(sub_list, input_dir, input_prefix, output_dir, output_prefix)
%
% This function computes surface-to-volume avgerage mapping of x/y/z index 
% across a given list of subjects.
%
% Input:
%     - sub_list    :
%                      absolute/relative path to subject list file,
%                        which contains a subject name each line
%     - input_dir   :
%                      absolute/relative path to directory where input can be found
%                      inputs are index files projected to a volumetric atlas space, 
%                        which can be read by MRIread()
%     - input_prefix:
%                      a fixed prefix for each subject's mapping,
%                        which may specify the approach and template used
%                      For example, an index file projected from left hemisphere of fsaverage 
%                        through Subject 0001 to the volumetric atlas space is named: 
%                        lh.xIndex_fsaverage_to_Sub0001_Ses1_FS_to_input_prefix.nii.gz
%     - output_dir:
%                      absolute/relative path to directory where output should be stored
%     - output_prefix:
%                      desired prefix for the outputs
%
% Output:
%     - There is no function output.
%     - a mapping file is created in output_dir:
%           [output_prefix]_avgMapping.prop.mat
%     - a count map file is created in output_dir:
%           [output_prefix]_count.mat
%
% Example:
% CBIG_RF_compute_vol2surf_avgMapping('~/data/GSP_subjectnames.csv', '../results/index_MNI152/', 
%               'RF_M3Z_MNI', '../results/mappings/', 'RF_M3Z_MNI2fsaverage_avg1490Sub')
% This command reads in subject mappings from  ../results/index_fsaverage directory with 
% prefix of 'RF_M3Z_MNI'. An average mapping is generated across the subjects provided in 
% GSP_subjectnames.csv and put into ../results/mappings directory.
%
% Written by Wu Jianxiao and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md

if nargin < 5
    disp('usage: CBIG_RF_compute_surf2vol_avgMapping(sub_list, input_dir, input_prefix, output_dir, output_prefix)');
    return
end

%Read subject names
fid = fopen(sub_list, 'r');
i = 1;
while ~feof(fid)
    sub_names{i} = fgetl(fid);
    i = i + 1;
end