📄 srf_markpoi.m
字号:
function hfile = srf_MarkPOI(hfile, poi, npoi, colcode, mix)
% SRF::MarkPOI - mark a patch-of-interest
%
% FORMAT: [srf] = srf.MarkPOI(poi, npoi, colcode [, mix])
%
% Input fields:
%
% poi POI BVQXfile object
% npoi either a name (does nothing if not found) or number
% colcode 1x3 RGB color code
% mix if given and between 0 .. 1, mix colcode with current
%
% Output fields:
%
% srf altered SRF object
% Version: v0.7b
% Build: 7090215
% Date: Sep-02 2007, 3:45 PM CEST
% Author: Jochen Weber, Brain Innovation, B.V., Maastricht, NL
% URL/Info: http://wiki.brainvoyager.com/BVQXtools
% check arguments
if nargin < 4 || ...
numel(hfile) ~= 1 || ...
~isBVQXfile(hfile, 'srf') || ...
numel(poi) ~= 1 || ...
~isBVQXfile(poi, 'poi') || ...
isempty(npoi) || ...
(~ischar(npoi) && ~isa(npoi, 'double')) || ...
~isa(colcode, 'double') || ...
(numel(colcode) ~= 1 && numel(colcode) ~= 3) || ...
any(isinf(colcode) | isnan(colcode) | colcode < 0 | colcode > 255)
error( ...
'BVQXfile:BadArguments', ...
'Invalid call to %s.', ...
mfilename ...
);
end
bc = bvqxfile_getcont(hfile.L);
poic = bvqxfile_getcont(poi.L);
if all(colcode <= 1) && ...
any(colcode ~= fix(colcode))
colcode = round(colcode(:)' * 255);
else
colcode = round(colcode(:)');
end
if nargin < 5 || ...
~isa(mix, 'double') || ...
numel(mix) ~= 1 || ...
isinf(mix) || ...
isnan(mix) || ...
mix <= 0 || ...
mix > 1
mix = 1;
end
% check npoi
pois = poic.POI;
numpois = numel(pois);
if ischar(npoi)
npoi = npoi(:)';
for pc = 1:numpois
if strcmpi(pois(pc).Name, npoi)
npoi = pc;
break;
end
end
end
% char POI not found
if ~isa(npoi, 'double')
return;
end
% check double POI
if numel(npoi) ~= 1 || ...
isinf(npoi) || ...
isnan(npoi) || ...
npoi ~= fix(npoi) || ...
npoi < 1 || ...
npoi > numpois
return;
end
% get selected poi's vertices
v = pois(npoi).Vertices(:)';
% check validity
nvert = size(bc.VertexColor, 1);
if any(v > nvert)
warning( ...
'BVQXfile:BadFileContents', ...
'Highest vertex in POI surpasses SRF vertex index.' ...
);
return;
end
% if mixing...
if mix < 1
% get original colors
cconvex = [0, round(bc.ConvexRGBA(1:3) * 255)];
cconcave = [0, round(bc.ConcaveRGBA(1:3) * 255)];
ocol = bc.VertexColor(v, :);
% set correct convex/concave color code
idxcc = isnan(ocol(:, 1));
idxcx = idxcc & ocol(:, 1) == 0;
idxcv = idxcc & ~idxcx;
ocol(idxcx, :) = repmat(cconvex, [sum(idxcx), 1]);
ocol(idxcv, :) = repmat(cconcave, [sum(idxcv), 1]);
% mix colors
ocol(:, 1) = NaN;
ocol(:, 2:4) = round((1 - mix) * ocol(:, 2:4) + ...
mix * repmat(colcode, [numel(v), 1]));
% otherwise
else
% create color array
ocol = [(NaN * ones(numel(v), 1)); repmat(colcode, [numel(v), 1])];
end
% set colors
bc.VertexColor(v, :) = ocol;
bvqxfile_setcont(hfile.L, bc);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -