Home > phiwave > phiw_arm_call.m

phiw_arm_call

PURPOSE ^

services callbacks from marmoire object set functions

SYNOPSIS ^

function [o,errf,msg] = phiw_arm_call(action, o, item, old_o)

DESCRIPTION ^

 services callbacks from marmoire object set functions
 FORMAT [o,errf,msg] = phiw_arm_call(action, o, item)
 See documentation for marmoire object for more detail

 action     - action string
 o          - candidate object for checking etc
 item       - name of item that has just been set
 old_o      - object before set

 Returns
 o          - possibly modified object
 errf       - flag, set if error in processing
 msg        - message to examplain error

 $Id: phiw_arm_call.m,v 1.1 2005/05/31 23:36:35 matthewbrett Exp $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [o,errf,msg] = phiw_arm_call(action, o, item, old_o)
0002 % services callbacks from marmoire object set functions
0003 % FORMAT [o,errf,msg] = phiw_arm_call(action, o, item)
0004 % See documentation for marmoire object for more detail
0005 %
0006 % action     - action string
0007 % o          - candidate object for checking etc
0008 % item       - name of item that has just been set
0009 % old_o      - object before set
0010 %
0011 % Returns
0012 % o          - possibly modified object
0013 % errf       - flag, set if error in processing
0014 % msg        - message to examplain error
0015 %
0016 % $Id: phiw_arm_call.m,v 1.1 2005/05/31 23:36:35 matthewbrett Exp $
0017   
0018 if nargin < 1
0019   error('Need action');
0020 end
0021 if nargin < 2
0022   error('Need object');
0023 end
0024 if nargin < 3
0025   error('Need item name');
0026 end
0027 if nargin < 4
0028   error('Need old object');
0029 end
0030 
0031 errf = 0; msg = ''; 
0032 
0033 item_struct = get_item_struct(o, item);
0034 
0035 switch lower(action)
0036  case 'set_design'
0037   % callback for setting design
0038 
0039   % Check for save of current design
0040   [btn o] = save_item_data_ui(old_o, 'def_design', ...
0041                   struct('ync', 1, ...
0042                      'prompt_prefix','previous '));
0043   if btn == -1
0044     errf = 1; 
0045     msg = 'Cancelled save of previous design'; 
0046     return
0047   end
0048   
0049   % Make design into object, do conversions
0050   [item_struct.data errf msg] = sf_check_design(item_struct.data);
0051   if errf, o = []; return, end
0052   o = set_item_struct(o, item, item_struct);
0053   
0054  case 'set_results'
0055   % callback for setting results
0056 
0057   % Need to set default data from results, and load contrast file
0058   % if not present (this is so for old MarsBaR results)
0059 
0060   data = item_struct.data;
0061   if isempty(data), return, end
0062   
0063   % Check for save of current design
0064   [btn o] = save_item_data_ui(old_o, 'est_design', ...
0065                   struct('ync', 1, ...
0066                      'prompt_prefix','previous '));
0067   if btn == -1
0068     errf = 1;
0069     msg = 'Cancelled save of current design'; 
0070     return
0071   end
0072 
0073   % Make design into object, do conversions
0074   [data errf msg] = sf_check_design(data);
0075   if errf, return, end
0076   if ~is_phiw_estimated(data)
0077     error('Design has not been estimated')
0078   end
0079   
0080   % Put data into object
0081   item_struct.data = data;
0082   o = set_item_struct(o, item, item_struct);
0083   
0084  otherwise
0085   error(['Peverse request for ' action]);
0086 end
0087 
0088 function [d,errf,msg] = sf_check_design(d)
0089 % Make design into object, do conversions
0090 errf = 0; msg = {};
0091 d = phido(d);
0092 if ~is_valid(d)
0093   errf = 1; 
0094   msg = 'This does not appear to be a valid design';
0095 end
0096 return
0097

Generated on Wed 06-Jul-2005 18:07:21 by m2html © 2003