0001 function varargout = prt(varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 global PRT_INIT
0020 if nargin == 0,
0021 Action = 'StartUp';
0022 else
0023 Action = varargin{1};
0024 end
0025
0026 switch lower(Action)
0027
0028 case 'startup'
0029
0030
0031
0032 prt('ASCIIwelcome');
0033
0034
0035
0036 if ~exist('prt_cfg_batch','file')
0037 addpath(fullfile(prt('Dir'),'batch'));
0038 end
0039
0040 if ~exist('prt_machine','file')
0041 pth_machines = fullfile(prt('Dir'),'machines');
0042 addpath(pth_machines);
0043
0044
0045 ls_machinedir = list_subdir(pth_machines);
0046 for ii=1:numel(ls_machinedir)
0047 gpath_ii = genpath(fullfile(pth_machines,ls_machinedir{ii}));
0048 gpath_ii = clean_gpath(gpath_ii);
0049 addpath(gpath_ii)
0050 end
0051 end
0052
0053
0054 if ~exist('prt_checkAlphaNumUnder','file')
0055 addpath(fullfile(prt('Dir'),'utils'));
0056 end
0057
0058
0059 ok = check_installation;
0060 if ~ok
0061 beep
0062 fprintf('INSTALLATION PROBLEM!');
0063 return
0064 end
0065
0066
0067 if ~exist('cfg_util','file')
0068 addpath(fullfile(spm('Dir'),'matlabbatch'));
0069 end
0070
0071
0072 cfg_get_defaults('cfg_util.genscript_run', @genscript_run);
0073 cfg_util('initcfg');
0074 clear prt_batch;
0075
0076
0077 spm_select('prevdirs',[spm('Dir') filesep]);
0078 spm_select('prevdirs',[prt('Dir') filesep]);
0079
0080
0081 if nargin<2 || ~strcmp(varargin{2},'nogui')
0082 prt_ui_main;
0083 end
0084
0085
0086 fprintf('PRoNTo present working directory:\n\t%s\n',pwd)
0087
0088
0089 PRT_INIT = true;
0090
0091
0092 case 'asciiwelcome'
0093
0094 disp( ' ');
0095 disp( ' ____ ____ _ ________ ___ ____ ');
0096 disp( ' / __ \/ __ \____ / | / /_ __/___ _ _|__ \ / __ \');
0097 disp( ' / /_/ / /_/ / __ \/ |/ / / / / __ \ | | / /_/ / / / / /');
0098 disp( ' / ____/ _, _/ /_/ / /| / / / / /_/ / | |/ / __/_/ /_/ / ');
0099 disp( ' /_/ /_/ |_|\____/_/ |_/ /_/ \____/ |___/____(_)____/ ');
0100 disp( ' ');
0101 disp( ' PRoNTo v2.0 - http://www.mlnl.cs.ucl.ac.uk/pronto ');
0102 fprintf('\n');
0103
0104
0105 case 'dir'
0106
0107
0108
0109 if nargin<2,
0110 Mfile = 'prt';
0111 else
0112 Mfile = varargin{2};
0113 end
0114 PRTdir = which(Mfile);
0115
0116 if isempty(PRTdir)
0117 if exist(Mfile,'file')==2
0118 PRTdir = Mfile;
0119 else
0120 error(['Can''t find ',Mfile,' on MATLABPATH']);
0121 end
0122 end
0123 PRTdir = fileparts(PRTdir);
0124 varargout = {PRTdir};
0125
0126
0127 case 'ver'
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142 if nargin ~= 2,
0143 ReDo = false;
0144 else
0145 ReDo = logical(varargin{3});
0146 end
0147
0148 v = get_version(ReDo);
0149 varargout = {v.Release v.Version};
0150
0151
0152 otherwise
0153
0154 error('Unknown action string');
0155
0156 end
0157
0158 return
0159
0160
0161
0162
0163
0164
0165 function ok = check_installation
0166
0167
0168
0169 ok = true;
0170
0171
0172 if exist('spm.m','file')
0173 [SPMver, SPMrel] = spm('Ver');
0174 if (~(strcmpi(SPMver,'spm8') && str2double(SPMrel)>8.5)) && ...
0175 isempty(regexpi(SPMver,'spm12'))
0176 beep
0177 fprintf('\nERROR:\n')
0178 fprintf('\tThe *latest* version of SPM8 or SPM12 should be installed on your computer,\n')
0179 fprintf('\tand be available on MATLABPATH!\n\n')
0180 ok = false;
0181 end
0182 else
0183 beep
0184 fprintf('\nERROR:\n')
0185 fprintf('\tThe *latest* version of SPM8 or SPM12 should be installed on your computer,\n')
0186 fprintf('\tand be available on MATLABPATH!\n\n')
0187 ok = false;
0188 end
0189
0190
0191
0192
0193
0194 dumb = which('svmtrain');
0195 if ~isempty(strfind(dumb,'libsvm'))
0196 disp('SVM path: OK')
0197 flag=1;
0198 elseif ~isempty(strfind(dumb,'biolearning'))
0199 flag=0;
0200 else
0201 flag=2;
0202 end
0203
0204
0205 if ~flag
0206 pth_machines = fullfile(prt('Dir'),'machines');
0207 addpath(pth_machines);
0208
0209
0210 ls_machinedir = list_subdir(pth_machines);
0211 for ii=1:numel(ls_machinedir)
0212 gpath_ii = genpath(fullfile(pth_machines,ls_machinedir{ii}));
0213 gpath_ii = clean_gpath(gpath_ii);
0214 addpath(gpath_ii)
0215 end
0216 dumb = which('svmtrain');
0217 if isempty(strfind(dumb,'libsvm'))
0218 flag=2;
0219 elseif ~isempty(strfind(dumb,'biolearning'))
0220 flag = 2;
0221 disp('PRoNTo was found under the biostats toolbox, please correct path')
0222 disp('SVM path: OK')
0223 else
0224 flag =1;
0225 end
0226 end
0227
0228 if flag ==2
0229 pth_machines = fullfile(prt('Dir'),'machines');
0230 ls_machinedir = list_subdir(pth_machines);
0231 for i=1:length(ls_machinedir)
0232 if ~isempty(strfind(ls_machinedir{i},'libsvm'))
0233 pfn= fullfile(pth_machines,ls_machinedir{i});
0234 dirtorem=cd;
0235 cd(pfn)
0236 cd matlab
0237 make;
0238 cd(dirtorem)
0239 end
0240 end
0241 dumb = which('svmtrain');
0242 if isempty(strfind(dumb,'libsvm'))
0243
0244 beep
0245 warning('PRoNTo:SVMcompilation', ...
0246 ['SVM path not recognized. Please check that: \n', ...
0247 '- PRoNTo''directory was added *without* all subfolders \n',...
0248 '- PRoNTo is above the biostats Matlab toolbox \n',...
0249 'Otherwise, the routines surely need to be re-compiled for your OS \n',...
0250 'Please look on the web or ask on the mailing list for assistance'])
0251 end
0252 end
0253
0254
0255 dumb = which('solve_chol');
0256 if ~isempty(dumb) && ~isempty(strfind(dumb,'.mex'))
0257 disp('GP path: OK')
0258 else
0259 beep
0260 disp('GP not compiled: routines will work but be slower')
0261 end
0262
0263
0264
0265
0266
0267
0268
0269
0270
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281 return
0282
0283
0284 function lsdir = list_subdir(pth_dir,rejd)
0285
0286
0287
0288
0289
0290 if nargin<2
0291 rejd = '.@_';
0292 end
0293 if nargin<1
0294 pth_dir = pwd;
0295 end
0296
0297 tmp = dir(pth_dir);
0298 ld = find([tmp.isdir]); ld([1 2]) = [];
0299 lsdir = {tmp(ld).name};
0300 if ~isempty(rejd)
0301 for ii=1:numel(rejd)
0302 lrej = find(strncmp(rejd(ii),lsdir,1));
0303 if ~isempty(lrej)
0304 lsdir(lrej) = [];
0305 end
0306 end
0307 end
0308
0309 return
0310
0311
0312 function v = get_version(ReDo)
0313
0314 persistent PRoNTo_VER;
0315 v = PRoNTo_VER;
0316 if isempty(PRoNTo_VER) || (nargin > 0 && ReDo)
0317 v = struct('Name','','Version','','Release','','Date','');
0318 try
0319 vfile = fullfile(prt('Dir'),'prt_contents.m');
0320 fid = fopen(vfile,'rt');
0321 if fid == -1, error(str); end
0322 l1 = fgetl(fid); l2 = fgetl(fid);
0323 fclose(fid);
0324 l1 = strtrim(l1(2:end)); l2 = strtrim(l2(2:end));
0325 t = textscan(l2,'%s','delimiter',' '); t = t{1};
0326 v.Name = l1; v.Date = t{4};
0327 v.Version = t{2}; v.Release = t{3}(2:end-1);
0328 catch
0329 error('PRoNTo:getversion', ...
0330 'Can''t obtain PRoNTo Revision information.');
0331 end
0332 PRoNTo_VER = v;
0333 end
0334
0335 return
0336
0337
0338 function gpath = clean_gpath(gpath,rejd)
0339
0340
0341
0342
0343
0344
0345 if nargin<2
0346 rejd = {'.svn'};
0347 end
0348 if nargin<1
0349 return
0350 end
0351
0352 if numel(rejd)>1
0353
0354 for ii=1:numel(rejd)
0355 gpath = clean_gpath(gpath,rejd{ii});
0356 end
0357 else
0358
0359 l_col = strfind(gpath,':');
0360 for ii=numel(l_col):-1:1
0361 if ii>1
0362 pth_bit = [l_col(ii-1)+1 l_col(ii)];
0363 else
0364 pth_bit = [1 l_col(ii)];
0365 end
0366 if ~isempty(strfind(gpath(pth_bit(1):pth_bit(2)),rejd{1}))
0367
0368 gpath(pth_bit(1):pth_bit(2)) = [];
0369 end
0370 end
0371 end
0372
0373 return