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 519 2012-05-07 21:07:37Z cphillip $
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         % utils - dirty check for the moment
0053         if ~exist('prt_checkAlphaNumUnder','file')
0054             addpath(fullfile(prt('Dir'),'utils'));
0055         end
0056         
0057         % in particular SPM's directories: matlabbatch
0058         if ~exist('cfg_util','file')
0059             addpath(fullfile(spm('Dir'),'matlabbatch'));
0060         end
0061         
0062         % intialize the matlabbatch system
0063         cfg_get_defaults('cfg_util.genscript_run', @genscript_run);
0064         cfg_util('initcfg');
0065         clear prt_batch;
0066         
0067         % launch the main GUI
0068         prt_ui_main;
0069         
0070         % print present working directory
0071         fprintf('PRoNTo present working directory:\n\t%s\n',pwd)
0072         
0073         
0074         %==================================================================
0075     case 'asciiwelcome'                       %-ASCII PRoNTo banner welcome
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'                          %-Identify specific (SPM) directory
0089         %==================================================================
0090         % prt('Dir',Mfile)
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)             %-Not found or full pathname given
0100             if exist(Mfile,'file')==2  %-Full pathname
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                                       %-Unknown action string
0111         %==================================================================
0112         error('Unknown action string');
0113         
0114 end
0115 
0116 return
0117 
0118 %=======================================================================
0119 %% SUBFUNCTIONS
0120 %=======================================================================
0121 
0122 %=======================================================================
0123 function ok = check_installation
0124 % function to check installation state of toolbox,
0125 % particullarly the SPM path setup
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 % function that returns the list of subdirectories of a directory,
0150 % rejection those beginning with some characters ('.', '@' and '_' by
0151 % default)
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

Generated on Sun 20-May-2012 13:24:48 by m2html © 2005