c_o_m method - calculates centre of mass $Id$
0001 function pt = c_o_m(o, sp, pt_type) 0002 % c_o_m method - calculates centre of mass 0003 % 0004 % $Id$ 0005 0006 if nargin < 2 0007 sp = ''; 0008 end 0009 if nargin < 3 0010 pt_type = 'real'; 0011 end 0012 pt = centre(o); 0013 switch pt_type 0014 case {'real','mm'} 0015 case 'vox' 0016 if isempty(sp) 0017 error('Need space to define voxel centre of mass'); 0018 end 0019 pt = sp.mat * [pt; 1]; 0020 pt = pt(1:3)'; 0021 otherwise 0022 error(['Do not recognize point type' pt_type]); 0023 end