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: spm_file.m
    path of file: ./repos/bspm/thirdparty/spm12
    
    the code of the file until where you have to start completion: function str = spm_file(str,varargin)
% Character array (or cell array of strings) handling facility
% FORMAT str = spm_file(str,option)
% str        - character array, or cell array of strings
% option     - string of requested item - one among:
%              {'path', 'cpath', 'fpath', 'basename', 'ext', 'filename',
%              'number', 'shortxx', 'unique'}
%
% FORMAT str = spm_file(str,opt_key,opt_val,...)
% str        - character array, or cell array of strings
% opt_key    - string of targeted item - one among:
%              {'path', 'basename', 'ext', 'filename', 'number', 'prefix',
%              'suffix','link','local'}
% opt_val    - string of new value for feature
%__________________________________________________________________________
%
% Definitions:
%
% <cpath> = <fpath>filesep<filename>
% <filename> = <basename>.<ext><number>
% <path> = empty or full path or relative path
%

    
function str = spm_file(str,varargin)
% Character array (or cell array of strings) handling facility
% FORMAT str = spm_file(str,option)
% str        - character array, or cell array of strings
% option     - string of requested item - one among:
%              {'path', 'cpath', 'fpath', 'basename', 'ext', 'filename',
%              'number', 'shortxx', 'unique'}
%
% FORMAT str = spm_file(str,opt_key,opt_val,...)
% str        - character array, or cell array of strings
% opt_key    - string of targeted item - one among:
%              {'path', 'basename', 'ext', 'filename', 'number', 'prefix',
%              'suffix','link','local'}
% opt_val    - string of new value for feature
%__________________________________________________________________________
%
% Definitions:
%
% <cpath> = <fpath>filesep<filename>
% <filename> = <basename>.<ext><number>
% <path> = empty or full path or relative path
%
% 'shortxx' produces a string of at most xx characters long. If the input
% string is longer than n, then it is prefixed with '..' and the last xx-2
% characters are returned. If the input string is a path, the leading
% directories are replaced by './'.
%
% 'unique' returns an unique filename by adding an incremental _%03d suffix.
%__________________________________________________________________________
%
% Examples:
%
% spm_file('C:\data\myimage.nii', 'prefix','rp_', 'ext','.txt')
% returns 'C:\data\rp_myimage.txt' on a Windows platform
%
% spm_file({'/home/karl/software/spm8/spm.m'},'path','/home/karl/spm12')
% returns {'/home/karl/spm12/spm.m'}
%
% spm_file('/home/karl/software/spm12/spm.m','filename')
% returns 'spm.m', and
% spm_file('/home/karl/software/spm12/spm.m','basename')
% returns 'spm'
%
% spm_file('SPM.mat','fpath')
% returns '/home/karl/data/stats' (i.e. pwd), while
% spm_file('SPM.mat','path')
% returns '', and
% spm_file('SPM.mat','cpath')
% returns '/home/karl/data/stats/SPM.mat'
%__________________________________________________________________________
%
% See also: spm_fileparts, spm_select, spm_file_ext, spm_existfile
%__________________________________________________________________________
% Copyright (C) 2011-2017 Wellcome Trust Centre for Neuroimaging

% Guillaume Flandin
% $Id: spm_file.m 7110 2017-06-15 11:45:05Z guillaume $


needchar = ischar(str);
options = varargin;

str = cellstr(str);

%-Get item
%==========================================================================
if numel(options) == 1
    for n=1:numel(str)
        [pth,nam,ext,num] = spm_fileparts(deblank(str{n}));
        switch lower(options{1})
            case 'path'
                str{n} = pth;
            case 'basename'
                str{n} = nam;
            case 'ext'
                str{n} = ext(2:end