0001 function varargout = prt(varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 if nargin == 0,
0016 Action = 'StartUp';
0017 else
0018 Action = varargin{1};
0019 end
0020
0021 switch lower(Action)
0022
0023 case 'startup'
0024
0025
0026
0027 ok = check_installation;
0028 if ~ok
0029 beep
0030 fprintf('INSTALLATION PROBLEM!');
0031 return
0032 end
0033
0034
0035 prt('ASCIIwelcome');
0036
0037
0038
0039 if ~exist('prt_batch','file')
0040 addpath(fullfile(prt('Dir'),'batch'));
0041 end
0042
0043 if ~exist('prt_machine','file')
0044 pth_machines = fullfile(prt('Dir'),'machines');
0045 addpath(pth_machines);
0046
0047 ls_machinedir = list_subdir(pth_machines);
0048 for ii=1:numel(ls_machinedir)
0049 addpath(fullfile(pth_machines,ls_machinedir{ii}))
0050 end
0051 end
0052
0053 if ~exist('prt_checkAlphaNumUnder','file')
0054 addpath(fullfile(prt('Dir'),'utils'));
0055 end
0056
0057
0058 if ~exist('cfg_util','file')
0059 addpath(fullfile(spm('Dir'),'matlabbatch'));
0060 end
0061
0062
0063 cfg_get_defaults('cfg_util.genscript_run', @genscript_run);
0064 cfg_util('initcfg');
0065 clear prt_batch;
0066
0067
0068 prt_ui_main;
0069
0070
0071 fprintf('PRoNTo present working directory:\n\t%s\n',pwd)
0072
0073
0074
0075 case 'asciiwelcome'
0076
0077 disp( ' ');
0078 disp( ' ____ ____ _ ________ ');
0079 disp( ' / __ \/ __ \____ / | / /_ __/_ ___ ___ ');
0080 disp( ' / /_/ / /_/ / __ \/ |/ / / / __ \ _ _< /< /');
0081 disp( ' / ____/ _, _/ /_/ / /| / / / /_/ / | |/ / / / / ');
0082 disp( ' /_/ /_/ |_|\____/_/ |_/ /_/\____/ |___/_(_)_/ ');
0083 disp( ' ');
0084 disp( ' PRoNTo v1.1 - http://www.mlnl.cs.ucl.ac.uk/pronto ');
0085 fprintf('\n');
0086
0087
0088 case 'dir'
0089
0090
0091
0092 if nargin<2,
0093 Mfile='prt';
0094 else
0095 Mfile=varargin{2};
0096 end
0097 PRTdir = which(Mfile);
0098
0099 if isempty(PRTdir)
0100 if exist(Mfile,'file')==2
0101 PRTdir = Mfile;
0102 else
0103 error(['Can''t find ',Mfile,' on MATLABPATH']);
0104 end
0105 end
0106 PRTdir = fileparts(PRTdir);
0107 varargout = {PRTdir};
0108
0109
0110 otherwise
0111
0112 error('Unknown action string');
0113
0114 end
0115
0116 return
0117
0118
0119
0120
0121
0122
0123 function ok = check_installation
0124
0125
0126
0127 ok=1;
0128
0129 if exist('spm.m','file')
0130 if ~strcmpi(spm('ver'),'spm8')
0131 beep
0132 fprintf('\nERROR:\n')
0133 fprintf('\tSPM8 should be installed on your computer, and\n')
0134 fprintf('\tbe available on MATLABPATH!\n\n')
0135 ok = 0;
0136 end
0137 else
0138 beep
0139 fprintf('\nERROR:\n')
0140 fprintf('\tSPM8 should be installed on your computer, and\n')
0141 fprintf ('\tbe available on MATLABPATH!\n\n')
0142 ok = 0;
0143 end
0144
0145 return
0146
0147
0148 function lsdir = list_subdir(pth_dir,rejd)
0149
0150
0151
0152
0153 if nargin<2
0154 rejd = '.@_';
0155 end
0156 if nargin<1
0157 pth_dir = pwd;
0158 end
0159
0160 tmp = dir(pth_dir);
0161 ld = find([tmp.isdir]); ld([1 2]) = [];
0162 lsdir = {tmp(ld).name};
0163 if ~isempty(rejd)
0164 for ii=1:numel(rejd)
0165 lrej = find(strncmp(rejd(ii),lsdir,1));
0166 if ~isempty(lrej)
0167 lsdir(lrej) = [];
0168 end
0169 end
0170 end
0171
0172 return