Home > marsbar > @maroi_matrix > maroi_matrix.m

maroi_matrix

PURPOSE ^

maroi_matrix - class constructor

SYNOPSIS ^

function [o, others] = maroi_matrix(params, space)

DESCRIPTION ^

 maroi_matrix - class constructor
 There are two usual forms of the call:
 1) Constructor call: obj = maroi_matrix(params);
 where input is [defaults]
  params  - a structure containing any fields for a maroi parent and
            .dat - a matrix
            .mat - mapping of matrix indices to mm

 2) Rebase call: obj = maroi_matrix(obj, space)
 where input is [defaults]
  obj - a maroi_matrix object
  space - mars_space object defining space to reslice to

 This maroi_matrix object is used for conversion between
 different types of rois, and for combining rois
 Much of the work is in the converter routines for other roi objects, to
 return objects of this type

 $Id$

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [o, others] = maroi_matrix(params, space)
0002 % maroi_matrix - class constructor
0003 % There are two usual forms of the call:
0004 % 1) Constructor call: obj = maroi_matrix(params);
0005 % where input is [defaults]
0006 %  params  - a structure containing any fields for a maroi parent and
0007 %            .dat - a matrix
0008 %            .mat - mapping of matrix indices to mm
0009 %
0010 % 2) Rebase call: obj = maroi_matrix(obj, space)
0011 % where input is [defaults]
0012 %  obj - a maroi_matrix object
0013 %  space - mars_space object defining space to reslice to
0014 %
0015 % This maroi_matrix object is used for conversion between
0016 % different types of rois, and for combining rois
0017 % Much of the work is in the converter routines for other roi objects, to
0018 % return objects of this type
0019 %
0020 % $Id$
0021 
0022 myclass = 'maroi_matrix';
0023 defstruct = struct('dat', [],'mat', eye(4));
0024 
0025 if nargin < 1
0026   params = [];
0027 end
0028 if isa(params, myclass)
0029   o = params;
0030   if nargin < 2 % simple object return call
0031     return
0032   end 
0033   % Rebase call
0034   if isempty(space)
0035     space = native_space(o);
0036     if isempty(space)
0037       error('Cannot define default space for object');
0038     end
0039   else
0040     space = mars_space(space);
0041   end
0042   
0043   % check if this in fact the same as object native space
0044   if space == native_space(o), return, end
0045   % if not, then rebase
0046   params = paramfields(o);
0047   params.label = [params.label '_rebased']; 
0048   params.descrip = [params.descrip ': rebased']; 
0049   params.dat = rebase(o,space,'i');
0050   params.mat = space.mat;
0051   o = maroi_matrix(params);
0052   return
0053 end
0054 
0055 % Constructor call
0056 
0057 % fill with defaults
0058 pparams = mars_struct('ffillmerge', defstruct, params);
0059 
0060 % umbrella object, parse out fields for (this object and children)
0061 [uo, pparams] = maroi(pparams);
0062 
0063 % reparse parameters into those for this object, children
0064 [pparams, others] = mars_struct('split', pparams, defstruct);
0065 
0066 % bless into object
0067 o = class(pparams, myclass, uo);
0068 
0069 % apply implied thresholding
0070 o = matrixdata(o, o.dat);
0071 
0072 return

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