0001 function varargout=nic_spm(varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244
0245
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255
0256
0257
0258
0259
0260
0261
0262
0263
0264
0265
0266
0267
0268
0269
0270
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284
0285
0286
0287
0288
0289
0290
0291
0292
0293
0294
0295
0296
0297
0298
0299
0300
0301
0302 Modalities = {'PET','FMRI','EEG'};
0303
0304
0305
0306 if nargin == 0, Action='Welcome'; else, Action = varargin{1}; end
0307
0308
0309
0310 switch lower(Action), case 'welcome'
0311
0312
0313 nic_spm_defaults;
0314 global defaults
0315 if isfield(defaults,'modality'), nic_spm(defaults.modality); return; end;
0316
0317
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
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
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'
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)
0453
0454
0455
0456
0457
0458
0459
0460
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
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
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
0480
0481 nic_spm_defaults; fprintf('.');
0482
0483
0484
0485 nic_spm('ChMod',Modality); fprintf('.');
0486
0487
0488
0489 set([Fmenu,Finter,Fgraph],'Visible','on'); fprintf('done\n\n');
0490
0491
0492
0493 fprintf('SPM present working directory:\n\t%s\n',pwd)
0494
0495
0496
0497 case 'createmenuwin'
0498
0499
0500 if nargin<2, Vis='on'; else, Vis=varargin{2}; end
0501
0502
0503 delete(nic_spm_figure('FindWin','Menu'))
0504
0505
0506
0507 WS = nic_spm('WinScale');
0508 FS = nic_spm('FontSizes');
0509 PF = nic_spm_platform('fonts');
0510 Rect = nic_spm('WinSize','Menu','raw').*WS;
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
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
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
0679
0680
0681
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
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
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
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
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
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
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
0966
0967
0968
0969
0970
0971
0972
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
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
1033
1034
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
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'
1129
1130
1131
1132 if nargin<2, Vis='on'; else, Vis=varargin{2}; end
1133
1134
1135 delete(nic_spm_figure('FindWin','Interactive'))
1136
1137 FS = nic_spm('FontSizes');
1138 PF = nic_spm_platform('fonts');
1139 Rect = nic_spm('WinSize','Interactive');
1140
1141
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'
1163
1164
1165
1166
1167
1168
1169 if nargin<2, Modality = ''; else, Modality = varargin{2}; end
1170 [Modality,ModNum] = nic_spm('CheckModality',Modality);
1171
1172
1173
1174 nic_spm('defaults',Modality);
1175
1176
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'
1202
1203
1204
1205 global defaults
1206 if isempty(defaults), nic_spm_defaults; end;
1207
1208
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');
1214 defaults.TWD = nic_spm_platform('tempdir');
1215
1216
1217
1218 global UFp
1219 if strcmpi(defaults.modality,'pet')
1220 UFp = defaults.stats.pet.ufp;
1221 elseif strcmpi(defaults.modality,'fmri')
1222 UFp = defaults.stats.fmri.ufp;
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'
1233
1234
1235
1236 delete(get(0,'Children'));
1237 local_clc;
1238 fprintf('Bye for now...\n\n');
1239
1240
1241
1242 case 'checkmodality'
1243
1244
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'}
1270
1271
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
1288
1289
1290
1291
1292 case {'fontsize','fontsizes','fontscale'}
1293
1294
1295
1296
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'
1312
1313
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
1328 Rect = Rect(1,:);
1329 elseif upper(Win(1))=='I'
1330
1331 Rect = Rect(2,:);
1332 elseif upper(Win(1))=='G'
1333
1334 Rect = Rect(3,:);
1335 elseif Win(1)=='0'
1336
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'
1353
1354
1355
1356 if nargin<2, Mfile='spm'; else, Mfile=varargin{2}; end
1357 SPMdir = which(Mfile);
1358 if isempty(SPMdir)
1359 if exist(Mfile,'file')==2
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'
1376
1377
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
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
1401
1402 if Con
1403 Vfile = fullfile(nic_spm('Dir',Mfile),'Contents.m');
1404 skip = 0;
1405 else
1406 Vfile = which(Mfile);
1407 if isempty(Vfile), error(['Can''t find ',Mfile,' on MATLABPATH']); end
1408 skip = 1;
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
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'
1440
1441
1442
1443
1444
1445
1446 Tdir = fullfile(nic_spm('Dir'),'toolbox');
1447
1448
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
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
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
1475 end
1476 end
1477
1478 varargout{1} = xTB;
1479
1480
1481
1482 case 'tblaunic_h'
1483
1484
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
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
1501
1502 evalin('base',xTB(i).prog);
1503 end
1504
1505
1506
1507 case 'colour'
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518 varargout = {[0.9 0.8 0.9],'blackcurrant purple'};
1519
1520
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'
1530
1531
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'}
1545
1546
1547
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'
1562
1563
1564
1565 v = version; tmp = find(v=='.');
1566 if length(tmp)>1, varargout={v(1:tmp(2)-1)}; end
1567
1568
1569 case 'setcmdwinlabel'
1570
1571
1572
1573
1574
1575
1576 Term = getenv('TERM');
1577 if ~strcmp(Term,'sun-cmd'), return, end
1578
1579
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
1590
1591 disp([']l' WinStripe '\]L' IconLabel '\'])
1592
1593
1594
1595 case 'popupcb'
1596
1597
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'
1609
1610
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'
1619
1620
1621 fprintf('%c',7)
1622
1623
1624
1625 case 'time'
1626
1627
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'
1637
1638
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!'}
1646
1647
1648
1649
1650
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'}
1708
1709
1710
1711
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'
1742
1743
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
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'
1774
1775
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
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'
1792
1793
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'
1815
1816
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'
1829
1830
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
1842
1843
1844
1845 case 'help'
1846
1847
1848
1849 if nargin>1, nic_spm_help(varargin{2:end}), else, nic_spm_help, end
1850
1851
1852
1853 otherwise
1854
1855 error('Unknown action string')
1856
1857
1858 end
1859
1860
1861
1862 function realign_unwarp(ob,varargin)
1863
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