0001 function varargout=phiwave(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 PWver = '3.2';
0035
0036
0037 MBver = '0.38.2';
0038
0039
0040 global PHI;
0041
0042
0043
0044 if nargin == 0, Action='Startup'; else, Action = varargin{1}; end
0045
0046
0047 switch lower(Action), case 'startup'
0048
0049
0050
0051 warning backtrace
0052
0053
0054 splashf = ~phiwave('is_started');
0055
0056
0057 phiwave('on');
0058
0059
0060
0061 S = get(0,'ScreenSize');
0062 if all(S==1), error('Can''t open any graphics windows...'), end
0063 PF = spm_platform('fonts');
0064
0065
0066
0067 if splashf
0068 phiwave('splash');
0069 end
0070
0071
0072
0073 Fmenu = phiwave('CreateMenuWin','off');
0074
0075
0076
0077 set([Fmenu],'Visible','on')
0078
0079
0080 case 'on'
0081
0082
0083
0084 if isempty(which('spm'))
0085 error('SPM does not appear to be on the path')
0086 end
0087
0088
0089 if isempty(which('marsbar'))
0090 marsbar_path = fullfile(spm('dir'), 'toolbox', 'marsbar');
0091 if exist(marsbar_path, 'dir')
0092 addpath(marsbar_path);
0093 else
0094 error('Cannot find MarsBaR - MarsBaR should be on your matlab path');
0095 end
0096 end
0097
0098
0099 badv = 1;
0100 try
0101 badv = mars_utils('version_less_than', marsbar('ver'), MBver);
0102 end
0103 if badv, error(['Need at least MarsBaR version ' MBver]); end
0104
0105
0106 marsbar('on');
0107
0108
0109 pwpath = fileparts(which('phiwave.m'));
0110 PHI.ADDPATHS = {fullfile(pwpath, 'uvi_wave')};
0111 addpath(PHI.ADDPATHS{:}, '-begin');
0112 fprintf('Phiwave analysis functions prepended to path\n');
0113
0114
0115 mars_veropts('defaults');
0116
0117
0118
0119 if isfield(PHI, 'ARMOIRE')
0120 o = PHI.ARMOIRE;
0121 else
0122 o = marmoire;
0123 end
0124
0125 spm_design_filter = mars_veropts('design_filter_spec');
0126 filter_specs = {spm_design_filter,...
0127 {'*phiw_spm.mat', 'Phiwave results (*phiw_spm.mat)'}};
0128 o = add_if_absent(o, 'def_design', ...
0129 struct('default_file_name', 'SPMcfg.mat',...
0130 'filter_spec', {filter_specs{1}},...
0131 'title', 'Default design',...
0132 'set_action','phiw_arm_call(''set_design'',o,item,old_o)'));
0133 o = add_if_absent(o, 'est_design',...
0134 struct('default_file_name', 'untitled_phiw_spm.mat',...
0135 'filter_spec', {filter_specs{2}},...
0136 'title', 'Phiwave estimated design',...
0137 'set_action', 'phiw_arm_call(''set_results'',o,item,old_o)'));
0138 PHI.ARMOIRE = o;
0139
0140
0141 if ~isfield(PHI, 'WORKSPACE'), PHI.WORKSPACE = []; end
0142
0143
0144 if ~mars_struct('isthere', PHI, 'OPTIONS')
0145 loadf = 1;
0146 PHI.OPTIONS = [];
0147 else
0148 loadf = 0;
0149 end
0150 [pwdefs sourcestr] = phiw_options('Defaults');
0151 PHI.OPTIONS = phiw_options('fill', PHI.OPTIONS, pwdefs);
0152 if loadf
0153 fprintf('Loaded Phiwave defaults from %s\n',sourcestr);
0154 end
0155
0156
0157 case 'off'
0158
0159
0160
0161 varargout = {0};
0162
0163
0164 if ~phiwave('is_started'), return, end
0165
0166
0167 btn = phiw_arm('save_ui', 'all', struct('ync', 1, 'no_no_save', 1));
0168 if btn == -1, varargout = {-1}; return, end
0169
0170
0171 rmpath(PHI.ADDPATHS{:});
0172 marsbar('off');
0173 fprintf('Phiwave analysis functions removed from path\n');
0174
0175
0176 case 'quit'
0177
0178
0179
0180
0181
0182 if phiwave('off') == -1, return, end
0183
0184
0185 if ~phiwave('is_started'), return, end
0186
0187
0188 delete(spm_figure('FindWin','Phiwave'));
0189 fprintf('Arrivederci...\n\n');
0190
0191
0192 case 'is_started'
0193
0194
0195 varargout = {~isempty(PHI)};
0196
0197
0198 case 'cfgfile'
0199
0200
0201 cfgfile = 'phiwavecfg.mat';
0202 varargout = {which(cfgfile), cfgfile};
0203
0204
0205 case 'createmenuwin'
0206
0207
0208 if nargin<2, Vis='on'; else, Vis=varargin{2}; end
0209
0210
0211 delete(spm_figure('FindWin','Phiwave'))
0212
0213
0214 [PWver,PWc] = phiwave('Ver');
0215
0216
0217
0218 WS = spm('WinScale');
0219 FS = spm('FontSizes');
0220 PF = spm_platform('fonts');
0221 Rect = [50 600 300 275];
0222 bno = 4; bgno = bno+1;
0223 bgapr = 0.25;
0224 bh = Rect(4) / (bno + bgno*bgapr);
0225 gh = bh * bgapr;
0226 by = fliplr(cumsum([0 ones(1, bno-1)*(bh+gh)])+gh);
0227 bx = Rect(3)*0.1;
0228 bw = Rect(3)*0.8;
0229 Fmenu = figure('IntegerHandle','off',...
0230 'Name',sprintf('%s',PWc),...
0231 'NumberTitle','off',...
0232 'Tag','Phiwave',...
0233 'Position',Rect.*WS,...
0234 'Resize','off',...
0235 'Color',[1 1 1]*.8,...
0236 'UserData',struct('PWver',PWver,'PWc',PWc),...
0237 'MenuBar','none',...
0238 'DefaultTextFontName',PF.helvetica,...
0239 'DefaultTextFontSize',FS(12),...
0240 'DefaultUicontrolFontName',PF.helvetica,...
0241 'DefaultUicontrolFontSize',FS(12),...
0242 'DefaultUicontrolInterruptible','on',...
0243 'Renderer','painters',...
0244 'Visible','off');
0245
0246
0247
0248
0249
0250 fw_st = 'struct(''force'', 1, ''warn_empty'', 1)';
0251 funcs = {...
0252 'phiwave(''make_design'', ''pet'');',...
0253 'phiwave(''make_design'', ''fmri'');',...
0254 'phiwave(''make_design'', ''basic'');',...
0255 'phiwave(''design_report'')',...
0256 'phiwave(''add_images'')',...
0257 'phiwave(''edit_filter'')',...
0258 'phiwave(''check_images'')',...
0259 'phiwave(''list_images'')',...
0260 'phiwave(''ana_cd'')',...
0261 'phiwave(''ana_desmooth'')',...
0262 'phiwave(''explicit_mask'')',...
0263 'phiwave(''def_from_est'')',...
0264 'phiwave(''set_def'');',...
0265 ['phiw_arm(''save_ui'', ''def_design'', ' fw_st ');'],...
0266 'phiw_arm(''show_summary'', ''def_design'')'};
0267
0268 uicontrol(Fmenu,'Style','PopUp',...
0269 'String',['Design...'...
0270 '|PET models',...
0271 '|FMRI models',...
0272 '|Basic models',...
0273 '|Explore',...
0274 '|Add images to FMRI design',...
0275 '|Add/edit filter for FMRI design',...
0276 '|Check image names in design',...
0277 '|List image names to console',...
0278 '|Change design path to images',...
0279 '|Convert to unsmoothed',...
0280 '|Set explicit mask for design',...
0281 '|Set design from estimated',...
0282 '|Set design from file',...
0283 '|Save design to file',...
0284 '|Show default design summary'],...
0285 'Position',[bx by(1) bw bh].*WS,...
0286 'ToolTipString','Set/specify design...',...
0287 'CallBack','spm(''PopUpCB'',gcbo)',...
0288 'UserData',funcs);
0289
0290
0291 funcs = {...
0292 'phiwave(''estimate'');',...
0293 'phiwave(''merge_contrasts'');',...
0294 'phiwave(''add_trial_f'');',...
0295 'phiwave(''set_defcon'');',...
0296 'phiwave(''writecons'')',...
0297 'phiwave(''denoisecon'')',...
0298 'phiw_display(''display'', ''slices'')',...
0299 'phiw_display(''display'', ''orth'')',...
0300 'phiwave(''set_results'');',...
0301 ['phiw_arm(''save_ui'', ''est_design'', ' fw_st ');'],...
0302 'phiw_arm(''show_summary'', ''est_design'')'};
0303
0304 uicontrol(Fmenu,'Style','PopUp',...
0305 'String',['Results...'...
0306 '|Estimate results',...
0307 '|Import contrasts',...
0308 '|Add trial-specific F',...
0309 '|Default contrast...',...
0310 '|Specify / write contrast', ...
0311 '|Denoise contrast' ...
0312 '|Display slices',...
0313 '|Display sections',...
0314 '|Set results from file',...
0315 '|Save results to file',...
0316 '|Show estimated design summary'],...
0317 'Position',[bx by(2) bw bh].*WS,...
0318 'ToolTipString','Write/display contrasts...',...
0319 'CallBack','spm(''PopUpCB'',gcbo)',...
0320 'UserData',funcs);
0321
0322 funcs = {'global PHI; PHI.OPTIONS=phiw_options(''load'');',...
0323 'phiw_options(''save'');',...
0324 'global PHI; PHI.OPTIONS=phiw_options(''edit'');',...
0325 ['global PHI; [PHI.OPTIONS str]=phiw_options(''defaults'');' ...
0326 ' fprintf(''Defaults loaded from %s\n'', str)']};
0327
0328 uicontrol(Fmenu,'Style','PopUp',...
0329 'String',['Options...'...
0330 '|Load options|Save options|Edit options|Restore defaults'],...
0331 'Position',[bx by(3) bw bh].*WS,...
0332 'ToolTipString','Load/save/edit Phiwave options',...
0333 'CallBack','spm(''PopUpCB'',gcbo)',...
0334 'UserData',funcs);
0335
0336
0337 uicontrol(Fmenu,'String','Quit',...
0338 'Position',[bx by(bno) bw bh].*WS,...
0339 'ToolTipString','exit Phiwave',...
0340 'ForeGroundColor','r',...
0341 'Interruptible','off',...
0342 'CallBack','phiwave(''Quit'')');
0343
0344
0345
0346 set(Fmenu,'CloseRequestFcn','phiwave(''Quit'')')
0347 set(Fmenu,'Visible',Vis)
0348
0349 varargout = {Fmenu};
0350
0351
0352 case {'ver', 'version'}
0353
0354
0355
0356 varargout = {PWver, 'Phiwave - wavelet analysis toolbox'};
0357
0358
0359 case 'splash'
0360
0361
0362
0363
0364 WS = spm('WinScale');
0365 [X,map] = imread('phiwave.jpg');
0366 aspct = size(X,1) / size(X,2);
0367 ww = 400;
0368 srect = [200 300 ww ww*aspct] .* WS;
0369 h = figure('visible','off',...
0370 'menubar','none',...
0371 'numbertitle','off',...
0372 'name','Welcome to Phiwave',...
0373 'pos',srect);
0374 im = image(X);
0375 colormap(map);
0376 ax = get(im, 'Parent');
0377 axis off;
0378 axis image;
0379 axis tight;
0380 set(ax,'plotboxaspectratiomode','manual',...
0381 'unit','pixels',...
0382 'pos',[0 0 srect(3:4)]);
0383 set(h,'visible','on');
0384 pause(3);
0385 close(h);
0386
0387
0388 case 'make_design'
0389
0390
0391
0392 if nargin < 2
0393 des_type = 'basic';
0394 else
0395 des_type = varargin{2};
0396 end
0397 if sf_prev_save('def_design') == -1, return, end
0398 D = ui_build(mars_veropts('default_design'), des_type);
0399 phiw_arm('set', 'def_design', D);
0400 phiwave('design_report');
0401
0402
0403 case 'list_images'
0404
0405
0406
0407 phiwD = phiw_arm('get', 'def_design');
0408 if isempty(phiwD), return, end;
0409 if has_images(phiwD)
0410 P = image_names(phiwD);
0411 strvcat(P{:})
0412 else
0413 disp('Design does not contain images');
0414 end
0415
0416
0417 case 'check_images'
0418
0419
0420
0421 phiwD = phiw_arm('get', 'def_design');
0422 if isempty(phiwD), return, end;
0423 if ~has_images(phiwD)
0424 disp('Design does not contain images');
0425 return
0426 end
0427
0428 P = image_names(phiwD);
0429 P = strvcat(P{:});
0430 ok_f = 1;
0431 for i = 1:size(P, 1)
0432 fname = deblank(P(i,:));
0433 if ~exist(fname, 'file');
0434 fprintf('Image %d: %s does not exist\n', i, fname);
0435 ok_f = 0;
0436 end
0437 end
0438 if ok_f
0439 disp('All images in design appear to exist');
0440 end
0441
0442
0443 case 'ana_cd'
0444
0445
0446
0447 phiwD = phiw_arm('get', 'def_design');
0448 if isempty(phiwD), return, end;
0449
0450
0451 [Finter,Fgraph,CmdLine] = spm('FnUIsetup','Change image path in design', 0);
0452
0453
0454 P = image_names(phiwD);
0455 P = strvcat(P{:});
0456 root_names = spm_str_manip(P, 'H');
0457 spm_input(deblank(root_names(1,:)),1,'d','Common path is:');
0458
0459
0460 newpath = spm_get([-1 0], '', 'New directory root for files');
0461 if isempty(newpath), return, end
0462
0463
0464 phiwD = cd_images(phiwD, newpath);
0465 phiw_arm('set', 'def_design', phiwD);
0466
0467
0468 case 'ana_desmooth'
0469
0470
0471
0472 phiwD = phiw_arm('get', 'def_design');
0473 if isempty(phiwD), return, end;
0474 phiwD = prefix_images(phiwD, 'remove', 's');
0475 phiw_arm('set', 'def_design', phiwD);
0476 disp('Done');
0477
0478
0479 case 'explicit_mask'
0480
0481
0482
0483 phiwD = phiw_arm('get', 'def_design');
0484 if isempty(phiwD), return, end;
0485 mask_img = spm_get([0 1], mars_veropts('get_img_ext'), ...
0486 'Select explicit masking image for design');
0487 if isempty(mask_img), return, end
0488 phiwD = explicit_mask(phiwD, mask_img);
0489 phiw_arm('set', 'def_design', phiwD);
0490 disp('Done');
0491
0492
0493 case 'add_images'
0494
0495
0496
0497 phiwD = phiw_arm('get', 'def_design');
0498 if isempty(phiwD), return, end
0499 if ~is_fmri(phiwD), return, end
0500 phiwD = fill(phiwD, {'images'});
0501 phiw_arm('update', 'def_design', phiwD);
0502 phiw_arm('set_param', 'def_design', 'file_name', '');
0503 phiw_arm('show_summary', 'def_design');
0504
0505
0506 case 'edit_filter'
0507
0508
0509
0510 phiwD = phiw_arm('get', 'def_design');
0511 if isempty(phiwD), return, end
0512 if ~is_fmri(phiwD), return, end
0513 tmp = {'filter'};
0514 if ~strcmp(type(phiwD), 'SPM99'), tmp = [tmp {'autocorr'}]; end
0515 phiwD = fill(phiwD, tmp);
0516 phiw_arm('update', 'def_design', phiwD);
0517 phiw_arm('set_param', 'def_design', 'file_name', '');
0518 phiw_arm('show_summary', 'def_design');
0519
0520
0521 case 'def_from_est'
0522
0523
0524
0525 phiwE = phiw_arm('get', 'est_design');
0526 if isempty(phiwE), return, end;
0527 errf = phiw_arm('set', 'def_design', phiwE);
0528 if ~errf, phiwave('design_report'); end
0529
0530
0531 case 'set_def'
0532
0533
0534
0535 if phiw_arm('set_ui', 'def_design'), return, end
0536 phiwave('design_report');
0537
0538
0539 case 'design_report'
0540
0541
0542
0543 phiwD = phiw_arm('get', 'def_design');
0544 if isempty(phiwD), return, end;
0545 spm('FnUIsetup','Explore design', 0);
0546
0547 fprintf('%-40s: ','Design reporting');
0548 ui_report(phiwD, 'DesMtx');
0549 ui_report(phiwD, 'DesRepUI');
0550 fprintf('%30s\n','...done');
0551
0552
0553 case 'estimate'
0554
0555
0556
0557 phiwD= phiw_arm('get', 'def_design');
0558 if isempty(phiwD), return, end
0559 if sf_prev_save('est_design') == -1, return, end
0560 flags = mars_struct('merge', PHI.OPTIONS.wt, PHI.OPTIONS.statistics);
0561 phiwRes = estimate(phiwD, [], flags);
0562 phiw_arm('set', 'est_design', phiwRes);
0563 phiw_arm('show_summary', 'est_design');
0564
0565
0566 case 'set_results'
0567
0568
0569
0570
0571 varargout = {0};
0572
0573
0574 if sf_prev_save('est_design') == -1, return, end
0575
0576
0577 phiw_arm('set_ui', 'est_design');
0578 if phiw_arm('isempty', 'est_design'), return, end
0579
0580
0581 phiwRes = phiw_arm('get', 'est_design');
0582
0583
0584 if mars_struct('isthere', PHI, 'WORKSPACE', 'default_contrast')
0585 PHI.WORKSPACE.default_contrast = [];
0586 fprintf('Reset of estimated design, cleared default contrast...\n');
0587 end
0588
0589
0590 fprintf('%-40s: ','Design reporting');
0591 ui_report(phiwRes, 'DesMtx');
0592 ui_report(phiwRes, 'DesRepUI');
0593 fprintf('%30s\n','...done');
0594
0595 varargout = {1};
0596 return
0597
0598
0599 case 'set_defcon'
0600
0601
0602
0603 varargout = {[]};
0604 phiwRes = phiw_arm('get', 'est_design');
0605 if isempty(phiwRes), return, end
0606
0607
0608 [Finter,Fgraph,CmdLine] = spm('FnUIsetup','Default contrast', 0);
0609 Ic = mars_struct('getifthere',PHI, 'WORKSPACE', 'default_contrast');
0610 if isempty(Ic)
0611 cname = '[Not set]';
0612 else
0613 xCon = get_contrasts(phiwRes);
0614 cname = xCon(Ic).name;
0615 end
0616 spm_input(cname, 1, 'd', 'Default contrast');
0617 opts = {'Quit', 'Set new default'};
0618 if ~isempty(Ic), opts = [opts {'Clear default contrast'}]; end
0619 switch spm_input('What to do?', '+1', 'm', opts, [1:length(opts)], 1);
0620 case 1
0621 case 2
0622 [Ic phiwRes changef] = ui_get_contrasts(phiwRes, 'T|F',1,...
0623 'Select default contrast','',1);
0624 if changef
0625 phiw_arm('update', 'est_design', phiwRes);
0626 end
0627 case 3
0628 Ic = [];
0629 end
0630 PHI.WORKSPACE.default_contrast = Ic;
0631 varargout = {Ic};
0632
0633
0634 case 'merge_contrasts'
0635
0636
0637
0638 D = phiw_arm('get', 'est_design');
0639 if isempty(D), return, end
0640 filter_spec = {...
0641 'SPM.mat','SPM: SPM.mat';...
0642 '*phiw_spm.mat','Phiwave: *phiw_spm.mat';...
0643 '*x?on.mat','xCon.mat file'};
0644 [fn pn] = mars_uifile('get', ...
0645 filter_spec, ...
0646 'Source design/contrast file...');
0647 if isequal(fn,0) | isequal(pn,0), return, end
0648 fname = fullfile(pn, fn);
0649 D2 = mardo(fname);
0650
0651
0652 if ~has_contrasts(D2)
0653 error(['Cannot find contrasts in design/contrast file ' fname]);
0654 end
0655
0656
0657 if ~is_valid(D2)
0658 D2 = get_contrasts(D2);
0659 end
0660
0661 [D Ic changef] = add_contrasts(D, D2, 'ui');
0662 disp('Done');
0663 if changef
0664 phiw_arm('update', 'est_design', D);
0665 end
0666
0667
0668 case 'add_trial_f'
0669
0670
0671
0672 D = phiw_arm('get', 'est_design');
0673 if isempty(D), return, end
0674 if ~is_fmri(D)
0675 disp('Can only add trial specific F contrasts for FMRI designs');
0676 return
0677 end
0678 [D changef] = add_trial_f(D);
0679 disp('Done');
0680 if changef
0681 phiw_arm('update', 'est_design', D);
0682 end
0683
0684
0685
0686 case 'writecons'
0687
0688
0689
0690
0691 phiwRes = phiw_arm('get', 'est_design');
0692 if isempty(phiwRes), return, end
0693 Ic = mars_struct('getifthere', PHI, 'WORKSPACE', 'default_contrast');
0694 if ~isempty(Ic)
0695 xCon = get_contrasts(phiwRes);
0696 fprintf('Using default contrast: %s\n', xCon(Ic).name);
0697 end
0698 flags = struct('t_only', 1, 'con_only', 1);
0699 [phiwRes connos changef] = write_contrasts(phiwRes, Ic, flags);
0700 if changef
0701 phiw_arm('update', 'est_design', phiwRes);
0702 end
0703
0704
0705 case 'denoisecon'
0706
0707
0708
0709 phiwRes = phiw_arm('get', 'est_design');
0710 if isempty(phiwRes), return, end
0711 Ic = mars_struct('getifthere', PHI, 'WORKSPACE', 'default_contrast');
0712 if ~isempty(Ic)
0713 xCon = get_contrasts(phiwRes);
0714 fprintf('Using default contrast: %s\n', xCon(Ic).name);
0715 end
0716 [Vdcon Vderr phiwRes changef] = get_wdimg(phiwRes, Ic, PHI.OPTIONS.denoise);
0717 if changef
0718 phiw_arm('update', 'est_design', phiwRes);
0719 end
0720 if isempty(Vdcon),return,end
0721 phiw_display('display', [], Vdcon);
0722
0723
0724 case 'make'
0725
0726
0727
0728
0729
0730
0731
0732
0733
0734
0735
0736
0737
0738
0739 if nargin < 2
0740 optfile = '';
0741 else
0742 optfile = varargin{2};
0743 end
0744
0745 if ~isempty(optfile)
0746 if ~exist(optfile, 'file')
0747 error(['optfile ' optfile ' does not appear to exist']);
0748 end
0749 optfile = [' -f ' optfile];
0750 end
0751
0752 mexfiles = { {'uvi_wave'}, ...
0753 {'do_wtx.c', 'do_iwtx.c'};...
0754 {'@phiw_wvimg', 'private'}, {'pplot_elbow.c'} };
0755
0756 pwd_orig = pwd;
0757 phiwave_dir = fileparts(which('phiwave.m'));
0758 if isempty(phiwave_dir)
0759 error('Can''t find phiwave on the matlab path');
0760 end
0761 try
0762 for d = 1:size(mexfiles, 1)
0763 cd(fullfile(phiwave_dir, mexfiles{d}{:}));
0764 files = mexfiles{d, 2};
0765 for f = 1:length(files)
0766 fprintf('Compiling %s\n', fullfile(pwd, files{f}));
0767 if isempty(optfile)
0768 mex(files{f});
0769 else
0770 mex(optfile, files{f});
0771 end
0772 end
0773 end
0774 cd(pwd_orig);
0775 catch
0776 cd(pwd_orig);
0777 rethrow(lasterror);
0778 end
0779
0780
0781 case 'error_log'
0782
0783
0784
0785 if nargin < 2
0786 fname = 'error_log.mat';
0787 else
0788 fname = varargin{2};
0789 end
0790
0791 e_log = struct('last_error', lasterr, ...
0792 'm_ver', phiwave('ver'),...
0793 'mars', PHI);
0794 savestruct(fname, e_log);
0795 if ~isempty(which('zip'))
0796 zip([fname '.zip'], fname);
0797 fname = [fname '.zip'];
0798 end
0799 disp(['Saved error log as ' fname]);
0800
0801
0802 case 'phiw_menu'
0803
0804
0805
0806
0807 [tstr pstr optfields optlabs] = deal(varargin{2:5});
0808 if nargin < 6
0809 optargs = cell(1, length(optfields));
0810 else
0811 optargs = varargin{6};
0812 end
0813
0814 [Finter,Fgraph,CmdLine] = spm('FnUIsetup',tstr);
0815 of_end = length(optfields)+1;
0816 my_task = spm_input(pstr, '+1', 'm',...
0817 {optlabs{:} 'Quit'},...
0818 [1:of_end],of_end);
0819 if my_task == of_end, return, end
0820 phiwave(optfields{my_task}{:});
0821
0822
0823 otherwise
0824
0825 error(['Unknown action string: ' Action])
0826
0827
0828 end
0829 return
0830
0831
0832
0833
0834 function btn = sf_prev_save(obj_name)
0835 btn = mars_arm('save_ui', obj_name, ...
0836 struct('ync', 1, ...
0837 'no_no_save', 1, ...
0838 'prompt_prefix', 'previous '));
0839
0840 if btn == 0
0841 mars_arm('set_param', obj_name, 'has_changed', 0);
0842 end
0843 return