function [spmPath, spm2Path, spm5Path] = nic_getSPMPath(P)
% Get the path of SPM (SPM2 or SPM5) to use from parameter (P)
%
% Useage: spmPath = nic_getSPMPath(P)
%
% Input: 
% 1. P - the parameter of format: 'analyze', 'nifti'
% Output:
% 1. spmPath: the path of SPM to use
%
%--------------------------------------------------------------------------
% Copyright (C) 2007 Neuroimage Computing Group, State Key Laboratory of
% Cognitive Neuroscience and Learning
%
% Guiwen Chen, gwenchill@gmail.com
% @(#)nic_getSPMPath.m  ver 1.0, 07/11/14

FilePath = which('nic_getSPMPath.m');

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

spm2Path = fullfile(giftPath, 'nic_spm2_files');
spm5Path = fullfile(giftPath, 'nic_spm5_files');

spmPath = spm5Path;

if ischar(P)
    if strcmpi(P, 'analyze')
        spmPath = spm2Path;	
    end   
end