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: refractEyePoints.m
    path of file: ./repos/gkaModelEye/model/project/stages
    
    the code of the file until where you have to start completion: function [eyePoints, pointLabels, targetIntersectError] = refractEyePoints(eyePoints,pointLabels,sceneGeometry,p,eyePose)
% Subject eyeWorld points to refraction by the cornea and artificial lenses
%
% Syntax:
%  [eyePoints, pointLabels, targetIntersectError] = refractEyePoints(eyePoints,pointLabels,sceneGeometry,p,eyePose)
%
% Description:
%   This step accounts for the effect of corneal and corrective lens
%   refraction upon the appearance of coordinate points from the eye.
%
% Inputs:
%   eyePoints             - nx3 vector. Points in eye world coordinates.
%   pointLabels           - nx1 cell array. The name of each eye point.
%   sceneGeometry         - Structure. SEE: createSceneGeometry
%   p                     - Structure. The structure returned by the
%                   
    
function handle.
        [virtualImageRay, ~, intersectError] = ...
            pupilRayFunc(eyePoint, eyePose, args{:});
        virtualPoint = virtualImageRay(1,:);
        
        % Check if the point has encountered total internal reflection or
        % is a bad ray trace
        retainPoint = true;
                
        if isnan(intersectError) || (intersectError > rayTraceErrorThreshold)
            % The eyePoint did not yield a valid image point. We will not
            % retain the point unless we find a replacement.
            retainPoint = false;
            
            % If this eyePoint is on the stop border, search across smaller
            % stop radii to find a replacement point on the boundary of the
            % pupil perimeter that does make it through.
            if replaceReflectedPoints

                % Find the appropriate center target for the search
                switch pointLabels{refractPointsIdx(ii)}
                    case 'stopPerimeter'
                        centerTarget = sceneGeometry.eye.stop.center;
                    case 'stopPerimeterFront'
                        centerTarget = sceneGeometry.eye.stop.center(1)+sceneGeometry.eye.iris.thickness/2;
                    case 'stopPerimeterBack'
                        centerTarget = sceneGeometry.eye.stop.center(1)-sceneGeometry.eye.iris.thickness/2;
                    case 'irisActualPerimeter'
                        centerTarget = sceneGeometry.eye.iris.center;
                end