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_get_space.m
    path of file: ./repos/bspm/thirdparty/spm12
    
    the code of the file until where you have to start completion: function M = spm_get_space(P,M)

    
function M = spm_get_space(P,M)
% Get/set the voxel-to-world mapping of an image
% FORMAT M = spm_get_space(P)
%            spm_get_space(P,M)
% P - image filename
% M - voxel-to-world mapping
%__________________________________________________________________________
% Copyright (C) 1996-2015 Wellcome Trust Centre for Neuroimaging

% John Ashburner
% $Id: spm_get_space.m 6379 2015-03-16 13:27:26Z guillaume $


[pth,nam,ext,num] = spm_fileparts(P);
if ~isempty(num), n = str2num(num(2:end