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: palm_maskstruct.m
    path of file: ./repos/CBIG/external_packages/matlab/non_default_packages/palm/palm-alpha109
    
    the code of the file until where you have to start completion: function S = palm_maskstruct(mask,readwith,extra)
% Create a struct for a mask, as if it had been read from a file.
% This is useful to save later the data.
%

    
function S = palm_maskstruct(mask,readwith,extra)
% Create a struct for a mask, as if it had been read from a file.
% This is useful to save later the data.
%
% Usage:
% M = maskstruct(mask,readwith,extra)
%
% Inputs:
% mask     : A (1 by m) real array.
% readwith : A string telling which function was used to read
%            original data. See 'miscread.m' for help.
% extra    : A struct that varies according to which function
%            was used to read the data.
%
% Usage:
% S        : A struct derived from the 'extra' argument along
%            The mask itself will then be in M.data.
%
% _____________________________________
% Anderson M. Winkler
% FMRIB / University of Oxford
% Aug/2013
% http://brainder.org

% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% PALM -- Permutation Analysis of Linear Models
% Copyright (C) 2015 Anderson M. Winkler
% 
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% any later version.
% 
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
% 
% You should have received a copy of the GNU General Public License
% along with this program.  If not, see <http://www.gnu.org/licenses/>.
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

% This is common to all cases below.
S.filename = '';
S.readwith = readwith;

% If more information is given, use to create the structs
% that will be used later to mask and save files. Note that
% the field 'filename' should remain empty.
switch lower(readwith),
    
    case {'load','csvread','vestread'},
        
        % If the original data is a CSV or VEST file.
        S.data = mask;
        S.extra = extra;
        
    case 'wb_command',
        S.data  = mask;
        S.extra = extra;
        
    case 'nifticlass',
        
        % If the original data is NIFTI and was read witht the NIFTI class
        S.data          = palm_conv2to4(mask,extra.dat.dim(1:3));
        S.extra.mat     = extra.mat;
        S.extra.dat.dim = extra.dat.dim;
        
    case 'spm_spm_vol',
        
        % If the original data is NIFTI and was read with SPM.
        S.data           = palm_conv2to4(mask,extra(1).dim(1:3));
        S.extra          = extra(1);
        S.extra.dt(1)    = spm_type('float64');
        S.extra.pinfo(1) = 1;
        
    case 'fs_load_nifti',
        
        % If the original data is NIFTI and was read with FreeSurfer.
        S.data                 = palm_conv2to4(mask,extra.hdr.dim(2:4));
        S.extra                = extra;
        S.extra.hdr.scl_slope  = 1;
        S.extra.hdr.dim([1 5]) = [3 1];
        S.extra.hdr.pixdim(5)  = 0;
        S.extra.hdr.datatype   = 64;
        S.extra.hdr.bitpix     = 64;
        
    case 'fsl_read_avw',
        
        % If the original data is NIFTI and was read with FSL.
        S.data  = palm_conv2to4(mask,extra.dims(1:3));
        S.extra = extra;
        if ~ isfield(S.extra,'vtype'),
            S.extra.vtype = 'd';
        end