function is_ok=cosmo_check_external(external, raise_)
% Checks whether a certain external toolbox exists, or list citation info
%
% is_ok=cosmo_check_external(external[, raise_])
%
% Inputs:
% external string or cell of strings. Currently supports:
% 'afni' AFNI matlab toolbox
% 'afni_bin' AFNI binaries present (unix-only)
% 'neuroelf' Neuroelf toolbox
% 'nifti' NIFTI toolbox
% 'fieldtrip' Fieldtrip
% 'libsvm' libSVM toolbox
% 'surfing' surfing toolbox
% 'gifti' GIfTI library for matlab
% 'xunit' xUnit unit test framework
% 'moxunit' MOxUnit unit test framework
% 'matlabsvm' SVM classifier in matlab stats
% toolbox (prior 2018a)
% 'matlabcsvm'
% 'svm' Either matlabsvm or libsvm
% '@{name}' Matlab toolbox {name}
% It can also be '-list', '-tic', '-toc',' or
% '-cite'; see below for their meaning.
% raise_ if true (the default), an error is raised if the
% external is not present.
%
% Returns:
% is_ok boolean indicating whether the external is
% present. A matlab toolbox must be prefixed
% by a '@'. If external is a cell if P elements,
% then the output is a Px1 boolean vector.
% Special switches allowed are:
% '-list': returns a cell of strings with
% the available externals
% '-tic': reset list of cached externals
% (see note below)
% '-toc': returns a cell of string of
% all externals queried so far
% '-cite': prints a list of publications to
% cite based on the output from
% '-toc'
%
% Examples:
% % see if the AFNI matlab toolbox is available, if not raise an error
% cosmo_check_external('afni')
%
% % see if libsvm and neuroelf are available, if not raise an error
% cosmo_check_external({'libsvm','neuroelf'});
%
% % see if libsvm and neuroelf and store the result in
% % the 2x1 boolean array is_ok. An error is not raised if
% % either is not present.
% is_ok=cosmo_check_external({'libsvm','neuroelf'},false);
%
% % see if the matlab 'stats' toolbox is available
% cosmo_check_external('@stats');
%
% % list the available externals
% cosmo_check_external('-list')
%
% % reset the list of cached externals, so that using '-cite' below
% % will only show externals checked since this reset
% cosmo_check_external('-tic')
%
% % check two externals
% cosmo_check_external({'afni','neuroelf'});
%
% % list the externals checked for since the last '-tic'
% cosmo_check_external('-toc')
%
% % list the publications associated with the externals
% cosmo_check_external('-cite');
%
% # For CoSMoMVPA's copyright information and license terms, #
% # see the COPYING file distributed with CoSMoMVPA. #