Home > rest_20090422 > rest_spm5_files > nic_spm.m

nic_spm

PURPOSE ^

SPM: Statistical Parametric Mapping (startup function)

SYNOPSIS ^

function varargout=nic_spm(varargin)

DESCRIPTION ^

 SPM: Statistical Parametric Mapping (startup function)
_______________________________________________________________________
  ___  ____  __  __
 / __)(  _ \(  \/  )  
 \__ \ )___/ )    (   Statistical Parametric Mapping
 (___/(__)  (_/\/\_)  SPM - http://www.fil.ion.ucl.ac.uk/spm/
_______________________________________________________________________

 SPM (Statistical Parametric Mapping) is a package for the analysis
 functional brain mapping experiments. It is the in-house package of
 the Wellcome Department of Cognitive Neurology, and is available to
 the scientific community as copyright freeware under the terms of the
 GNU General Public Licenic_e.
 
 Theoretical, computational and other details of the package are
 available in SPM's "Help" facility. This can be launic_hed from the
 main SPM Menu window using the "Help" button, or directly from the
 command line using the command `spm_help`.

 Details of this release are availiable via the "About SPM" help topic
 (file spm.man), accessible from the SPM splash screen.  (Or type
 `spm_help spm.man` in the MatLab command window)
 
 This spm function initialises the default parameters, and displays a
 splash screen with buttons leading to the PET(SPECT) & fMRI
 modalities Alternatively, `spm('pet')` and `spm('fmri')`
 (equivalently `spm pet` and `spm mri`) lead directly to the respective
 modality interfaces.

 Onic_e the modality is chosen, (and it can be toggled mid-session) the
 SPM user interface is displayed. This provides a constant visual
 environment in which data analysis is implemented. The layout has
 been designed to be simple and at the same time show all the
 facilities that are available. The interface consists of three
 windows: A menu window with pushbuttons for the SPM routines (each
 button has a 'CallBack' string which launic_hes the appropriate
 function/script); A blank panel used for interaction with the user;
 And a graphics figure with various editing and print facilities (see
 spm_figure.m). (These windows are 'Tag'ged 'Menu', 'Interactive', and
 'Graphics' respectively, and should be referred to by their tags
 rather than their figure numbers.)

 Further interaction with the user is (mainly) via questioning in the
 'Interactive' window (managed by spm_input), and file selection
 (managed by spm_select). See the help on spm_input.m and spm_select.m for
 details on using these functions.

 If a "message of the day" file named spm_motd.man exists in the SPM
 directory (alongside spm.m) then it is displayed in the Graphics
 window on startup.

 Arguments to this routine (spm.m) lead to various setup facilities,
 mainly of use to SPM power users and programmers. See programmers
 FORMAT & help in the main body of spm.m

_______________________________________________________________________
 SPM is developed by members and collaborators of the
 Wellcome Department of Imaging Neuroscienic_e

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

DOWNLOAD ^

nic_spm.m

SOURCE CODE ^

0001 function varargout=nic_spm(varargin)
0002 % SPM: Statistical Parametric Mapping (startup function)
0003 %_______________________________________________________________________
0004 %  ___  ____  __  __
0005 % / __)(  _ \(  \/  )
0006 % \__ \ )___/ )    (   Statistical Parametric Mapping
0007 % (___/(__)  (_/\/\_)  SPM - http://www.fil.ion.ucl.ac.uk/spm/
0008 %_______________________________________________________________________
0009 %
0010 % SPM (Statistical Parametric Mapping) is a package for the analysis
0011 % functional brain mapping experiments. It is the in-house package of
0012 % the Wellcome Department of Cognitive Neurology, and is available to
0013 % the scientific community as copyright freeware under the terms of the
0014 % GNU General Public Licenic_e.
0015 %
0016 % Theoretical, computational and other details of the package are
0017 % available in SPM's "Help" facility. This can be launic_hed from the
0018 % main SPM Menu window using the "Help" button, or directly from the
0019 % command line using the command `spm_help`.
0020 %
0021 % Details of this release are availiable via the "About SPM" help topic
0022 % (file spm.man), accessible from the SPM splash screen.  (Or type
0023 % `spm_help spm.man` in the MatLab command window)
0024 %
0025 % This spm function initialises the default parameters, and displays a
0026 % splash screen with buttons leading to the PET(SPECT) & fMRI
0027 % modalities Alternatively, `spm('pet')` and `spm('fmri')`
0028 % (equivalently `spm pet` and `spm mri`) lead directly to the respective
0029 % modality interfaces.
0030 %
0031 % Onic_e the modality is chosen, (and it can be toggled mid-session) the
0032 % SPM user interface is displayed. This provides a constant visual
0033 % environment in which data analysis is implemented. The layout has
0034 % been designed to be simple and at the same time show all the
0035 % facilities that are available. The interface consists of three
0036 % windows: A menu window with pushbuttons for the SPM routines (each
0037 % button has a 'CallBack' string which launic_hes the appropriate
0038 % function/script); A blank panel used for interaction with the user;
0039 % And a graphics figure with various editing and print facilities (see
0040 % spm_figure.m). (These windows are 'Tag'ged 'Menu', 'Interactive', and
0041 % 'Graphics' respectively, and should be referred to by their tags
0042 % rather than their figure numbers.)
0043 %
0044 % Further interaction with the user is (mainly) via questioning in the
0045 % 'Interactive' window (managed by spm_input), and file selection
0046 % (managed by spm_select). See the help on spm_input.m and spm_select.m for
0047 % details on using these functions.
0048 %
0049 % If a "message of the day" file named spm_motd.man exists in the SPM
0050 % directory (alongside spm.m) then it is displayed in the Graphics
0051 % window on startup.
0052 %
0053 % Arguments to this routine (spm.m) lead to various setup facilities,
0054 % mainly of use to SPM power users and programmers. See programmers
0055 % FORMAT & help in the main body of spm.m
0056 %
0057 %_______________________________________________________________________
0058 % SPM is developed by members and collaborators of the
0059 % Wellcome Department of Imaging Neuroscienic_e
0060 
0061 %-SVN ID and authorship of this program...
0062 %-----------------------------------------------------------------------
0063 % Copyright (C) 2005 Wellcome Department of Imaging Neuroscienic_e
0064 
0065 % Andrew Holmes
0066 % $Id: spm.m 348 2005-12-01 07:39:48Z will $
0067 
0068 
0069 %=======================================================================
0070 % - FORMAT specifications for embedded CallBack functions
0071 %=======================================================================
0072 %( This is a multi function function, the first argument is an action  )
0073 %( string, specifying the particular action function to take. Recall   )
0074 %( MatLab's command-function duality: `spm Welcome` is equivalent to   )
0075 %( `spm('Welcome')`.                                                   )
0076 %
0077 % FORMAT spm
0078 % Defaults to spm('Welcome')
0079 %
0080 % FORMAT spm('Welcome')
0081 % Clears command window, deletes all figures, prints welcome banner and
0082 % splash screen, sets window defaults.
0083 %
0084 % FORMAT spm('AsciiWelcome')
0085 % Prints ASCII welcome banner in MatLab command window.
0086 %
0087 % FORMAT spm('PET') spm('FMRI')
0088 % Closes all windows and draws new Menu, Interactive, and Graphics
0089 % windows for an SPM session. The buttons in the Menu window launic_h the
0090 % main analysis routines.
0091 %
0092 % FORMAT Fmenu = spm('CreateMenuWin',Vis)
0093 % Creates SPM menu window, 'Tag'ged 'Menu'
0094 % F   - handle of figure created
0095 % Vis - Visibility, 'on' or 'off'
0096 %
0097 % Finter = FORMAT spm('CreateIntWin',Vis)
0098 % Creates an SPM Interactive window, 'Tag'ged 'Interactive'
0099 % F   - handle of figure created
0100 % Vis - Visibility, 'on' or 'off'
0101 %
0102 % FORMAT spm('ChMod',Modality)
0103 % Changes modality of SPM: Currently SPM supports PET & MRI modalities,
0104 % each of which have a slightly different Menu window and different
0105 % defaults. This function switches to the specified modality, setting
0106 % defaults and displaying the relevant buttons.
0107 %
0108 % FORMAT spm('defaults',Modality)
0109 % Sets default global variables for the specified modality.
0110 %
0111 % FORMAT [Modality,ModNum]=spm('CheckModality',Modality)
0112 % Checks the specified modality against those supported, returns
0113 % upper(Modality) and the Modality number, it's position in the list of
0114 % supported Modalities.
0115 %
0116 % FORMAT WS=spm('WinScale')
0117 % Returns ratios of current display dimensions to that of a 1152 x 900
0118 % Sun display. WS=[Xratio,Yratio,Xratio,Yratio]. Used for scaling other
0119 % GUI elements.
0120 % (function duplicated in spm_figure.m, repeated to reduce inter-dependenic_ies.)
0121 %
0122 % FORMAT [FS,sf] = spm('FontSize',FS)
0123 % FORMAT [FS,sf] = spm('FontSizes',FS)
0124 % Returns fontsizes FS scaled for the current display.
0125 % FORMAT sf = spm('FontScale')
0126 % Returns font scaling factor
0127 % FS     - (vector of) Font sizes to scale [default [1:36]]
0128 % sf     - font scaling factor (FS(out) = floor(FS(in)*sf)
0129 %
0130 % Rect = spm('WinSize',Win,raw)
0131 % Returns sizes and positions for SPM windows.
0132 % Win  - 'Menu', 'Interactive', 'Graphics', or '0'
0133 %      -  Window whose position is required. Only first character is
0134 %         examined. '0' returns size of root workspace.
0135 % raw  - If specified, then positions are for a 1152 x 900 Sun display.
0136 %        Otherwise the positions are scaled for the current display.
0137 %
0138 % FORMAT SPMdir=spm('Dir',Mfile)
0139 % Returns the directory containing the version of spm in use,
0140 % identified as the first in MATLABPATH containing the Mfile spm (this
0141 % file) (or Mfile if specified).
0142 %
0143 % FORMAT [v,c]=spm('Ver',Mfile,ReDo,Cache,Con)
0144 % Returns the current version (v) & copyright notice, extracted from
0145 % the top line of the Contents.m file in the directory containing the
0146 % currently used file Mfile (defaults on omission or empty to 'spm').
0147 %
0148 %-The version and copyright information are saved in a global
0149 % variable called [upper(spm_str_manip(Mfile,'rt')),'_VER'], as a
0150 % structure with fields 'v' and 'c'. This enables repeat use without
0151 % recomputation.
0152 %
0153 %-If Con [default (missing or empty) 1] is false, then the version
0154 % information is extracted from Mfile itself, rather than the
0155 % Contents.m file in the same directory. When using a Contents.m file,
0156 % the first line is read. For other files, the second line (the H1 help
0157 % line) is used. This is for consistenic_y with MatLab's ver and help
0158 % commands respectively. (This functionality enables toolboxes to be
0159 % identified by a function rather than a Contents.m file, allowing
0160 % installation in a directory which already has a Contents.m file.)
0161 %
0162 %-If Cache [default (missing or empty) 1] is true, then the version and
0163 % copyright information cached in the global variable
0164 % [upper(Mfile),'_VER'], as a structure with fields 'v' and 'c'. This
0165 % enables repeat use without recomputation.
0166 %
0167 %-If ReDo [default (missing or empty) 0] is true, then the version and
0168 % copyright information are recomputed (regardless of any stored global
0169 % data).
0170 %
0171 % FORMAT xTB = spm('TBs')
0172 % Identifies installed SPM toolboxes: SPM toolboxes are defined as the
0173 % contents of sub-directories of fullfile(spm('Dir'),'toolbox') - the
0174 % SPM toolbox installation directory. For SPM to pick a toolbox up,
0175 % there must be a single mfile in the directory whose name ends with
0176 % the toolbox directory name. (I.e. A toolbox called "test" would be in
0177 % the "test" subdirectory of spm('Dir'), with a single file named
0178 % *test.m.) This M-file is regarded as the launic_h file for the
0179 % toolbox.
0180 % xTB      - structure array containing toolbox definitions
0181 % xTB.name - name of toolbox (taken as toolbox directory name)
0182 % xTB.prog - launic_h program for toolbox
0183 % xTB.dir  - toolbox directory
0184 %
0185 % FORMAT spm('TBlaunic_h',xTB,i)
0186 % Launic_h a toolbox, prepending TBdir to path if necessary
0187 % xTB      - toolbox definition structure (i.e. from spm('TBs')
0188 % xTB.name - name of toolbox
0189 % xTB.prog - name of program to launic_h toolbox
0190 % xTB.dir  - toolbox directory (prepended to path if not on path)
0191 %
0192 % FORMAT [c,cName] = spm('Colour')
0193 % Returns the RGB triple and a description for the current en-vogue SPM
0194 % colour, the background colour for the Menu and Help windows.
0195 %
0196 % FORMAT [v1,v2,...] = spm('GetGlobal',name1,name2,...)
0197 % Returns values of global variables (without declaring them global)
0198 % name1, name2,... - name strings of desired globals
0199 % a1, a2,...       - corresponding values of global variables with given names
0200 %                    ([] is returned as value if global variable doesn't exist)
0201 %
0202 % FORMAT CmdLine = spm('CmdLine',CmdLine)
0203 % Command line SPM usage?
0204 % CmdLine (input)  - CmdLine preferenic_e
0205 %                    [defaults (missing or empty) to global defaults.cmdline,]
0206 %                    [if it exists, or 0 (GUI) otherwise.                    ]
0207 % CmdLine (output) - true if global CmdLine if true,
0208 %                    or if on a terminal with no support for graphics windows.
0209 %
0210 % FORMAT v = spm('MLver')
0211 % Returns MatLab version, trunic_ated to major & minor revision numbers
0212 %
0213 % FORMAT spm('SetCmdWinLabel',WinStripe,IconLabel)
0214 % Sets the names on the headers and icons of Sun command tools.
0215 % WinStripe defaults to a summary line identifying the user, host and
0216 % MatLab version; IconLabel to 'MatLab'.
0217 %
0218 % FORMAT spm('PopUpCB',h)
0219 % Callback handler for PopUp UI menus with multiple callbacks as cellstr UserData
0220 %
0221 % FORMAT str = spm('GetUser',fmt)
0222 % Returns current users login name, extracted from the hosting environment
0223 % fmt   - format string: If USER is defined then sprintf(fmt,USER) is returned
0224 %
0225 % FORMAT spm('Beep')
0226 % plays the keyboard beep!
0227 %
0228 % FORMAT spm('time')
0229 % Returns the current time and date as hh:mm dd/mm/yyyy
0230 %
0231 % FORMAT spm('Pointer',Pointer)
0232 % Changes pointer on all SPM (HandleVisible) windows to type Pointer
0233 % Pointer defaults to 'Arrow'. Robust to absenic_e of windows
0234 %
0235 % FORMAT h = spm('alert',Message,Title,CmdLine,wait)
0236 % FORMAT h = spm('alert"',Message,Title,CmdLine,wait)
0237 % FORMAT h = spm('alert*',Message,Title,CmdLine,wait)
0238 % FORMAT h = spm('alert!',Message,Title,CmdLine,wait)
0239 % Displays an alert, either in a GUI msgbox, or as text in the command window.
0240 %  ( 'alert"' uses the 'help' msgbox icon, 'alert*' the )
0241 %  ( 'error' icon, 'alert!' the 'warn' icon             )
0242 % Message - string (or cellstr) containing message to print
0243 % Title   - title string for alert
0244 % CmdLine - CmdLine preferenic_e [default spm('CmdLine')]
0245 %         - If CmdLine is complex, then a CmdLine alert is always used,
0246 %           possibly in addition to a msgbox (the latter according
0247 %           to spm('CmdLine').)
0248 % wait    - if true, waits until user dismisses GUI / confirms text alert
0249 %           [default 0] (if doing both GUI & text, waits on GUI alert)
0250 % h       - handle of msgbox created, empty if CmdLine used
0251 %
0252 % FORMAT SPMid = spm('FnBanner', Fn,FnV)
0253 % Prints a function start banner, for version FnV of function Fn, & datestamps
0254 % FORMAT SPMid = spm('SFnBanner',Fn,FnV)
0255 % Prints a sub-function start banner
0256 % FORMAT SPMid = spm('SSFnBanner',Fn,FnV)
0257 % Prints a sub-sub-function start banner
0258 % Fn    - function name (string)
0259 % FnV   - function version (string)
0260 % SPMid - ID string: [SPMver: Fn (FnV)]
0261 %
0262 % FORMAT [Finter,Fgraph,CmdLine] = spm('FnUIsetup',Iname,bGX,CmdLine)
0263 % Robust UIsetup procedure for functions:
0264 %   Returns handles of 'Interactive' and 'Graphics' figures.
0265 %   Creates 'Interactive' figure if ~CmdLine, creates 'Graphics' figure if bGX.
0266 % Iname   - Name for 'Interactive' window
0267 % bGX     - Need a Graphics window? [default 1]
0268 % CmdLine - CommandLine usage? [default spm('CmdLine')]
0269 % Finter  - handle of 'Interactive' figure
0270 % Fgraph  - handle of 'Graphics' figure
0271 % CmdLine - CommandLine usage?
0272 %
0273 % FORMAT F = spm('FigName',Iname,F,CmdLine)
0274 % Set name of figure F to "SPMver (User): Iname" if ~CmdLine
0275 % Robust to absenic_e of figure.
0276 % Iname      - Name for figure
0277 % F (input)  - Handle (or 'Tag') of figure to name [default 'Interactive']
0278 % CmdLine    - CommandLine usage? [default spm('CmdLine')]
0279 % F (output) - Handle of figure named
0280 %
0281 % FORMAT spm('GUI_FileDelete')
0282 % CallBack for GUI for file deletion, using spm_select and confirmation dialogs
0283 %
0284 % FORMAT Fs = spm('Show')
0285 % Opens all SPM figure windows (with HandleVisibility) using `figure`.
0286 %   Maintains current figure.
0287 % Fs - vector containing all HandleVisible figures (i.e. get(0,'Children'))
0288 %
0289 % FORMAT spm('Clear',Finter, Fgraph)
0290 % Clears and resets SPM-GUI, clears and timestamps MatLab command window
0291 % Finter  - handle or 'Tag' of 'Interactive' figure [default 'Interactive']
0292 % Fgraph  - handle or 'Tag' of 'Graphics' figure [default 'Graphics']
0293 %
0294 % FORMAT spm('Help',varargin)
0295 % Merely a gateway to spm_help(varargin) - so you can type "spm help"
0296 %
0297 %_______________________________________________________________________
0298 
0299 
0300 %-Parameters
0301 %-----------------------------------------------------------------------
0302 Modalities = {'PET','FMRI','EEG'};
0303 
0304 %-Format arguments
0305 %-----------------------------------------------------------------------
0306 if nargin == 0, Action='Welcome'; else, Action = varargin{1}; end
0307 
0308 
0309 %=======================================================================
0310 switch lower(Action), case 'welcome'             %-Welcome splash screen
0311 %=======================================================================
0312 
0313 nic_spm_defaults;
0314 global defaults
0315 if isfield(defaults,'modality'), nic_spm(defaults.modality); return; end;
0316 
0317 %-Open startup window, set window defaults
0318 %-----------------------------------------------------------------------
0319 if str2double(version('-release'))>=14,
0320     S = get(0, 'MonitorPosition');
0321     S = S(1,:);
0322 else
0323     S  = get(0,'ScreenSize');
0324 end;
0325 
0326 if all(S==1), error('Can''t open any graphics windows...'), end
0327 [SPMver,SPMc] = nic_spm('Ver','',1);
0328 PF = nic_spm_platform('fonts');
0329 
0330 F = figure('IntegerHandle','off',...
0331     'Name',sprintf('%s%s',nic_spm('ver'),nic_spm('GetUser',' (%s)')),...
0332     'NumberTitle','off',...
0333     'Tag','Welcome',...
0334     'Position',[S(3)/2-300,S(4)/2-140,500,280],...
0335     'Resize','off',...
0336     'Pointer','Watch',...
0337     'Color',[1 1 1]*.8,...
0338     'MenuBar','none',...
0339     'DefaultUicontrolFontName',PF.helvetica,...
0340     'HandleVisibility','off',...
0341     'Visible','off');
0342 
0343 %-Text
0344 %-----------------------------------------------------------------------
0345 hA = axes('Parent',F,'Position',[0 0 100/500 280/280],'Visible','Off');
0346 text(0.5,0.5,'SPM',...
0347     'Parent',hA,...
0348     'FontName',PF.times,'FontSize',96,...
0349     'FontAngle','Italic','FontWeight','Bold',...
0350     'Rotation',90,...
0351     'VerticalAlignment','Middle','HorizontalAlignment','Center',...
0352     'Color',[1 1 1]*.6);
0353 
0354 uicontrol(F,'Style','Text','Position',[110 245 390 030],...
0355     'String','Statistical Parametric Mapping',...
0356     'FontName',PF.times,'FontSize',18,'FontAngle','Italic',...
0357     'FontWeight','Bold',...
0358     'ForegroundColor',[1 1 1]*.6,'BackgroundColor',[1 1 1]*.8);
0359 
0360 
0361 uicontrol(F,'Style','Frame','Position',[110 130 380 115]);
0362 uicontrol(F,'Style','Frame','Position',[110 015 380 087]);
0363 
0364 uicontrol(F,'Style','Text','String',SPMver,...
0365     'ToolTipString','by the FIL methods group',...
0366     'Position',[112 200 376 030],...
0367     'FontName',PF.times,'FontSize',18,'FontWeight','Bold',...
0368     'ForegroundColor','b')
0369 
0370 uicontrol(F,'Style','Text','Position',[112 175 376 020],...
0371     'String','developed by members and collaborators of',...
0372     'ToolTipString','',...
0373     'FontName',PF.times,'FontSize',10,'FontAngle','Italic')
0374 
0375 uicontrol(F,'Style','Text','Position',[112 160 376 020],...
0376     'String','The Wellcome Department of Imaging Neuroscienic_e',...
0377     'ToolTipString','',...
0378     'FontName',PF.times,'FontSize',12,'FontWeight','Bold')
0379 
0380 uicontrol(F,'Style','Text', 'Position',[112 140 376 020],...
0381     'String','Institute of Neurology, University College London',...
0382     'ToolTipString','',...
0383     'FontName',PF.times,'FontSize',12)
0384 
0385 uicontrol(F,'Style','Text','String',SPMc,'ToolTipString',SPMc,...
0386     'ForegroundColor',[1 1 1]*.6,'BackgroundColor',[1 1 1]*.8,...
0387     'FontName',PF.times,'FontSize',10,...
0388     'HorizontalAlignment','center',...
0389     'Position',[110 003 380 010])
0390 
0391 %-Objects with Callbacks - PET, fMRI, About SPM, SPMweb
0392 %-----------------------------------------------------------------------
0393 set(F,'DefaultUicontrolFontSize',12,'DefaultUicontrolInterruptible','on')
0394 uicontrol(F,'String','PET and SPECT',...
0395     'ToolTipString',...
0396     'launic_h SPM-GUI in PET/SPECT modality (or type "spm pet" in MatLab)',...
0397     'Position',[140 061 115 030],...
0398     'CallBack','delete(gcbf),clear all,spm(''PET'')',...
0399     'ForegroundColor',[0 1 1])
0400 
0401 uicontrol(F,'String','M/EEG',...
0402     'ToolTipString',...
0403     'launic_h SPM-GUI in EEG/MEG modality (or type "spm eeg" in MatLab)',...
0404     'Position',[265 061 70 030],...
0405     'CallBack','delete(gcbf),clear all,spm(''EEG'')',...
0406     'ForegroundColor',[0 1 1])
0407 
0408 uicontrol(F,'String','fMRI time-series',...
0409     'ToolTipString',...
0410     'launic_h SPM-GUI in fMRI modality (or type "spm fmri" in MatLab)',...
0411     'Position',[345 061 115 030],...
0412     'CallBack','delete(gcbf),clear all,spm(''FMRI'')',...
0413     'ForegroundColor',[0 1 1])
0414 
0415 uicontrol(F,'String','About SPM',...
0416     'ToolTipString','launic_h SPMhelp browser - about SPM',...
0417     'Position',[140 025 100 030],...
0418     'CallBack','nic_spm_help(''spm.man'')',...
0419     'ForegroundColor','g')
0420 
0421 uicontrol(F,'String','SPMweb',...
0422     'FontWeight','Bold','FontName',PF.courier,...
0423     'ToolTipString',...
0424     'launic_h web browser - http://www.fil.ion.ucl.ac.uk/spm/',...
0425     'Position',[250 025 100 030],...
0426     'CallBack',['set(gcbf,''Pointer'',''Watch''),',...
0427             'web(''http://www.fil.ion.ucl.ac.uk/spm/'');',...
0428             'set(gcbf,''Pointer'',''Arrow'')'],...
0429     'ForegroundColor','k')
0430 
0431 uicontrol(F,'String','Quit',...
0432     'ToolTipString','close this splash screen',...
0433     'Position',[360 025 100 030],...
0434     'CallBack','delete(gcbf)',...
0435     'Interruptible','off',...
0436     'ForegroundColor','r')
0437 
0438 set(F,'Pointer','Arrow','Visible','on')
0439 
0440 
0441 %=======================================================================
0442 case 'asciiwelcome'                           %-ASCII SPM banner welcome
0443 %=======================================================================
0444 disp( ' ___  ____  __  __                                            ');
0445 disp( '/ __)(  _ \(  \/  )                                           ');
0446 disp( '\__ \ )___/ )    (   Statistical Parametric Mapping           ');
0447 disp(['(___/(__)  (_/\/\_)  ',spm('Ver'),' - http://www.fil.ion.ucl.ac.uk/spm/']);
0448 fprintf('\n');
0449 
0450 
0451 %=======================================================================
0452 case lower(Modalities)            %-Initialise SPM in PET, fMRI modality
0453 %=======================================================================
0454 % spm(Modality)
0455 
0456 %-Turn on warning messages for debugging
0457 %- disabled as syntax for Matlab 6.5 has changed
0458 %warning always, warning backtrace
0459 
0460 %-Initialisation and workspace canonicalisation
0461 %-----------------------------------------------------------------------
0462 local_clc, nic_spm('SetCmdWinLabel')
0463 nic_spm('AsciiWelcome');                    fprintf('\n\nInitialising SPM');
0464 Modality = upper(Action);                                  fprintf('.');
0465 delete(get(0,'Children'));                                 fprintf('.');
0466 
0467 %-Draw SPM windows
0468 %-----------------------------------------------------------------------
0469 Fmenu  = nic_spm('CreateMenuWin','off');                       fprintf('.');
0470 Finter = nic_spm('CreateIntWin','off');                           fprintf('.');
0471 spm_figure('WaterMark',Finter,nic_spm('Ver'),'',45);           fprintf('.');
0472 Fgraph = nic_spm_figure('Create','Graphics','Graphics','off'); fprintf('.');
0473 %spm_jobman('pulldown');
0474 
0475 Fmotd  = fullfile(nic_spm('Dir'),'spm_motd.man');
0476 if exist(Fmotd), nic_spm_help('!Disp',Fmotd,'',Fgraph,nic_spm('Ver')); end
0477                                                            fprintf('.');
0478 
0479 %-Load startup global defaults
0480 %-----------------------------------------------------------------------
0481 nic_spm_defaults;                                              fprintf('.');
0482 
0483 %-Setup for current modality
0484 %-----------------------------------------------------------------------
0485 nic_spm('ChMod',Modality);                                     fprintf('.');
0486 
0487 %-Reveal windows
0488 %-----------------------------------------------------------------------
0489 set([Fmenu,Finter,Fgraph],'Visible','on');          fprintf('done\n\n');
0490 
0491 %-Print present working directory
0492 %-----------------------------------------------------------------------
0493 fprintf('SPM present working directory:\n\t%s\n',pwd)
0494 
0495 
0496 %=======================================================================
0497 case 'createmenuwin'                              %-Draw SPM menu window
0498 %=======================================================================
0499 % Fmenu = spm('CreateMenuWin',Vis)
0500 if nargin<2, Vis='on'; else, Vis=varargin{2}; end
0501 
0502 %-Close any existing 'Menu' 'Tag'ged windows
0503 delete(nic_spm_figure('FindWin','Menu'))
0504 
0505 %-Get size and scalings and create Menu window
0506 %-----------------------------------------------------------------------
0507 WS   = nic_spm('WinScale');                %-Window scaling factors
0508 FS   = nic_spm('FontSizes');            %-Scaled font sizes
0509 PF   = nic_spm_platform('fonts');            %-Font names (for this platform)
0510 Rect = nic_spm('WinSize','Menu','raw').*WS;        %-Menu window rectangle
0511 
0512 [SPMver,SPMc] = nic_spm('Ver','',1,1);
0513 
0514 Fmenu = figure('IntegerHandle','off',...
0515     'Name',sprintf('%s%s',nic_spm('ver'),nic_spm('GetUser',' (%s)')),...
0516     'NumberTitle','off',...
0517     'Tag','Menu',...
0518     'Position',Rect,...
0519     'Resize','off',...
0520     'Color',[1 1 1]*.8,...
0521     'UserData',struct('SPMver',SPMver,'SPMc',SPMc),...
0522     'MenuBar','none',...
0523     'DefaultTextFontName',PF.helvetica,...
0524     'DefaultTextFontSize',FS(10),...
0525     'DefaultUicontrolFontName',PF.helvetica,...
0526     'DefaultUicontrolFontSize',FS(12),...
0527     'DefaultUicontrolInterruptible','on',...
0528     'Renderer','painters',...
0529     'Visible','off');
0530 
0531 %-Frames and text
0532 %-----------------------------------------------------------------------
0533 uicontrol(Fmenu,'Style','Frame','BackgroundColor',spm('Colour'),...
0534     'Position',[010 145 380 295].*WS)
0535 
0536 uicontrol(Fmenu,'Style','Frame',...
0537     'Position',[020 340 360 90].*WS)
0538 
0539 uicontrol(Fmenu,'Style','Text',...
0540     'String','Spatial pre-processing',...
0541     'Position',[025 410 350 020].*WS,...
0542     'ForegroundColor','w',...
0543     'FontAngle','Italic',...
0544     'FontSize',FS(10),...
0545     'HorizontalAlignment','Left',...
0546     'Tag', 'PETFMRI')
0547 
0548 uicontrol(Fmenu,'Style','Text',...
0549   'String','temporal pre-processing',...
0550     'Position',[025 410 350 020].*WS,...
0551     'ForegroundColor','w',...
0552     'FontAngle','Italic',...
0553     'FontSize',FS(10),...
0554     'HorizontalAlignment','Left',...
0555     'Tag', 'EEG')
0556 
0557 uicontrol(Fmenu,'Style','Frame',...
0558     'Position',[020 245 360 90].*WS,...
0559     'Tag', 'PETFMRI')
0560 
0561 uicontrol(Fmenu,'Style','Text',...
0562     'String','Model specification, review and estimation',...
0563     'Position',[025 315 350 020].*WS,...
0564     'ForegroundColor','w',...
0565     'FontAngle','Italic',...
0566     'FontSize',FS(10),...
0567     'HorizontalAlignment','Left',...
0568     'Tag', 'PETFMRI')
0569 
0570 uicontrol(Fmenu,'Style','Frame',...
0571     'Position',[020 200 360 40].*WS,...
0572     'Tag', 'PETFMRI')
0573 uicontrol(Fmenu,'Style','Text',...
0574     'String','Inferenic_e',...
0575     'Position',[025 220 350 020].*WS,...
0576     'ForegroundColor','w',...
0577     'FontAngle','Italic',...
0578     'FontSize',FS(10),...
0579     'HorizontalAlignment','Left',...
0580     'Tag', 'PETFMRI')
0581 
0582 uicontrol(Fmenu,'Style','Frame',...
0583     'Position',[020 295 360 40].*WS, 'Tag', 'EEG')
0584 
0585 uicontrol(Fmenu,'Style','Text',...
0586     'String','spatial projection',...
0587     'Position',[025 315 350 020].*WS,...
0588     'ForegroundColor','w',...
0589     'FontAngle','Italic',...
0590     'FontSize',FS(10),...
0591     'HorizontalAlignment','Left',...    
0592     'Tag', 'EEG')
0593 
0594 
0595 uicontrol(Fmenu,'Style','Text',...
0596     'String','Model specification, review and estimation',...
0597     'Position',[025 315 350 020].*WS,...
0598     'ForegroundColor','w',...
0599     'FontAngle','Italic',...
0600     'FontSize',FS(10),...
0601     'HorizontalAlignment','Left',...
0602     'Tag', 'PETFMRI')
0603 
0604 uicontrol(Fmenu,'Style','Frame',...
0605     'Position',[020 155 360 40].*WS,...
0606     'Tag', 'PETFMRI')
0607 
0608 uicontrol(Fmenu,'Style','Frame',...
0609     'Position',[020 200 360 90].*WS,...
0610     'Tag', 'EEG')
0611 
0612 uicontrol(Fmenu,'Style','Text',...
0613     'String','Model specification, review and estimation',...
0614     'Position',[025 270 350 020].*WS,...
0615     'ForegroundColor','w',...
0616     'FontSize',FS(10),...
0617     'FontAngle','Italic',...
0618     'HorizontalAlignment','Left',...
0619     'Tag', 'EEG')
0620 
0621 uicontrol(Fmenu,'Style','Frame',...
0622     'Position',[020 155 360 40].*WS,...
0623     'Tag', 'EEG')
0624 uicontrol(Fmenu,'Style','Text',...
0625     'String','Inferenic_e',...
0626     'Position',[025 175 350 020].*WS,...
0627     'ForegroundColor','w',...
0628     'FontAngle','Italic',...
0629     'FontSize',FS(10),...
0630     'HorizontalAlignment','Left',...
0631     'Tag', 'EEG')
0632 
0633 uicontrol(Fmenu,'Style','Text',...
0634     'String','SPM for PET/SPECT',...
0635     'ToolTipString','modality & defaults set for PET/SPECT',...
0636     'ForegroundColor',[1 1 1]*.6,...
0637     'BackgroundColor',[1 1 1]*.8,...
0638     'FontAngle','Italic',...
0639     'HorizontalAlignment','center',...
0640     'Position',[020 122 360 020].*WS,...
0641     'Tag','PET',...
0642     'Visible','off')
0643 uicontrol(Fmenu,'Style','Text',...
0644     'String','SPM for functional MRI',...
0645     'ToolTipString','modality & defaults set for fMRI',...
0646     'ForegroundColor',[1 1 1]*.6,...
0647     'BackgroundColor',[1 1 1]*.8,...
0648     'FontAngle','Italic',...
0649     'HorizontalAlignment','center',...
0650     'Position',[020 122 360 020].*WS,...
0651     'Tag','FMRI',...
0652     'Visible','off')
0653 
0654 uicontrol(Fmenu,'Style','Text',...
0655     'String','SPM for EEG/MEG',...
0656     'ToolTipString','modality & defaults set for EEG/MEG',...
0657     'ForegroundColor',[1 1 1]*.6,'BackgroundColor',[1 1 1]*.8,...
0658     'FontName',PF.times,'FontAngle','Italic','FontWeight','Bold',...
0659     'HorizontalAlignment','center',...
0660     'Position',[020 122 360 020].*WS,...
0661     'Tag','EEG','Visible','off')
0662 
0663 % Utilities frames and text
0664 %-----------------------------------------------------------------------
0665 uicontrol(Fmenu,'Style','Frame',...
0666     'BackgroundColor',spm('Colour'),...
0667     'Position',[010 010 380 112].*WS)
0668 
0669 uicontrol(Fmenu,'Style','Text','String',SPMc,...
0670     'ToolTipString',SPMc,...
0671     'ForegroundColor',[1 1 1]*.6,...
0672     'BackgroundColor',[1 1 1]*.8,...
0673     'FontName',PF.times,...
0674     'FontSize',FS(10),...
0675     'HorizontalAlignment','center',...
0676     'Position',[020 002 360 008].*WS)
0677 
0678 %-Objects with Callbacks - main spm_*_ui.m routines
0679 %=======================================================================
0680 
0681 %-Spatial
0682 %-----------------------------------------------------------------------
0683 uicontrol(Fmenu,'Style','popup',...
0684     'String','Realign|Realign & Unwarp',...
0685     'Position',[035 380 100 030].*WS,...
0686     'FontSize',FS(10),...
0687     'ToolTipString','realignment',...
0688     'UserData','',...
0689     'CallBack',@realign_unwarp,...
0690     'Tag','FMRI','Visible','off');                                                                              
0691 
0692 uicontrol(Fmenu,'String','Realign',...
0693     'Position',[040 380 080 030].*WS,...
0694     'FontSize',FS(10),...
0695     'ToolTipString','realignment',...
0696     'UserData','jobs.spatial.realign',...
0697     'CallBack','nic_spm_jobman(''interactive'','''',''jobs.spatial.realign'');',...
0698     'Tag','PET','Visible','off');
0699 
0700 uicontrol(Fmenu,'String','Normalize',...
0701     'Position',[150 370 100 030].*WS,...
0702     'FontSize',FS(10),...
0703     'ToolTipString','spatial normalization',...
0704     'CallBack','nic_spm_jobman(''interactive'','''',''jobs.spatial.normalise'');',...
0705     'Tag','PET',...
0706     'UserData','jobs.spatial.normalise',...
0707     'Visible','off');
0708 
0709 uicontrol(Fmenu,'String','Normalize',...
0710     'Position',[150 345 100 030].*WS,...
0711     'FontSize',FS(10),...
0712     'ToolTipString','spatial normalisation',...
0713     'CallBack','nic_spm_jobman(''interactive'','''',''jobs.spatial.normalise'');',...
0714     'UserData','jobs.spatial.normalise',...
0715     'Tag','FMRI', 'Visible','off');
0716 
0717 uicontrol(Fmenu,'String','Slice timing',...
0718     'Position',[150 380 100 030].*WS,...
0719     'FontSize',FS(10),'ToolTipString',...
0720     'correct slice acquisition times',...
0721     'CallBack','nic_spm_jobman(''interactive'','''',''jobs.temporal.st'');',...
0722     'UserData','jobs.temporal.st',...
0723     'Tag','FMRI',...
0724     'Visible','off');;
0725 
0726 uicontrol(Fmenu,'String','Smooth',...
0727     'Position',[280 380 080 030].*WS,...
0728     'ToolTipString','spatial smoothing with Gaussian kernel',...
0729     'FontSize',FS(10),...
0730     'UserData','jobs.spatial.smooth',...
0731     'CallBack','nic_spm_jobman(''interactive'','''',''jobs.spatial.smooth'');',...
0732     'Tag', 'PETFMRI');
0733 
0734 uicontrol(Fmenu,'String','Coregister',...
0735     'Position',[040 345 080 030].*WS,...
0736     'ToolTipString','co-register images from disparate modalities',...
0737     'FontSize',FS(10),...
0738     'UserData','jobs.spatial.coreg',...
0739     'CallBack','nic_spm_jobman(''interactive'','''',''jobs.spatial.coreg'');',...
0740     'Tag', 'PETFMRI');
0741 
0742 uicontrol(Fmenu,'String','Segment',...
0743     'Position',[280 345 080 030].*WS,...
0744     'ToolTipString','segment',...
0745     'FontSize',FS(10),...
0746     'UserData','jobs.spatial.preproc',...
0747     'CallBack','nic_spm_jobman(''interactive'','''',''jobs.spatial.preproc'');',...
0748     'Tag', 'PETFMRI');
0749 
0750 %-Temporal EEG
0751 %-----------------------------------------------------------------------
0752 uicontrol(Fmenu,'String','Convert',...
0753     'Position',[035 380 100 030].*WS,...
0754     'ToolTipString','Convert neuroscan format',...
0755     'FontSize',FS(10),...
0756     'UserData','nic_spm_eeg_converteeg2mat',...
0757     'CallBack','nic_spm_eeg_converteeg2mat;',...
0758     'Tag', 'EEG',...
0759     'Visible','off')
0760 
0761 uicontrol(Fmenu,'String','Epoching',...
0762     'Position',[035 345 100 030].*WS,...
0763     'ToolTipString','epoch continuous M/EEG data',...
0764     'FontSize',FS(10),...
0765     'UserData','nic_spm_eeg_epochs',...
0766     'CallBack','nic_spm_eeg_epochs;',...
0767     'Tag', 'EEG',...
0768     'Visible','off');
0769     
0770 uicontrol(Fmenu,'String','Filter',...
0771     'Position',[150 380 100 030].*WS,...
0772     'ToolTipString','rereferenic_e M/EEG time-series',...
0773     'FontSize',FS(10),...
0774     'UserData','nic_spm_eeg_filter',...
0775     'CallBack','nic_spm_eeg_filter;',...
0776     'Tag', 'EEG',...
0777     'Visible','off');
0778 
0779 uicontrol(Fmenu,'String','Artefacts',...
0780     'Position',[150 345 100 030].*WS,...
0781     'ToolTipString','detect and correct artefacts',...
0782     'FontSize',FS(10),...
0783     'UserData','nic_spm_eeg_artefact',...
0784     'CallBack','nic_spm_eeg_artefact;',...
0785     'Tag', 'EEG',...
0786     'Visible','off');
0787 
0788 uicontrol(Fmenu,'String','Averaging',...
0789     'Position',[265 380 100 030].*WS,...
0790     'ToolTipString','Average epochs',...
0791     'FontSize',FS(10),...
0792     'UserData','nic_spm_eeg_average',...
0793     'CallBack','nic_spm_eeg_average;',...
0794     'Tag', 'EEG',...
0795     'Visible','off');
0796 
0797 uicontrol(Fmenu,'Style','PopUp',...
0798     'String','Other...|rereferenic_e|downsample|time-frequenic_y|grand mean|merge|3Dimages|average TF',...
0799     'Position',[265 345 100 030].*WS,...
0800     'ToolTipString','Other preprocessing functions',...
0801     'FontSize',FS(10),...
0802     'CallBack','nic_spm(''PopUpCB'',gcbo)',...
0803     'UserData',{'nic_spm_eeg_rereferenic_e;','nic_spm_eeg_downsample;','nic_spm_eeg_tf;',...
0804     'nic_spm_eeg_grandmean;','nic_spm_eeg_merge;','nic_spm_eeg_make3dimage;','nic_spm_eeg_average_TF;'},...
0805     'Tag', 'EEG')
0806 
0807 % Spatial EEG
0808 %-----------------------------------------------------------------------
0809 uicontrol(Fmenu,'String','2D interpolation',...
0810     'Position',[120 300 100 030].*WS,...
0811     'ToolTipString', '2D interpolation of EEG/MEG channel data',...
0812     'FontSize',FS(10),...
0813     'UserData','nic_spm_eeg_TF_images;',...
0814     'CallBack','nic_spm_eeg_TF_images;',...
0815     'Visible','off',...
0816     'Tag','EEG')
0817 
0818 uicontrol(Fmenu,'String','3D source reconstruction',...
0819     'Position',[235 300 135 030].*WS,...
0820     'ToolTipString','3D source reconstruction of EEG/MEG data (not functional yet)',...
0821     'FontSize',FS(10),...
0822     'UserData','',...
0823     'CallBack','nic_spm_eeg_inv_imag_api;',...
0824     'Visible','off',...
0825     'Tag','EEG')
0826 
0827 %-Statistical fMRI
0828 %-----------------------------------------------------------------------
0829 
0830 uicontrol(Fmenu,'String','Specify 1st-level',...
0831     'Position',[75 285 110 030].*WS,...
0832     'ToolTipString',['GLM setup for fMRI time series'],...
0833     'FontSize',FS(10),...
0834     'CallBack','nic_spm_jobman(''interactive'','''',''jobs.stats.fmri_spec'');',...
0835     'Visible','off',...
0836     'UserData','jobs.stats.fmri_spec',...
0837     'Tag','FMRI');
0838 
0839 uicontrol(Fmenu,'String','Specify 2nd-level',...
0840     'Position',[75 250 110 030].*WS,...
0841     'FontSize',FS(10),...
0842     'ToolTipString','basic statistical models',...
0843     'UserData','jobs.stats.factorial_design',...
0844     'CallBack','nic_spm_jobman(''interactive'','''',''jobs.stats.factorial_design'');',...
0845     'Tag', 'FMRI');
0846 
0847 uicontrol(Fmenu,'String','Review',...
0848     'Position',[225 285 110 030].*WS,...
0849     'FontSize',FS(10),...
0850     'ToolTipString','review a specified model',...
0851     'UserData','nic_spm_DesRep',...
0852     'CallBack','nic_spm pointer watch, nic_spm_DesRep; nic_spm pointer arrow',...
0853     'Tag', 'FMRI');
0854 
0855 uicontrol(Fmenu,'String','Estimate',...
0856     'Position',[225 250 110 030].*WS,...
0857     'ToolTipString','estimate parameters of a specified model',...
0858     'FontSize',FS(10),...
0859     'UserData','jobs.stats.fmri_est',...
0860     'CallBack','nic_spm_jobman(''interactive'','''',''jobs.stats.fmri_est'');',...
0861     'Tag', 'FMRI');
0862 
0863 % Statistical PET
0864 %-----------------------------------------------------------------------
0865 
0866 uicontrol(Fmenu,'String','Basic models',...
0867     'Position',[035 285 110 030].*WS,...
0868     'FontSize',FS(10),...
0869     'ToolTipString','basic statistical models',...
0870     'UserData','jobs.stats.factorial_design',...
0871     'CallBack','nic_spm_jobman(''interactive'','''',''jobs.stats.factorial_design'');',...
0872     'Tag', 'PET');
0873 
0874 uicontrol(Fmenu,'String','PET',...
0875     'Position',[150 285 95 030].*WS,...
0876     'FontSize',FS(10),...
0877     'ToolTipString','GLM setup for PET',...
0878     'CallBack','nic_spm_jobman(''interactive'','''',''jobs.stats.factorial_design'');',...
0879     'Visible','off',...
0880     'Tag','PET',...
0881     'UserData','jobs.stats.factorial_design',...
0882     'Enable','on');
0883 
0884 uicontrol(Fmenu,'String','Review',...
0885     'Position',[250 285 110 030].*WS,...
0886     'FontSize',FS(10),...
0887     'ToolTipString','review a specified model',...
0888     'UserData','nic_spm_DesRep',...
0889     'CallBack','nic_spm pointer watch, nic_spm_DesRep; nic_spm pointer arrow',...
0890     'Tag', 'PET');
0891 
0892 uicontrol(Fmenu,'String','Estimate',...
0893     'Position',[035 250 160 030].*WS,...
0894     'ToolTipString','estimate (ReML) parameters of a specified model',...
0895     'FontSize',FS(10),...
0896     'UserData','nic_spm_spm',...
0897     'CallBack','SPM = nic_spm_spm;',...
0898     'Tag', 'PET');
0899 
0900 uicontrol(Fmenu,'String','Bayesian',...
0901     'Position',[200 250 160 030].*WS,...
0902     'ToolTipString','Bayesian or conditional estimators',...
0903     'FontSize',FS(10),...
0904     'UserData','nic_spm_spm_Bayes',...
0905     'CallBack','nic_spm_spm_Bayes',...
0906     'Tag', 'PET');
0907 
0908 % Statistical Results
0909 %-------------------------------------------------------
0910 
0911 uicontrol(Fmenu,'String','Results',...
0912     'Position',[130 205 130 030].*WS,...
0913     'ToolTipString','Inferenic_e and regional responses etc.',...
0914     'FontSize',FS(10),...
0915     'UserData','nic_spm_results_ui',...
0916     'CallBack','[hReg,xSPM,SPM] = nic_spm_results_ui;',...
0917     'Tag', 'PETFMRI');
0918 
0919 uicontrol(Fmenu,'String','Dynamic Causal Modelling',...
0920     'Position',[60 160 280 030].*WS,...
0921     'ToolTipString','Specify and estimate a dynamic causal model',...
0922     'FontSize',FS(10),...
0923     'Visible','off',...
0924     'Tag','FMRI',...
0925     'UserData','nic_spm_dcm_ui',...
0926     'CallBack','nic_spm_dcm_ui',...
0927     'Tag', 'PETFMRI');
0928 
0929 % Statistical EEG
0930 %-----------------------------------------------------------------------
0931 
0932 uicontrol(Fmenu,'String','EEG/MEG',...
0933     'Position',[75 240 110 030].*WS,...
0934     'FontSize',FS(10),...
0935     'ToolTipString','EEG and MEG models (any level)',...
0936     'UserData','nic_spm_eeg_spm_ui',...
0937     'CallBack','nic_spm_eeg_spm_ui;',...
0938     'Tag', 'EEG');
0939 
0940 uicontrol(Fmenu,'String','Basic models',...
0941     'Position',[75 205 110 030].*WS,...
0942     'FontSize',FS(10),...
0943     'ToolTipString','basic statistical models',...
0944     'UserData','nic_spm_spm_ui',...
0945     'CallBack','SPM = nic_spm_spm_ui(''cfg'',spm_spm_ui(''DesDefs_Stats''));',...
0946     'Tag', 'EEG');
0947 
0948 
0949 uicontrol(Fmenu,'String','Review',...
0950     'Position',[225 240 110 030].*WS,...
0951     'FontSize',FS(10),...
0952     'ToolTipString','review a specified model',...
0953     'UserData','nic_spm_DesRep',...
0954     'CallBack','nic_spm pointer watch, nic_spm_DesRep; nic_spm pointer arrow',...
0955     'Tag', 'EEG');
0956 
0957 uicontrol(Fmenu,'String','Estimate',...
0958     'Position',[225 205 110 030].*WS,...
0959     'ToolTipString','estimate the parameters of a specified model',...
0960     'FontSize',FS(10),...
0961     'UserData','nic_spm_spm',...
0962     'CallBack','SPM = nic_spm_spm;',...
0963     'Tag', 'EEG');
0964 
0965 % uicontrol(Fmenu,'String','-> Bayesian',...
0966 %     'Position',[200 205 160 030].*WS,...
0967 %     'ToolTipString','Bayesian or conditional estimators',...
0968 %     'FontSize',FS(10),...
0969 %     'UserData','spm_spm_Bayes',...
0970 %     'CallBack','spm_spm_Bayes',...
0971 %     'ForeGroundColor',[1 1 1]/2,...
0972 %     'Tag', 'EEG');
0973 
0974 uicontrol(Fmenu,'String','Results',...
0975     'Position',[130 160 130 030].*WS,...
0976     'ToolTipString','Inferenic_e and regional responses etc.',...
0977     'FontSize',FS(10),...
0978     'UserData','nic_spm_results_ui',...
0979     'CallBack','[hReg,xSPM,SPM] = nic_spm_results_ui;',...
0980     'Tag', 'EEG');
0981 
0982 %-Utility buttons (first line)
0983 %-----------------------------------------------------------------------
0984 uicontrol(Fmenu,'String','Display',...
0985     'Position',[020 088 082 024].*WS,...
0986     'ToolTipString','orthogonal sections',...
0987     'FontSize',FS(9),...
0988     'UserData','jobs.util.disp',...
0989     'CallBack','nic_spm_jobman(''serial'','''',''jobs.util.disp'');',...
0990     'Tag', 'PETFMRI')
0991 
0992 uicontrol(Fmenu,'Style','PopUp',...
0993     'String','Display...|images|M/EEG',...
0994     'Position',[020 088 082 024].*WS,...
0995     'ToolTipString','orthogonal sections and M/EEG display',...
0996     'FontSize',FS(9),...
0997     'CallBack','nic_spm(''PopUpCB'',gcbo)',...
0998     'UserData',{    'nic_spm_jobman(''serial'','''',''jobs.util.disp'');','spm_eeg_display_ui;'},...
0999     'Tag', 'EEG')
1000 
1001 uicontrol(Fmenu,'String','Check Reg',...
1002     'Position',[112 088 083 024].*WS,...
1003     'ToolTipString','check image registration',...
1004     'FontSize',FS(9),...
1005     'UserData','jobs.util.checkreg',...
1006     'CallBack','nic_spm_jobman(''serial'','''',''jobs.util.checkreg'');')
1007 
1008 uicontrol(Fmenu,'Style','PopUp',...
1009     'String','Render...|Display|Xtract Surface',...
1010     'Position',[205 088 083 024].*WS,...
1011     'ToolTipString','rendering utilities...',...
1012     'FontSize',FS(9),...
1013     'CallBack','nic_spm(''PopUpCB'',gcbo)',...
1014     'UserData',{    'nic_spm_render;',...
1015             'nic_spm_surf;'    })
1016 
1017 uicontrol(Fmenu,'Style','PopUp',...
1018     'String',Modalities,...
1019     'ToolTipString','change modality PET<->fMRI<->EEG',...
1020     'Tag','Modality',...
1021     'Position',[298 088 082 024].*WS,...
1022     'CallBack',[...
1023         'if isempty(get(gco,''UserData'')) | ',...
1024         'get(gco,''Value'')~=get(gco,''UserData''),',...
1025         'nic_spm(''ChMod'',get(gco,''Value''));,',...
1026         'Fhelp = nic_spm_figure(''FindWin'',''Help'');',...
1027         'if length(Fhelp),delete(Fhelp),end;',...
1028         'end'],...
1029     'UserData','nic_SPM_Modality',...
1030     'Interruptible','off')
1031 
1032 %-Utility buttons (second line)
1033 %-----------------------------------------------------------------------
1034 %-Toolbox pulldown
1035 xTB = spm('TBs');
1036 if isempty(xTB)
1037     uicontrol(Fmenu,'String','Toolboxes...',...
1038     'Position',[020 054 082 024].*WS,...
1039     'ToolTipString','Additional Toolboxes',...
1040     'FontSize',FS(9),...
1041     'UserData','MenuWin_Toolboxes_PullDown',...
1042     'CallBack','','Enable','off')
1043 else
1044     uicontrol(Fmenu,'Style','PopUp',...
1045     'String',{'Toolboxes...',xTB.name},...
1046        'ToolTipString','Additional Toolboxes',...
1047        'Position',[020 054 082 024].*WS,...
1048        'FontSize',FS(9),...
1049     'CallBack',...
1050         ['nic_spm(''TBlaunic_h'',get(gcbo,''UserData''),get(gcbo,''Value'')-1), ',...
1051             'set(gcbo,''Value'',1)'],...
1052        'UserData', xTB)
1053 end
1054 
1055 uicontrol(Fmenu,...
1056     'String','PPIs',...
1057     'Position',[112 054 083 024].*WS,...
1058     'ToolTipString',...
1059     'Forms PPI regressors for fMRI using hemodynamic deconvolution',...
1060     'FontSize',FS(9),...
1061     'UserData','nic_spm_peb_ppi',...
1062     'CallBack','nic_spm_peb_ppi')
1063 
1064 uicontrol(Fmenu,'String','ImCalc',...
1065     'Position',[205 054 083 024].*WS,...
1066     'ToolTipString','image calculator',...
1067     'FontSize',FS(9),...
1068     'UserData','jobs.util.imcalc',...
1069     'CallBack','nic_spm_jobman(''interactive'','''',''jobs.util.imcalc'');')
1070 
1071 uicontrol(Fmenu,'String','DICOM Import',...
1072     'Position',[298 054 082 024].*WS,...
1073     'ToolTipString','Convert DICOM files to NIFTI-1',...
1074     'FontSize',FS(9),...
1075     'UserData','jobs.util.dicom',...
1076     'CallBack','nic_spm_jobman(''serial'','''',''jobs.util.dicom'');')
1077 
1078 %-Utility buttons (third line)
1079 %-----------------------------------------------------------------------
1080 uicontrol(Fmenu,'String','Help',...
1081     'Position',[020 020 082 024].*WS,...
1082     'ToolTipString','launic_h SPMhelp browser',...
1083     'CallBack','nic_spm_help;',...
1084     'UserData','nic_spm_help',...
1085     'ForeGroundColor','g')
1086 
1087 uicontrol(Fmenu,'Style','PopUp',...
1088     'String','Utils...|CD|PWD|delete files|Show SPM|Run mFile|SPMweb',...
1089     'ToolTipString','misc SPM utilities',...
1090     'Position',[112 020 083 024].*WS,...
1091     'FontSize',FS(9),...
1092     'CallBack','nic_spm(''PopUpCB'',gcbo)',...
1093     'UserData',{    [...
1094         'nic_spm(''FnBanner'',''CD'');',...
1095            'cd(nic_spm_select(1,''dir'',''Select new working directory'')),',...
1096            'nic_spm(''alert"'',',...
1097                 '{''New working directory:'',[''    '',pwd]},',...
1098                 '''CD'',sqrt(-1));'],...
1099             ['nic_spm(''alert"'',',...
1100             '{''Present working directory:'',[''    '',pwd]},',...
1101             '''PWD'',0);'],...
1102         'nic_spm(''GUI_FileDelete'')',...
1103         'nic_spm(''Show'');',...
1104         'run(nic_spm_select(1,''*\.m$'',''Select mFile to run''))',...
1105         'web(''http://www.fil.ion.ucl.ac.uk/spm/'')' } )
1106 
1107 uicontrol(Fmenu,'String','Defaults',...
1108     'Position',[205 020 083 024].*WS,...
1109     'ToolTipString','adjust default SPM behaviour for this session',...
1110     'FontSize',FS(9),...
1111     'CallBack','nic_spm_jobman(''defaults'');')
1112 
1113 uicontrol(Fmenu,'String','Quit',...
1114     'Position',[298 020 082 024].*WS,...
1115     'ToolTipString','exit SPM',...
1116     'ForeGroundColor','r',...
1117     'Interruptible','off',...
1118     'UserData','QuitSPM',...
1119     'CallBack','nic_spm(''Quit''), clear all')
1120 
1121 %-----------------------------------------------------------------------
1122 set(Fmenu,'CloseRequestFcn','nic_spm(''Quit'')')
1123 set(Fmenu,'Visible',Vis)
1124 varargout = {Fmenu};
1125 
1126 
1127 %=======================================================================
1128 case 'createintwin'                      %-Create SPM interactive window
1129 %=======================================================================
1130 % Finter = spm('CreateIntWin',Vis)
1131 %-----------------------------------------------------------------------
1132 if nargin<2, Vis='on'; else, Vis=varargin{2}; end
1133 
1134 %-Close any existing 'Interactive' 'Tag'ged windows
1135 delete(nic_spm_figure('FindWin','Interactive'))
1136 
1137 FS   = nic_spm('FontSizes');            %-Scaled font sizes
1138 PF   = nic_spm_platform('fonts');            %-Font names (for this platform)
1139 Rect = nic_spm('WinSize','Interactive');        %-Interactive window rectangle
1140 
1141 %-Create SPM Interactive window
1142 Finter = figure('IntegerHandle','off',...
1143     'Tag','Interactive',...
1144     'Name','','NumberTitle','off',...
1145     'Position',Rect,...
1146     'Resize','off',...
1147     'Color',[1 1 1]*.7,...
1148     'MenuBar','none',...
1149     'DefaultTextFontName',PF.helvetica,...
1150     'DefaultTextFontSize',FS(10),...
1151     'DefaultAxesFontName',PF.helvetica,...
1152     'DefaultUicontrolBackgroundColor',[1 1 1]*.7,...
1153     'DefaultUicontrolFontName',PF.helvetica,...
1154     'DefaultUicontrolFontSize',FS(10),...
1155     'DefaultUicontrolInterruptible','on',...
1156     'Renderer', 'painters',...
1157     'Visible',Vis);
1158 varargout = {Finter};
1159 
1160 
1161 %=======================================================================
1162 case 'chmod'                            %-Change SPM modality PET<->fMRI
1163 %=======================================================================
1164 % spm('ChMod',Modality)
1165 %-----------------------------------------------------------------------
1166 
1167 %-Sort out arguments
1168 %-----------------------------------------------------------------------
1169 if nargin<2, Modality = ''; else, Modality = varargin{2}; end
1170 [Modality,ModNum] = nic_spm('CheckModality',Modality);
1171 
1172 %-Sort out global defaults
1173 %-----------------------------------------------------------------------
1174 nic_spm('defaults',Modality);
1175 
1176 %-Sort out visability of appropriate controls on Menu window
1177 %-----------------------------------------------------------------------
1178 Fmenu = nic_spm_figure('FindWin','Menu');
1179 if isempty(Fmenu), error('SPM Menu window not found'), end
1180 
1181 if strcmpi(Modality,'PET')
1182     set(findobj(Fmenu, 'Tag', 'FMRI'),    'Visible', 'off');
1183     set(findobj(Fmenu, 'Tag', 'EEG'),     'Visible', 'off');
1184     set(findobj(Fmenu, 'Tag', 'PETFMRI'), 'Visible', 'on' );
1185     set(findobj(Fmenu, 'Tag', 'PET'),     'Visible', 'on' );
1186 elseif strcmpi(Modality,'FMRI')
1187     set(findobj(Fmenu, 'Tag', 'EEG'),     'Visible', 'off');
1188     set(findobj(Fmenu, 'Tag', 'PET'),     'Visible', 'off');
1189     set(findobj(Fmenu, 'Tag', 'PETFMRI'), 'Visible', 'on' );
1190     set(findobj(Fmenu, 'Tag', 'FMRI'),    'Visible', 'on' );
1191 else
1192     set(findobj(Fmenu, 'Tag', 'PETFMRI'), 'Visible', 'off');
1193     set(findobj(Fmenu, 'Tag', 'PET'),     'Visible', 'off');
1194     set(findobj(Fmenu, 'Tag', 'FMRI'),    'Visible', 'off');
1195     set(findobj(Fmenu, 'Tag', 'EEG'),     'Visible', 'on' );
1196 end
1197 set(findobj(Fmenu,'Tag','Modality'),'Value',ModNum,'UserData',ModNum);
1198 nic_spm_jobman('chmod',Modality);
1199 
1200 %=======================================================================
1201 case 'defaults'                 %-Set SPM defaults (as global variables)
1202 %=======================================================================
1203 % spm('defaults',Modality)
1204 %-----------------------------------------------------------------------
1205 global defaults
1206 if isempty(defaults), nic_spm_defaults; end;
1207 
1208 %-Sort out arguments
1209 %-----------------------------------------------------------------------
1210 if nargin<2, Modality=''; else, Modality=varargin{2}; end
1211 Modality          = nic_spm('CheckModality',Modality);
1212 defaults.modality = Modality;
1213 defaults.SWD      = nic_spm('Dir');              % SPM directory
1214 defaults.TWD      = nic_spm_platform('tempdir'); % Temp directory
1215     
1216 %-Set Modality specific default (global variables)
1217 %-----------------------------------------------------------------------
1218 global UFp
1219 if strcmpi(defaults.modality,'pet')
1220     UFp    = defaults.stats.pet.ufp;        % Upper tail F-prob
1221 elseif strcmpi(defaults.modality,'fmri')
1222     UFp    = defaults.stats.fmri.ufp;        % Upper tail F-prob
1223 elseif strcmpi(defaults.modality,'eeg')
1224     ;
1225 elseif strcmpi(defaults.modality,'unknown')
1226 else
1227     error('Illegal Modality');
1228 end
1229 
1230 
1231 %=======================================================================
1232 case 'quit'                                      %-Quit SPM and clean up
1233 %=======================================================================
1234 % spm('Quit')
1235 %-----------------------------------------------------------------------
1236 delete(get(0,'Children'));
1237 local_clc;
1238 fprintf('Bye for now...\n\n');
1239 
1240 
1241 %=======================================================================
1242 case 'checkmodality'              %-Check & canonicalise modality string
1243 %=======================================================================
1244 % [Modality,ModNum] = spm('CheckModality',Modality)
1245 %-----------------------------------------------------------------------
1246 if nargin<2, Modality=''; else, Modality=upper(varargin{2}); end
1247 if isempty(Modality)
1248     global defaults
1249     if isfield(defaults,'modality'), Modality = defaults.modality;
1250     else, Modality = 'UNKNOWN'; end
1251 end
1252 if ischar(Modality)
1253     ModNum = find(ismember(Modalities,Modality));
1254 else
1255     if ~any(Modality == [1:length(Modalities)])
1256         Modality = 'ERROR';
1257         ModNum   = [];
1258     else
1259         ModNum   = Modality;
1260         Modality = Modalities{ModNum};
1261     end
1262 end
1263 
1264 if isempty(ModNum), error('Unknown Modality'), end
1265 varargout = {upper(Modality),ModNum};
1266 
1267 
1268 %=======================================================================
1269 case {'winscale','getwinscale'}  %-Window scale factors (to fit display)
1270 %=======================================================================
1271 % WS = spm('WinScale')
1272 %-----------------------------------------------------------------------
1273 if strcmp(lower(Action),'getwinscale')
1274     warning('nic_spm(''GetWinScale'' GrandFathered, use ''WinScale''')
1275 end
1276 if str2double(version('-release'))>=14,
1277     S0 = get(0, 'MonitorPosition');
1278     S0 = S0(1,:);
1279 else
1280     S0   = get(0,'ScreenSize');
1281 end;
1282 if all(S0==1), error('Can''t open any graphics windows...'), end
1283 
1284 tmp = [S0(3)/1152 (S0(4)-50)/900 S0(3)/1152 (S0(4)-50)/900];
1285 varargout = {min(tmp)*[1 1 1 1]};
1286 
1287 % Make sure that aspect ratio is about right - for funny shaped screens
1288 % varargout = {[S0(3)/1152 (S0(4)-50)/900 S0(3)/1152 (S0(4)-50)/900]};
1289 
1290 
1291 %=======================================================================
1292 case {'fontsize','fontsizes','fontscale'}                 %-Font scaling
1293 %=======================================================================
1294 % [FS,sf] = spm('FontSize',FS)
1295 % [FS,sf] = spm('FontSizes',FS)
1296 % sf = spm('FontScale')
1297 %-----------------------------------------------------------------------
1298 if nargin<3, c=0; else, c=1; end
1299 if nargin<2, FS=[1:36]; else, FS=varargin{2}; end
1300 
1301 sf  = 1 + 0.85*(min(nic_spm('WinScale'))-1);
1302 
1303 if strcmp(lower(Action),'fontscale')
1304     varargout = {sf};
1305 else
1306     varargout = {ceil(FS*sf),sf};
1307 end
1308 
1309 
1310 %=======================================================================
1311 case 'winsize'                 %-Standard SPM window locations and sizes
1312 %=======================================================================
1313 % Rect = spm('WinSize',Win,raw)
1314 %-----------------------------------------------------------------------
1315 if nargin<3, raw=0; else, raw=1; end
1316 if nargin<2, Win=''; else, Win=varargin{2}; end
1317 
1318 Rect = [    [108 466 400 445];...
1319         [108 045 400 395];...
1320         [515 015 600 865] ];
1321 
1322 WS = nic_spm('WinScale');
1323 
1324 if isempty(Win)
1325     WS = ones(3,1)*WS;
1326 elseif upper(Win(1))=='M'
1327     %-Menu window
1328     Rect = Rect(1,:);
1329 elseif upper(Win(1))=='I'
1330     %-Interactive window
1331     Rect = Rect(2,:);
1332 elseif upper(Win(1))=='G'
1333     %-Graphics window
1334     Rect = Rect(3,:);
1335 elseif Win(1)=='0'
1336     %-Root workspace
1337     if str2double(version('-release'))>=14,
1338         Rect = get(0, 'MonitorPosition');
1339         Rect = Rect(1,:);
1340     else
1341         Rect = get(0,'ScreenSize');
1342     end;
1343 else
1344     error('Unknown Win type');
1345 end
1346 
1347 if ~raw, Rect = Rect.*WS; end
1348 varargout = {Rect};
1349 
1350 
1351 %=======================================================================
1352 case 'dir'                           %-Identify specific (SPM) directory
1353 %=======================================================================
1354 % spm('Dir',Mfile)
1355 %-----------------------------------------------------------------------
1356 if nargin<2, Mfile='spm'; else, Mfile=varargin{2}; end
1357 SPMdir = which(Mfile);
1358 if isempty(SPMdir)            %-Not found or full pathname given
1359     if exist(Mfile,'file')==2    %-Full pathname
1360         SPMdir = Mfile;
1361     else
1362         error(['Can''t find ',Mfile,' on MATLABPATH']);
1363     end
1364 end
1365 [SPMdir,junk] = fileparts(SPMdir);
1366 
1367 if str2num(version('-release'))==14 && isdeployed,
1368     ind = findstr(SPMdir,'_mcr')-1;
1369     [SPMdir,junk] = fileparts(SPMdir(1:ind(1)));
1370 end;
1371 varargout = {SPMdir};
1372 
1373 
1374 %=======================================================================
1375 case 'ver'                                                 %-SPM version
1376 %=======================================================================
1377 % SPMver = spm('Ver',Mfile,ReDo,Cache,Con)
1378 %-----------------------------------------------------------------------
1379 if nargin<5, Con=[]; else, Con=varargin{5}; end
1380 if isempty(Con), Con=1; end
1381 if nargin<4, Cache=[]; else, Cache=varargin{4}; end
1382 if isempty(Cache), Cache=1; end
1383 if nargin<3, ReDo=[]; else, ReDo=varargin{3}; end
1384 if isempty(ReDo), ReDo=0; end
1385 if nargin<2, Mfile=''; else, Mfile=varargin{2}; end
1386 if isempty(Mfile), Mfile='spm'; end
1387 
1388 xVname = [upper(nic_spm_str_manip(Mfile,'rt')),'_VER'];
1389 
1390 %-See if version info exists in global variable
1391 %-----------------------------------------------------------------------
1392 xV = nic_spm('GetGlobal',xVname);
1393 if ~ReDo & ~isempty(xV)
1394     if isstruct(xV) & isfield(xV,'v') & isfield(xV,'c')
1395         varargout = {xV.v,xV.c};
1396         return
1397     end
1398 end
1399 
1400 %-Work version out from file
1401 %-----------------------------------------------------------------------
1402 if Con
1403     Vfile = fullfile(nic_spm('Dir',Mfile),'Contents.m');
1404     skip = 0;    %-Don't skip first line
1405 else
1406     Vfile = which(Mfile);
1407     if isempty(Vfile), error(['Can''t find ',Mfile,' on MATLABPATH']); end
1408     skip = 1;    %-Skip first line
1409 end
1410 if exist(Vfile)
1411     fid = fopen(Vfile,'r');
1412     str = fgets(fid);
1413     if skip, str=fgets(fid); end
1414     fclose(fid);
1415     str(1:max(1,min(find(str~='%' & str~=' '))-1))=[];
1416     tmp = min(find(str==10|str==32));
1417     v = str(1:tmp-1);
1418     if str(tmp)==32
1419         c = str(tmp+1:tmp+min(find(str(tmp+1:end)==10))-1);
1420     else
1421         c = '(c) Copyright reserved';
1422     end
1423 else
1424     v = 'SPM';
1425     c = '(c) Copyright reserved';
1426 end
1427 
1428 %-Store version info in global variable
1429 %-----------------------------------------------------------------------
1430 if Cache
1431     eval(['global ',xVname])
1432     eval([xVname,' = struct(''v'',v,''c'',c);'])
1433 end
1434 
1435 varargout = {v,c};
1436 
1437 
1438 %=======================================================================
1439 case 'tbs'                                %-Identify installed toolboxes
1440 %=======================================================================
1441 % xTB = spm('TBs')
1442 %-----------------------------------------------------------------------
1443 
1444 % Toolbox directory
1445 %-----------------------------------------------------------------------
1446 Tdir  = fullfile(nic_spm('Dir'),'toolbox');
1447 
1448 %-List of potential installed toolboxes directories
1449 %-----------------------------------------------------------------------
1450 if exist(Tdir,'dir')
1451     d = dir(Tdir); 
1452     d = {d([d.isdir]).name};
1453     d = {d{cellfun('isempty',regexp(d,'^\.'))}};
1454 else
1455     d = {};
1456 end
1457 
1458 %-Look for a "main" M-file in each potential directory
1459 %-----------------------------------------------------------------------
1460 xTB = [];
1461 for i = 1:length(d)
1462     tdir = fullfile(Tdir,d{i});
1463     fn   = cellstr(nic_spm_select('List',tdir,['^.*' d{i} '\.m$']));
1464     if numel(fn) > 1
1465         %-Discard possible config files if ambiguity
1466         %---------------------------------------------------------------
1467         fn = {fn{cellfun('isempty',regexp(fn,'.*_config_.*'))}};
1468     end
1469     if numel(fn) == 1
1470         xTB(end+1).name = strrep(d{i},'_','');
1471         xTB(end).prog   = nic_spm_str_manip(fn{1},'r');
1472         xTB(end).dir    = tdir;
1473     elseif numel(fn) > 1
1474         % there's still an ambiguity there....
1475     end
1476 end
1477 
1478 varargout{1} = xTB;
1479 
1480 
1481 %=======================================================================
1482 case 'tblaunic_h'                                  %-Launic_h an SPM toolbox
1483 %=======================================================================
1484 % xTB = spm('TBlaunic_h',xTB,i)
1485 %-----------------------------------------------------------------------
1486 
1487 if nargin < 3, i   = 1;          else i   = varargin{3}; end
1488 if nargin < 2, xTB = nic_spm('TBs'); else xTB = varargin{2}; end
1489 
1490 if i > 0
1491     %-Addpath (& report)
1492     %-------------------------------------------------------------------
1493     if isempty(findstr(xTB(i).dir,path))
1494         addpath(xTB(i).dir,'-begin');
1495         nic_spm('alert"',{'Toolbox directory prepended to Matlab path:',...
1496             xTB(i).dir},...
1497             [xTB(i).name,' toolbox'],1);
1498     end
1499 
1500     %-Launic_h
1501     %-------------------------------------------------------------------
1502     evalin('base',xTB(i).prog);
1503 end
1504 
1505 
1506 %=======================================================================
1507 case 'colour'                                     %-SPM interface colour
1508 %=======================================================================
1509 % spm('Colour')
1510 %-----------------------------------------------------------------------
1511 %-Pre-developmental livery
1512 % varargout = {[1.0,0.2,0.3],'fightening red'};
1513 %-Developmental livery
1514 % varargout = {[0.7,1.0,0.7],'flourescent green'};
1515 %-Alpha release livery
1516 % varargout = {[0.9,0.9,0.5],'over-ripe banana'};
1517 %-Beta release livery
1518   varargout = {[0.9 0.8 0.9],'blackcurrant purple'};
1519 %-Distribution livery
1520 % varargout = {[0.8 0.8 1.0],'vile violet'};;
1521 
1522 global defaults
1523 if isempty(defaults), nic_spm_defaults; end;
1524 if isfield(defaults,'ui') && isfield(defaults.ui,'colour2'),
1525     varargout{1} = defaults.ui.colour2;
1526 end;
1527 
1528 %=======================================================================
1529 case 'getglobal'                           %-Get global variable cleanly
1530 %=======================================================================
1531 % varargout = spm('GetGlobal',varargin)
1532 %-----------------------------------------------------------------------
1533 wg = who('global');
1534 for i=1:nargin-1
1535     if any(strcmp(wg,varargin{i+1}))
1536         eval(['global ',varargin{i+1},', tmp=',varargin{i+1},';'])
1537         varargout{i} = tmp;
1538     else
1539         varargout{i} = [];
1540     end
1541 end
1542 
1543 %=======================================================================
1544 case {'cmdline','isgcmdline'}                   %-SPM command line mode?
1545 %=======================================================================
1546 % CmdLine = spm('CmdLine',CmdLine)
1547 % isGCmdLine usage is Grandfathered
1548 %-----------------------------------------------------------------------
1549 if nargin<2, CmdLine=[]; else, CmdLine = varargin{2}; end
1550 if isempty(CmdLine),
1551     global defaults
1552     if ~isempty(defaults) & isfield(defaults,'cmdline'),
1553         CmdLine = defaults.cmdline;
1554     else,
1555         CmdLine = 0;
1556     end;
1557 end
1558 varargout = {CmdLine * (get(0,'ScreenDepth')>0)};
1559 
1560 %=======================================================================
1561 case 'mlver'                       %-MatLab major & point version number
1562 %=======================================================================
1563 % v = spm('MLver')
1564 %-----------------------------------------------------------------------
1565 v = version; tmp = find(v=='.');
1566 if length(tmp)>1, varargout={v(1:tmp(2)-1)}; end
1567 
1568 %=======================================================================
1569 case 'setcmdwinlabel'      %-Set command window label (Sun OpenWin only)
1570 %=======================================================================
1571 % spm('SetCmdWinLabel',WinStripe,IconLabel)
1572 %-----------------------------------------------------------------------
1573 
1574 %-Only label Sun command tools
1575 %-----------------------------------------------------------------------
1576 Term        = getenv('TERM');
1577 if ~strcmp(Term,'sun-cmd'), return, end
1578 
1579 %-Work out label text
1580 %-----------------------------------------------------------------------
1581 User        = nic_spm('GetUser');
1582 [null,Host] = unix('echo `hostname` | sed -e ''s/\..*$//''');
1583 Host        = Host(1:length(Host)-1); 
1584 v           = nic_spm('MLver');
1585 
1586 if nargin<3, IconLabel = ['MatLab',v(1)]; end
1587 if nargin<2, WinStripe = [User,' - ',Host,' : MatLab ',v]; end
1588 
1589 %-Set window stripe
1590 %-----------------------------------------------------------------------
1591 disp([']l' WinStripe '\]L' IconLabel '\'])
1592 
1593 
1594 %=======================================================================
1595 case 'popupcb'               %-Callback handling utility for PopUp menus
1596 %=======================================================================
1597 % spm('PopUpCB',h)
1598 %-----------------------------------------------------------------------
1599 if nargin<2, h=gcbo; else, h=varargin{2}; end
1600 v   = get(h,'Value');
1601 if v==1, return, end
1602 set(h,'Value',1)
1603 CBs = get(h,'UserData');
1604 evalin('base',CBs{v-1})
1605 
1606 
1607 %=======================================================================
1608 case 'getuser'                                           %-Get user name
1609 %=======================================================================
1610 % str = spm('GetUser',fmt)
1611 %-----------------------------------------------------------------------
1612 str = nic_spm_platform('user');
1613 if ~isempty(str) & nargin>1, str = sprintf(varargin{2},str); end
1614 varargout = {str};
1615 
1616 
1617 %=======================================================================
1618 case 'beep'                                %-Emit a keyboard "bell" beep
1619 %=======================================================================
1620 % spm('Beep')
1621 fprintf('%c',7)
1622 
1623 
1624 %=======================================================================
1625 case 'time'                          %-Return formatted date/time string
1626 %=======================================================================
1627 % [timestr, date_vec] = spm('Time')
1628 %-----------------------------------------------------------------------
1629 tmp = clock;
1630 varargout = {sprintf('%02d:%02d:%02d - %02d/%02d/%4d',...
1631             tmp(4),tmp(5),floor(tmp(6)),tmp(3),tmp(2),tmp(1)),...
1632         tmp};
1633 
1634 
1635 %=======================================================================
1636 case 'pointer'                 %-Set mouse pointer in all MatLab windows
1637 %=======================================================================
1638 % spm('Pointer',Pointer)
1639 %-----------------------------------------------------------------------
1640 if nargin<2, Pointer='Arrow'; else, Pointer=varargin{2}; end
1641 set(get(0,'Children'),'Pointer',Pointer)
1642 
1643 
1644 %=======================================================================
1645 case {'alert','alert"','alert*','alert!'}                %-Alert dialogs
1646 %=======================================================================
1647 % h = spm('alert',Message,Title,CmdLine,wait)
1648 %-----------------------------------------------------------------------
1649 
1650 %- Globals
1651 %-----------------------------------------------------------------------
1652 if nargin<5, wait    = 0;  else, wait    = varargin{5}; end
1653 if nargin<4, CmdLine = []; else, CmdLine = varargin{4}; end
1654 if nargin<3, Title   = ''; else, Title   = varargin{3}; end
1655 if nargin<2, Message = ''; else, Message = varargin{2}; end
1656 Message = cellstr(Message);
1657 
1658 if isreal(CmdLine)
1659     CmdLine  = nic_spm('CmdLine',CmdLine);
1660     CmdLine2 = 0;
1661 else
1662     CmdLine  = nic_spm('CmdLine');
1663     CmdLine2 = 1;
1664 end
1665 timestr = nic_spm('Time');
1666 SPMv    = nic_spm('ver');
1667 
1668 switch(lower(Action))
1669 case 'alert',    icon = 'none';    str = '--- ';
1670 case 'alert"',    icon = 'help';    str = '~ - ';
1671 case 'alert*',    icon = 'error'; str = '* - ';
1672 case 'alert!',    icon = 'warn';    str = '! - ';
1673 end
1674 
1675 if CmdLine | CmdLine2
1676     Message(strcmp(Message,'')) = {' '};
1677     tmp = sprintf('%s: %s',SPMv,Title);
1678     fprintf('\n    %s%s  %s\n\n',str,tmp,repmat('-',1,62-length(tmp)))
1679     fprintf('        %s\n',Message{:})
1680     fprintf('\n        %s  %s\n\n',repmat('-',1,62-length(timestr)),timestr)
1681     h = [];
1682 end
1683 
1684 if ~CmdLine
1685     tmp = max(size(char(Message),2),42) - length(SPMv) - length(timestr);
1686     str = sprintf('%s  %s  %s',SPMv,repmat(' ',1,tmp-4),timestr);
1687     h   = msgbox([{''};Message(:);{''};{''};{str}],...
1688         sprintf('%s%s: %s',SPMv,spm('GetUser',' (%s)'),Title),...
1689         icon,'non-modal');
1690     drawnow
1691     set(h,'windowstyle','modal');
1692 end
1693 
1694 if wait
1695     if isempty(h)
1696         input('        press ENTER to continue...');
1697     else
1698         uiwait(h)
1699         h = [];
1700     end
1701 end
1702 
1703 if nargout, varargout = {h}; end
1704 
1705 
1706 %=======================================================================
1707 case {'fnbanner','sfnbanner','ssfnbanner'}  %-Text banners for functions
1708 %=======================================================================
1709 % SPMid = spm('FnBanner', Fn,FnV)
1710 % SPMid = spm('SFnBanner',Fn,FnV)
1711 % SPMid = spm('SSFnBanner',Fn,FnV)
1712 %-----------------------------------------------------------------------
1713 time = nic_spm('time');
1714 str  = nic_spm('ver');
1715 if nargin>=2, str = [str,': ',varargin{2}]; end
1716 if nargin>=3, str = [str,' (v',varargin{3},')']; end
1717 
1718 switch lower(Action)
1719 case 'fnbanner'
1720     tab = '';
1721     wid = 72;
1722     lch = '=';
1723 case 'sfnbanner'
1724     tab = sprintf('\t');
1725     wid = 72-8;
1726     lch = '-';
1727 case 'ssfnbanner'
1728     tab = sprintf('\t\t');
1729     wid = 72-2*8;
1730     lch = '-';
1731 end
1732 
1733 fprintf('\n%s%s',tab,str)
1734 fprintf('%c',repmat(' ',1,wid-length([str,time])))
1735 fprintf('%s\n%s',time,tab)
1736 fprintf('%c',repmat(lch,1,wid)),fprintf('\n')
1737 varargout = {str};
1738 
1739 
1740 %=======================================================================
1741 case 'fnuisetup'                %-Robust UI setup for main SPM functions
1742 %=======================================================================
1743 % [Finter,Fgraph,CmdLine] = spm('FnUIsetup',Iname,bGX,CmdLine)
1744 %-----------------------------------------------------------------------
1745 if nargin<4, CmdLine=nic_spm('CmdLine'); else, CmdLine=varargin{4}; end
1746 if nargin<3, bGX=1; else, bGX=varargin{3}; end
1747 if nargin<2, Iname=''; else, Iname=varargin{2}; end
1748 if CmdLine
1749     Finter = nic_spm_figure('FindWin','Interactive');
1750     if ~isempty(Finter), nic_spm_figure('Clear',Finter), end
1751     %if ~isempty(Iname), fprintf('%s:\n',Iname), end
1752 else
1753     Finter = nic_spm_figure('GetWin','Interactive');
1754     nic_spm_figure('Clear',Finter)
1755     if ~isempty(Iname)
1756         str = sprintf('%s (%s): %s',nic_spm('ver'),nic_spm('GetUser'),Iname);
1757     else
1758         str = '';
1759     end
1760     set(Finter,'Name',str)
1761 end
1762 
1763 if bGX
1764     Fgraph = nic_spm_figure('GetWin','Graphics');
1765     spm_figure('Clear',Fgraph)
1766 else
1767     Fgraph = nic_spm_figure('FindWin','Graphics');
1768 end
1769 varargout = {Finter,Fgraph,CmdLine};    
1770 
1771 
1772 %=======================================================================
1773 case 'figname'                                %-Robust SPM figure naming
1774 %=======================================================================
1775 % F = spm('FigName',Iname,F,CmdLine)
1776 %-----------------------------------------------------------------------
1777 if nargin<4, CmdLine=nic_spm('CmdLine'); else, CmdLine=varargin{4}; end
1778 if nargin<3, F='Interactive'; else, F=varargin{3}; end
1779 if nargin<2, Iname=''; else, Iname=varargin{2}; end
1780 
1781 %if ~isempty(Iname), fprintf('\t%s\n',Iname), end
1782 if CmdLine, varargout={[]}; return, end
1783 F = nic_spm_figure('FindWin',F);
1784 if ~isempty(F) & ~isempty(Iname)
1785     set(F,'Name',sprintf('%s (%s): %s',nic_spm('ver'),nic_spm('GetUser'),Iname))
1786 end
1787 varargout={F};
1788 
1789 
1790 %=======================================================================
1791 case 'gui_filedelete'                                %-GUI file deletion
1792 %=======================================================================
1793 % spm('GUI_FileDelete')
1794 %-----------------------------------------------------------------------
1795 P = nic_spm_select(Inf,'.*','Select file(s) to delete');
1796 n = length(P);
1797 if n==0
1798     nic_spm('alert"','Nothing selected to delete!','file delete',0);
1799     return
1800 elseif n<4
1801     str=[{' '};P];
1802 elseif n<11
1803     str=[{' '};P;{' ';sprintf('(%d files)',n)}];
1804 else
1805     str=[{' '};P(1:min(n,10));{'...';' ';sprintf('(%d files)',n)}];
1806 end
1807 if nic_spm_input(str,-1,'bd','delete|canic_el',[1,0],[],'confirm file delete')
1808     nic_spm_unlink(P{:})
1809     nic_spm('alert"',P,'file delete',1);
1810 end
1811 
1812 
1813 %=======================================================================
1814 case 'show'                   %-Bring visible MatLab windows to the fore
1815 %=======================================================================
1816 % Fs = spm('Show')
1817 %-----------------------------------------------------------------------
1818 cF = get(0,'CurrentFigure');
1819 Fs = get(0,'Children');
1820 Fs = findobj(Fs,'flat','Visible','on');
1821 for F=Fs', figure(F), end
1822 set(0,'CurrentFigure',cF)
1823 nic_spm('FnBanner','GUI show');
1824 varargout={Fs};
1825 
1826 
1827 %=======================================================================
1828 case 'clear'                                             %-Clear SPM GUI
1829 %=======================================================================
1830 % spm('Clear',Finter, Fgraph)
1831 %-----------------------------------------------------------------------
1832 if nargin<3, Fgraph='Graphics'; else, Fgraph=varargin{3}; end
1833 if nargin<2, Finter='Interactive'; else, Finter=varargin{2}; end
1834 nic_spm_figure('Clear',Fgraph)
1835 nic_spm_figure('Clear',Finter)
1836 nic_spm('Pointer','Arrow')
1837 nic_spm_select('clearvfiles');
1838 nic_spm_conman('Initialise','reset');
1839 local_clc, nic_spm('FnBanner','GUI cleared');
1840 fprintf('\n');
1841 %evalin('Base','clear')
1842 
1843 
1844 %=======================================================================
1845 case 'help'                                  %-Pass through for spm_help
1846 %=======================================================================
1847 % spm('Help',varargin)
1848 %-----------------------------------------------------------------------
1849 if nargin>1, nic_spm_help(varargin{2:end}), else, nic_spm_help, end
1850 
1851 
1852 %=======================================================================
1853 otherwise                                        %-Unknown action string
1854 %=======================================================================
1855 error('Unknown action string')
1856 
1857 %=======================================================================
1858 end
1859 
1860 
1861 %=======================================================================
1862 function realign_unwarp(ob,varargin)
1863 % Choose either realign or unwarp
1864 %=======================================================================
1865 if get(ob,'Value')==1,
1866     nic_spm_jobman('interactive','','jobs.spatial.realign');
1867 else
1868     nic_spm_jobman('interactive','','jobs.spatial.realignunwarp');
1869 end
1870 
1871 
1872 %=======================================================================
1873 function local_clc
1874 %=======================================================================
1875 if str2num(version('-release'))~=14 || ~isdeployed,
1876     clc
1877 end

Generated on Wed 29-Apr-2009 01:06:38 by m2html © 2005