Home > marsbar > @mardo_2 > mardo_2.m

mardo_2

PURPOSE ^

class constructor for SPM2 MarsBaR design object

SYNOPSIS ^

function [o, others] = mardo_2(params, others, varargin)

DESCRIPTION ^

 class constructor for SPM2 MarsBaR design object
 FORMAT [o, others] = mardo_2(params, others, varargin)
 Inputs
 params  - structure,containing fields, or SPM/MarsBaR design
 others  - structure, containing other fields to define

 Outputs
 o       - mardo_2 object (unless disowned)
 others  - any unrecognized fields from params, for processing by
           children

 This object is called from the mardo object contructor
 with a mardo object as input.  mardo_2 checks to see
 if the contained design is an SPM2 design, returns
 the object unchanged if not.  If it is an SPM2
 design, it claims ownership of the passed object.
 
 Note the third argument.  If this call is a call as a constructor (i.e
 not an action string call), this can be the 'child_pass_f', which is 1
 if this call is from a child, passing a mardo object to be handled by
 the mardo_2 class.  In this case we just accept this design is for us,
 and don't do any SPM2 specific processing

 The constructor can also be called to give class functions, where the
 name of the class function is a character string which is one of:
    'spm_filter' - applies spm_filter routine to passed args
 
 $Id$

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [o, others] = mardo_2(params, others, varargin)
0002 % class constructor for SPM2 MarsBaR design object
0003 % FORMAT [o, others] = mardo_2(params, others, varargin)
0004 % Inputs
0005 % params  - structure,containing fields, or SPM/MarsBaR design
0006 % others  - structure, containing other fields to define
0007 %
0008 % Outputs
0009 % o       - mardo_2 object (unless disowned)
0010 % others  - any unrecognized fields from params, for processing by
0011 %           children
0012 %
0013 % This object is called from the mardo object contructor
0014 % with a mardo object as input.  mardo_2 checks to see
0015 % if the contained design is an SPM2 design, returns
0016 % the object unchanged if not.  If it is an SPM2
0017 % design, it claims ownership of the passed object.
0018 %
0019 % Note the third argument.  If this call is a call as a constructor (i.e
0020 % not an action string call), this can be the 'child_pass_f', which is 1
0021 % if this call is from a child, passing a mardo object to be handled by
0022 % the mardo_2 class.  In this case we just accept this design is for us,
0023 % and don't do any SPM2 specific processing
0024 %
0025 % The constructor can also be called to give class functions, where the
0026 % name of the class function is a character string which is one of:
0027 %    'spm_filter' - applies spm_filter routine to passed args
0028 %
0029 % $Id$
0030 
0031 myclass = 'mardo_2';
0032 cvs_v   = marsbar('ver'); % was CVS version; now marsbar version
0033 
0034 % Default object structure
0035 defstruct = [];
0036 
0037 if nargin < 1
0038   defstruct.cvs_version = cvs_v;
0039   o = class(defstruct, myclass, mardo);
0040   others = [];
0041   return
0042 end
0043 if nargin < 2
0044   others = [];
0045 end
0046 if nargin < 3
0047   arg3 = 0;
0048 else
0049   arg3 = varargin{1};
0050 end
0051 
0052 % parse out string action calls (class functions)
0053 if ischar(params)
0054   switch params
0055    case 'spm_filter'
0056     if nargin < 2
0057       error('Need filter');
0058     elseif nargin < 3
0059       o = pr_spm_filter(others);
0060     else
0061       o = pr_spm_filter(others, arg3);
0062     end
0063     return
0064   otherwise
0065     error(sprintf('Is "%s" a filename? Use ``mardo`` to load from files',...
0066             params));
0067   end
0068 end
0069     
0070 % Deal with passed objects of this (or child) class
0071 if isa(params, myclass)
0072   o = params;
0073   % Check for simple form of call
0074   if isempty(others), return, end
0075 
0076   % Otherwise, we are being asked to set fields of object
0077   % (Moot at the moment, as there are no fields specific for this object)
0078   [p others] = mars_struct('split', others, defstruct);
0079   return
0080 end
0081 
0082 % Set child_pass_f
0083 child_pass_f = arg3;
0084 
0085 % normal call is via mardo constructor
0086 if isa(params, 'mardo')
0087   % Check to see if this is a suitable design, return if not
0088   des = des_struct(params);
0089   if ~arg3 & ~my_design(des), o = params; return, end
0090   % own
0091   if isfield(des, 'SPM')
0092     des = des.SPM;
0093   end
0094   uo = des_struct(params, des);
0095   params = [];
0096 else
0097   uo = [];
0098 end
0099 
0100 if ~isa(uo, 'mardo') % mardo object not passed
0101   % umbrella object, parse out fields for (this object and children)
0102   % third argument of 0 prevents recursive call back to here
0103   [uo, params] = mardo(params, others, 0);
0104 else
0105   % fill params with other parameters
0106   params = mars_struct('ffillmerge', params, others);
0107 end  
0108 
0109 % parse parameters into those for this object, children
0110 [params, others] = mars_struct('ffillsplit', defstruct, params);
0111 
0112 % add cvs tag
0113 params.cvs_version = cvs_v;
0114 
0115 % set the mardo object
0116 o  = class(params, myclass, uo);
0117 
0118 % convert vols to current format, if not passed from a child
0119 if ~child_pass_f
0120   o = convert_vols(o);
0121 end
0122 
0123 return

Generated on Wed 11-May-2022 16:26:09 by m2html © 2003-2019