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_CheckValidSurfaceData.m
    path of file: ./repos/CBIG/utilities/matlab/figure_utilities/draw_surface_data_as_annotation
    
    the code of the file until where you have to start completion: function flag = CBIG_CheckValidSurfaceData(surface_template, lh_data, rh_data, ref_lh_vertices, ref_rh_vertices)

% flag = CBIG_CheckValidSurfaceData(surface_template, lh_data, rh_data, ref_lh_vertices, ref_rh_vertices)
%
% Check if the number of vertices in the input annotation match that of
% the reference vertices and the surface template in both hemispheres
% 
% Input:
%     - lh_data              : column vector containing surface data of
%                              the left hemisphere.
%     - rh_data              : column vector containing surface data of
%                              the right hemisphere.
%     - ref_lh_vertices      : column vector containing reference vertices
%                              of the left hemisphere.
%     - ref_rh_vertices      : column vector containing reference vertices
%                              of the right hemisphere
%     - surface_template     : name of the surface space of the input
%                              data.`surface_space` needs to correspond to
%                              number of vertices of the annotation in
%                              `lh_data`, `rh_data` and the reference annotations.
%        surface_template    |      number of vertices
%          fsaverage5        |            10242
%          fsaverage6        |            40962

    
function flag = CBIG_CheckValidSurfaceData(surface_template, lh_data, rh_data, ref_lh_vertices, ref_rh_vertices)

% flag = CBIG_CheckValidSurfaceData(surface_template, lh_data, rh_data, ref_lh_vertices, ref_rh_vertices)
%
% Check if the number of vertices in the input annotation match that of
% the reference vertices and the surface template in both hemispheres
% 
% Input:
%     - lh_data              : column vector containing surface data of
%                              the left hemisphere.
%     - rh_data              : column vector containing surface data of
%                              the right hemisphere.
%     - ref_lh_vertices      : column vector containing reference vertices
%                              of the left hemisphere.
%     - ref_rh_vertices      : column vector containing reference vertices
%                              of the right hemisphere
%     - surface_template     : name of the surface space of the input
%                              data.`surface_space` needs to correspond to
%                              number of vertices of the annotation in
%                              `lh_data`, `rh_data` and the reference annotations.
%        surface_template    |      number of vertices
%          fsaverage5        |            10242
%          fsaverage6        |            40962
%          fsaverage         |            163842
%          fs_LR_32k         |            32492
%          fs_LR_164k        |            163842
% Example:
%  flag = CBIG_CheckValidSurfaceData('fsaverage5', lh_data, rh_data, ref_lh_vertices, ref_rh_vertices)
%
%  Check if the length of vectors lh_data, rh_data, ref_lh_vertices and
%  ref_rh_vertices equal to each other and equal to 10242 (number of vertices
%  in fsaverage5 template). flag equals to 1 if true, and 0 otherwise.
%
% Written by Gia H. Ngo and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md
    
    if size(lh_data,2) ~= 1
        error('Input argument ''lh_data'' should be a column vector');
    end