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: coreg_p.m
    path of file: ./repos/osprey/coreg
    
    the code of the file until where you have to start completion: % coreg_p.m
% Georg Oeltzschner, Johns Hopkins University 2019.
%
% USAGE:
% [vol_mask] = coreg_p(in, dcm_folder, maskFile);
%
% DESCRIPTION:
% Creates a SPM volume containing a voxel mask with the same dimensions
% as the SPM volume containing a structural image. The voxel mask will be
% created with the geometry information stored in the FID-A structure "in".
% This routine works for the GE P data type.

% INPUTS:
% in        = Input data structure.
% dcm_folder = Path to the folder containing DICOM images of the structural
%           image that the voxel defined in the 'geometry' field of the
%           input data structure 'in' is supposed to be co-registered to.
% maskFile  = Filename under which the SPM volume of the co-registered
%           voxel mask is supposed to be saved.
%
% OUTPUTS:
% vol_mask  = SPM volume of the coregistered voxel mask.
% T1_max    = maximum intensity of the image volume.
% vol_image	= SPM v
    
function [vol_mask, T1_max, vol_image, voxel_ctr] = coreg_p(in, dcm_folder, maskFile)

% Deactivate MATLAB warnings and load geometry parameters
warning('off','MATLAB:nearlySingularMatrix');
warning('off','MATLAB:qhullmx:InternalWarning');
geom = in.geometry;

%%% 1. PREPARE THE MRS VOXEL COORDINATES %%%
% Convert from RAS to LPS
VoxOffs  = geom.pos .* [-1 -1 1];
tlhc_LPS = geom.rot.tlhc .* [-1 -1 1];
trhc_LPS = geom.rot.trhc .* [-1 -1 1];
brhc_LPS = geom.rot.brhc .* [-1 -1 1];

e1_SVS_n = trhc_LPS - tlhc_LPS;
e1_SVS_n = e1_SVS_n ./ norm(e1_SVS_n);
e2_SVS_n = brhc_LPS - trhc_LPS;
e2_SVS_n = e2_SVS_n ./ norm(e2_SVS_n);
e3_SVS_n = -cross(e1_SVS_n, e2_SVS_n);

[~,orientation_SVS] = max(abs(e3_SVS_n));

if orientation_SVS == 3     % axial
    e1_SVS_n2 = e1_SVS_n;
    e2_SVS_n2 = e2_SVS_n;
    e3_SVS_n2 = e3_SVS_n;
elseif orientation_SVS == 2 % coronal
    e1_SVS_n2 = e1_SVS_n;
    e2_SVS_n2 = e3_SVS_n;
    e3_SVS_n2 = e2_SVS_n;
elseif orientation_SVS == 1 % sagittal
    e1_SVS_n2 = e3_SVS_n;
    e2_SVS_n2 = e1_SVS_n;
    e3_SVS_n2 = e2_SVS_n;
end