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: icatb_compute_percent_variance.m
    path of file: ./repos/bspm/thirdparty/MIALAB/GroupICATv4.0a/icatb/icatb_helper_functions
    
    the code of the file until where you have to start completion: function [ss_residual, ss_total, percent_variance]  = icatb_compute_percent_variance(data, model)
%% Use regression to get explained percent variance in the data by the model
% where components are treated as model.
%
% Inputs:
% 1. data - Data is of size voxels by timepoints
% 2. model - Component timecourses of dimensions timepoints by components
%
% Outputs:
% 1. ss_residual - Sum of squares of residual
% 2. ss_total - Total sum of squares
% 3. percent_variance - Percent variance

%% Initialise variables
voxels = size(data, 1);
time_points = size(data, 2);

    
function [ss_residual, ss_total, percent_variance]  = icatb_compute_percent_variance(data, model)
%% Use regression to get explained percent variance in the data by the model
% where components are treated as model.
%
% Inputs:
% 1. data - Data is of size voxels by timepoints
% 2. model - Component timecourses of dimensions timepoints by components
%
% Outputs:
% 1. ss_residual - Sum of squares of residual
% 2. ss_total - Total sum of squares
% 3. percent_variance - Percent variance

%% Initialise variables
voxels = size(data, 1);
time_points = size(data, 2);

%% Do error check on number of timepoints
if (time_points ~= size(model, 1))
    model = model';
end