0001 function [o, others] = maroi_pointlist(params, type)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 myclass = 'maroi_pointlist';
0015 defstruct = struct('XYZ', [],...
0016 'mat', eye(4),...
0017 'vals',[],...
0018 'voxblock',[]);
0019
0020 if nargin < 1
0021 params = [];
0022 end
0023 if nargin < 2
0024 type = 'real';
0025 end
0026 if isa(params, myclass)
0027 o = params;
0028 return
0029 end
0030
0031
0032 pparams = mars_struct('ffillmerge', defstruct, params);
0033
0034
0035 [uo, pparams] = maroi(pparams);
0036
0037
0038 [pparams, others] = mars_struct('split', pparams, defstruct);
0039
0040
0041 if isempty(pparams.XYZ)
0042 o = class(pparams, myclass, uo);
0043 return
0044 end
0045
0046
0047 if size(pparams.XYZ, 1) == 1
0048 pparams.XYZ = pparams.XYZ';
0049 end
0050
0051 if strcmp(type, 'real') | strcmp(type, 'mm')
0052
0053 pparams.XYZ = inv(pparams.mat) * ...
0054 [pparams.XYZ; ones(1, size(pparams.XYZ,2))];
0055 pparams.XYZ = pparams.XYZ(1:3,:);
0056 end
0057
0058
0059 tiny = 0.001;
0060 if any(any((abs(pparams.XYZ - round(pparams.XYZ))) > tiny))
0061 error(['Non integer points in voxel space - ' ...
0062 'are points really of type ''' type '''?']);
0063 end
0064 pparams.XYZ = round(pparams.XYZ);
0065
0066
0067 pparams.voxblock = my_voxblock(pparams.XYZ, pparams.mat, pparams.vals);
0068
0069
0070 if ~isempty(pparams.vals)
0071 tmp = find(~isnan(pparams.vals) & ...
0072 abs(pparams.vals) >= roithresh(uo));
0073 pparams.XYZ = pparams.XYZ(:, tmp);
0074 if binarize(uo)
0075 pparams.vals = [];
0076 else
0077 pparams.vals = pparams.vals(tmp);
0078 end
0079 end
0080
0081
0082 o = class(pparams, myclass, uo);
0083 return