function [spmPath, spm2Path, spm5Path] = icatb_getSPMPath(P)

giftFile = which('gift.m');

[giftPath, fileN, extn] = fileparts(giftFile);

spm2Path = fullfile(giftPath, 'icatb_spm2_files');
spm5Path = fullfile(giftPath, 'icatb_spm5_files');

spmPath = spm2Path;

if ischar(P)
    
    if ~strcmpi(P, '.img')
        spmPath = spm5Path;
    end
    
elseif isstruct(P)
    
    if strcmpi(class(P(1).private), 'read_nifti')
        spmPath = spm5Path;
    end
    
else
    error('Check the variable passed to SPM path');
    
end