Home > marsbar > @mardo_99 > mardo_99.m

mardo_99

PURPOSE ^

class constructor for SPM99 MarsBaR design object

SYNOPSIS ^

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

DESCRIPTION ^

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

 Outputs
 o       - mardo_99 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_99 checks to see
 if the contained design is an SPM99 design, returns
 the object unchanged if not.  If it is an SPM99
 design, it claims ownership of the passed object.

 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_99(params, others, varargin)
0002 % class constructor for SPM99 MarsBaR design object
0003 % FORMAT [o, others] = mardo_99(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_99 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_99 checks to see
0015 % if the contained design is an SPM99 design, returns
0016 % the object unchanged if not.  If it is an SPM99
0017 % design, it claims ownership of the passed object.
0018 %
0019 % The constructor can also be called to give class functions, where the
0020 % name of the class function is a character string which is one of:
0021 %    'spm_filter' - applies spm_filter routine to passed args
0022 %
0023 % $Id$
0024   
0025 myclass = 'mardo_99';
0026 cvs_v   = marsbar('ver'); % was CVS version; now marsbar version
0027 
0028 % Default object structure
0029 defstruct = [];
0030 
0031 if nargin < 1
0032   defstruct.cvs_version = cvs_v;
0033   o = class(defstruct, myclass, mardo);
0034   others = [];
0035   return
0036 end
0037 if nargin < 2
0038   others = [];
0039 end
0040 
0041 % parse out string action calls (class functions)
0042 if ischar(params)
0043   switch params
0044    case 'spm_filter'
0045     if nargin < 2
0046       error('Need filter');
0047     elseif nargin < 3
0048       error('Need action string');
0049     elseif nargin < 4
0050       o = pr_spm_filter(others, varargin{1});
0051     else
0052       o = pr_spm_filter(others, varargin{1:2});
0053     end
0054     return
0055   otherwise
0056     error(sprintf('Is "%s" a filename? Use ``mardo`` to load from files',...
0057             params));
0058   end
0059 end
0060     
0061 % Deal with passed objects of this (or child) class
0062 if isa(params, myclass)
0063   o = params;
0064   % Check for simple form of call
0065   if isempty(others), return, end
0066 
0067   % Otherwise, we are being asked to set fields of object
0068   % (Moot at the moment, as there are no fields specific for this object)
0069   [p others] = mars_struct('split', others, defstruct);
0070   return
0071 end
0072     
0073 % normal call is via mardo constructor
0074 if isa(params, 'mardo')
0075   % Check to see if this is a suitable design, return if not
0076   des = des_struct(params);
0077   if ~my_design(des), o = params; return, end
0078   uo = params;
0079   params = [];
0080 else
0081   uo = [];
0082 end
0083 
0084 if ~isa(uo, 'mardo') % mardo object not passed
0085   % umbrella object, parse out fields for (this object and children)
0086   % third argument of 0 prevents recursive call back to here
0087   [uo, params] = mardo(params, others, 0);
0088 else
0089   % fill params with other parameters
0090   params = mars_struct('ffillmerge', params, others);
0091 end  
0092 
0093 % parse parameters into those for this object, children
0094 [params, others] = mars_struct('ffillsplit', defstruct, params);
0095 
0096 % add cvs tag
0097 params.cvs_version = cvs_v;
0098 
0099 % set the mardo object
0100 o  = class(params, myclass, uo);
0101 
0102 % set filter (to allow sparse->full trick to work for spm_spm.m)
0103 SPM = des_struct(o);
0104 K   = mars_struct('getifthere', SPM, 'xX', 'K');
0105 if iscell(K);
0106   SPM.xX.K = pr_spm_filter('set', K);
0107   o = des_struct(o, SPM);
0108 end
0109 
0110 % convert vols to current format
0111 o = convert_vols(o);
0112 
0113 return

Generated on Thu 17-Mar-2016 01:14:46 by m2html © 2005