Home > . > prt.m

prt

PURPOSE ^

Pattern Recognition for Neuroimaging Toolbox, PRoNTo.

SYNOPSIS ^

function varargout = prt(varargin)

DESCRIPTION ^

 Pattern Recognition for Neuroimaging Toolbox, PRoNTo.

 This function initializes things for PRoNTo and provides some low level
 functionalities

_______________________________________________________________________
 Copyright (C) 2011 Machine Learning & Neuroimaging Laboratory

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function varargout = prt(varargin)
0002 % Pattern Recognition for Neuroimaging Toolbox, PRoNTo.
0003 %
0004 % This function initializes things for PRoNTo and provides some low level
0005 % functionalities
0006 %
0007 %_______________________________________________________________________
0008 % Copyright (C) 2011 Machine Learning & Neuroimaging Laboratory
0009 
0010 % Written by Christophe Phillips
0011 % $Id: prt.m 571 2012-08-14 10:44:04Z schrouff $
0012 
0013 %-Format arguments
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'                                    % Startup the toolbox
0024     %==================================================================
0025         
0026         % check installation of toolbox and that of SPM8
0027         ok = check_installation;
0028         if ~ok
0029             beep
0030             fprintf('INSTALLATION PROBLEM!');
0031             return
0032         end
0033         
0034         % Welcome message
0035         prt('ASCIIwelcome');
0036         
0037         % add appropriate paths, if necessary
0038         % batch dir
0039         if ~exist('prt_batch','file')
0040             addpath(fullfile(prt('Dir'),'batch'));
0041         end
0042         % machines
0043         if ~exist('prt_machine','file')
0044             pth_machines = fullfile(prt('Dir'),'machines');
0045             addpath(pth_machines);
0046             % add each machine sub-directory
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         %check for compiled routines
0053         %svm
0054         dumb=which('svmtrain');
0055         if ~isempty(findstr('libsvm',dumb))
0056             disp('SVM path OK')
0057         else
0058             warning(['SVM path not recognized. Please check that: \n', ...
0059                 '-PRoNTo was added with all subfolders \n',...
0060                 '-PRoNTo is above the biostats Matlab toolbox \n',...
0061                 'Otherwise, the routines surely need to be re-compiled for your OS \n',...
0062                 'Please look on the web or ask on the mailing list for assistance'])
0063         end
0064         %GP
0065         dumb=which('solve_chol');
0066         if ~isempty(dumb) && ~isempty(findstr('.mex',dumb))
0067             disp('GP path: OK')
0068         else
0069             disp('GP not compiled: routines will work but be slower')
0070         end
0071         %RF
0072         dumb=which('rtenslearn_c');
0073         if ~isempty(dumb) || ~isempty(findstr('.mex',dumb))
0074             disp('RF path OK')
0075         else
0076             warning(['RF path not recognized. Please check that \n', ...
0077                 'PRoNTo was added with all subfolders \n',...
0078                 'Otherwise, the routines surely need to be re-compiled for your OS \n',...
0079                 'Please look on the web or ask on the mailing list for assistance'])
0080         end
0081 
0082         % utils - dirty check for the moment
0083         if ~exist('prt_checkAlphaNumUnder','file')
0084             addpath(fullfile(prt('Dir'),'utils'));
0085         end
0086         
0087         % in particular SPM's directories: matlabbatch
0088         if ~exist('cfg_util','file')
0089             addpath(fullfile(spm('Dir'),'matlabbatch'));
0090         end
0091         
0092         % intialize the matlabbatch system
0093         cfg_get_defaults('cfg_util.genscript_run', @genscript_run);
0094         cfg_util('initcfg');
0095         clear prt_batch;
0096         
0097         % launch the main GUI
0098         prt_ui_main;
0099         
0100         % print present working directory
0101         fprintf('PRoNTo present working directory:\n\t%s\n',pwd)
0102         
0103         
0104         %==================================================================
0105     case 'asciiwelcome'                       %-ASCII PRoNTo banner welcome
0106         %==================================================================
0107         disp( '                                                      ');
0108         disp( '     ____  ____        _   ________                   ');
0109         disp( '    / __ \/ __ \____  / | / /_  __/_         ___ ___  ');
0110         disp( '   / /_/ / /_/ / __ \/  |/ / / / __ \   _  _<  /<  /');
0111         disp( '  / ____/ _, _/ /_/ / /|  / / / /_/ /  | |/ / / / / ');
0112         disp( ' /_/   /_/ |_|\____/_/ |_/ /_/\____/   |___/_(_)_/  ');
0113         disp( '                                                      ');
0114         disp( '  PRoNTo v1.1 - http://www.mlnl.cs.ucl.ac.uk/pronto   ');
0115         fprintf('\n');
0116         
0117         %==================================================================
0118     case 'dir'                          %-Identify specific (SPM) directory
0119         %==================================================================
0120         % prt('Dir',Mfile)
0121         %------------------------------------------------------------------
0122         if nargin<2,
0123             Mfile='prt';
0124         else
0125             Mfile=varargin{2};
0126         end
0127         PRTdir = which(Mfile);
0128         
0129         if isempty(PRTdir)             %-Not found or full pathname given
0130             if exist(Mfile,'file')==2  %-Full pathname
0131                 PRTdir = Mfile;
0132             else
0133                 error(['Can''t find ',Mfile,' on MATLABPATH']);
0134             end
0135         end
0136         PRTdir    = fileparts(PRTdir);
0137         varargout = {PRTdir};
0138         
0139         %==================================================================
0140     otherwise                                       %-Unknown action string
0141         %==================================================================
0142         error('Unknown action string');
0143         
0144 end
0145 
0146 return
0147 
0148 %=======================================================================
0149 %% SUBFUNCTIONS
0150 %=======================================================================
0151 
0152 %=======================================================================
0153 function ok = check_installation
0154 % function to check installation state of toolbox,
0155 % particullarly the SPM path setup
0156 
0157 ok=1;
0158 
0159 if exist('spm.m','file')
0160     if ~strcmpi(spm('ver'),'spm8')
0161         beep
0162         fprintf('\nERROR:\n')
0163         fprintf('\tSPM8 should be installed on your computer, and\n')
0164         fprintf('\tbe available on MATLABPATH!\n\n')
0165         ok = 0;
0166     end
0167 else
0168     beep
0169     fprintf('\nERROR:\n')
0170     fprintf('\tSPM8 should be installed on your computer, and\n')
0171     fprintf ('\tbe available on MATLABPATH!\n\n')
0172     ok = 0;
0173 end
0174 
0175 return
0176 
0177 %=======================================================================
0178 function lsdir = list_subdir(pth_dir,rejd)
0179 % function that returns the list of subdirectories of a directory,
0180 % rejection those beginning with some characters ('.', '@' and '_' by
0181 % default)
0182 
0183 if nargin<2
0184     rejd = '.@_';
0185 end
0186 if nargin<1
0187     pth_dir = pwd;
0188 end
0189 
0190 tmp = dir(pth_dir);
0191 ld = find([tmp.isdir]); ld([1 2]) = [];
0192 lsdir = {tmp(ld).name};
0193 if ~isempty(rejd)
0194     for ii=1:numel(rejd)
0195         lrej = find(strncmp(rejd(ii),lsdir,1));
0196         if ~isempty(lrej)
0197             lsdir(lrej) = [];
0198         end
0199     end
0200 end
0201     
0202 return

Generated on Mon 03-Sep-2012 18:07:18 by m2html © 2005