function  install_utils

%INSTALL_UTILITIES -- Add various utilities to the MATLAB path
%
%  * ANOVA Toolbox                         Ver 1.0    20-Dec-2002
%  * ACT-R Base-Level Activation Toolbox   Ver 2.0    12-Feb-2006
%  * General Utilities Toolbox             Ver 1.3    06-Jun-2006
%  * Image-Processing Utilities Toolbox    Ver 1.4    06-Dec-2007
%  * Nominal Statistics Toolbox            Ver 1.2    21-Oct-2005
%  * Parameter Search Toolbox              Ver 1.2    16-Aug-2007
%  * PolarGraph Utilities Toolbox          Ver 1.0    02-Dec-2004
%  * Regression Utilities Toolbox          Ver 1.0    21-Oct-2005
%  * Subject-Database Toolbox              Ver 1.1    11-Mar-2005
%
% See also ADDPATH, PERCLEARN_INSTALL, PATH2RC, REHASH.

% Original coding by Alex Petrov, Ohio State University
% $Revision: 1.1.1 $  $Date: 2008-12-12 $
%
% Part of the utils toolbox version 1.1 for MATLAB version 5 and up.
% http://alexpetrov.com/softw/utils/
% Copyright (c) Alexander Petrov 1999-2008, http://alexpetrov.com
% Please read the LICENSE and NO WARRANTY statement in ./utils_license.m

%-- Print herald
more off ;
home ;

fprintf('\nHello!\n\n') ;

fprintf('Matlab UTILS ver. 1.1.1, released 22 Feb 2008.\n\n') ;

fprintf('Copyright (c) Alexander Petrov 1999-2008, http://alexpetrov.com \n\n') ;

fprintf('This software is freely available and freely redistributable,\n') ;
fprintf('according to the conditions of the GNU General Public License.\n') ;
fprintf('The full text of the GNU General Public License is available at\n') ;
fprintf('the Free Software Foundation website (http://www.fsf.org) and is\n') ;
fprintf('reproduced in utils_license.m. In brief, the GNU GPL provisions are:\n\n') ;

fprintf('You may not distribute the software, in whole or in part, in\n') ;
fprintf('conjunction with proprietary code. That means you ONLY have my\n') ;
fprintf('permission to distribute a program that uses my code IF you also\n') ;
fprintf('make freely available (under the terms of the GNU GPL) the source\n') ;
fprintf('code for your whole project. You may not pass on the software to\n') ;
fprintf('another party in its current form or any altered, embellished or\n') ;
fprintf('reduced form, without acknowledging the author and including a\n') ;
fprintf('copy of the GNU General Public License.\n\n') ;

fprintf('The software is distributed in the hope that it will be useful,\n') ;
fprintf('but WITHOUT ANY WARRANTY; without even the implied warranty of\n') ;
fprintf('MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n') ;
fprintf('See the GNU General Public License for more details.\n\n') ;

reply = lower(input('Do you agree with this license agreement? y/n (y): ','s')) ;
if (isempty(reply))  reply = 'y' ; end
if (reply(1)~='y')
    fprintf('\nOK. No changes were made to the path. Good bye!\n\n') ;
    return
end

fprintf('\nThis script will install the following utilities to the Matlab path.\n') ;
fprintf(' * ANOVA Toolbox                         Ver 1.0    20-Dec-2002\n') ;
fprintf(' * ACT-R Base-Level Activation Toolbox   Ver 2.0    12-Feb-2006\n') ;
fprintf(' * General Utilities Toolbox             Ver 1.3    06-Jun-2006\n') ;
fprintf(' * Image-Processing Utilities Toolbox    Ver 1.4    06-Dec-2007\n') ;
fprintf(' * Nominal Statistics Toolbox            Ver 1.2    21-Oct-2005\n') ;
fprintf(' * Parameter Search Toolbox              Ver 1.2    16-Aug-2007\n') ;
fprintf(' * PolarGraph Utilities Toolbox          Ver 1.0    02-Dec-2004\n') ;
fprintf(' * Regression Utilities Toolbox          Ver 1.0    21-Oct-2005\n') ;
fprintf(' * Subject-Database Toolbox              Ver 1.1    11-Mar-2005\n') ;

fprintf('\nMost of these contain a few one-line functions, but they can\n') ;
fprintf('enhance one''s productivity considerably.  There are also some\n') ;
fprintf('non-trivial algorithms, such as locally weighted regression.\n') ;
fprintf('Each "Toolbox" has its own Contents file -- go there for details.\n\n') ;

reply = lower(input('Do you want to proceed? y/n (y): ','s')) ;
if (isempty(reply))  reply = 'y' ; end
if (reply(1)~='y')
    fprintf('\nOK. No changes were made to the path. Good bye!\n\n') ;
    return
end

%-- Path name -- edit this if necessary
utils_path = fileparts(which('install_utils')) ;  % e.g. '/work/utils'

%-- Now do the real work
s = fullfile(utils_path,'sbjdb') ;
addpath(s) ;
fprintf('\nSubject-Database Toolbox added to the path: %s\n',s) ;

s = fullfile(utils_path,'regression') ;
addpath(s) ;
fprintf('Regressopm Utilities Toolbox added to the path: %s\n',s) ;

s = fullfile(utils_path,'polargr') ;
addpath(s) ;
fprintf('PolarGraph Utilities Toolbox added to the path: %s\n',s) ;

s = fullfile(utils_path,'paramsearch') ;
addpath(s) ;
fprintf('Parameter Search Toolbox added to the path: %s\n',s) ;

s = fullfile(utils_path,'nomstats') ;
addpath(s) ;
fprintf('Nominal Statistics Toolbox added to the path: %s\n',s) ;

s = fullfile(utils_path,'image') ;
addpath(s) ;
fprintf('Image-Processing Utilities Toolbox added to the path: %s\n',s) ;

s = fullfile(utils_path,'general') ;
addpath(s) ;
fprintf('General Utilities Toolbox added to the path: %s\n',s) ;

s = fullfile(utils_path,'base_act') ;
addpath(s) ;
fprintf('ACT-R Base-Level Activation Toolbox added to the path: %s\n',s) ;

s = fullfile(utils_path,'anova') ;
addpath(s) ;
fprintf('ANOVA Toolbox added to the path: %s\n\n',s) ;

%-- Save and finish
if (which('savepath'))
    notsaved = savepath ;  % Save the changes for future Matlab sessions.
else
    notsaved = path2rc ;   % deprecated version of SAVEPATH
end
if (notsaved)
    fprintf('\nThere were problems saving the path. ') ;
    fprintf('Manual intervention seems necessary.\n\n') ;
else
    rehash toolbox ;   % Make sure the new settings are in effect.
    rehash toolboxcache ;
    fprintf('The updated path saved to MATLAB''s pathdef.m file.\n\n') ;
end

fprintf('Updates may be available at http://alexpetrov.com/softw/ \n') ;
fprintf('Thank you for your interest in this software. I hope you find it useful.\n') ;
fprintf('  -- Alex Petrov\n\n') ;

%---  Return no values
%%%%% End of file INSTALL_UTILS.M
