📄 prt_addcond.m
字号:
function hfile = prt_AddCond(hfile, cname, onoffsets, ccolor)
% PRT::AddCond - add a condition to a PRT file
%
% FORMAT: [prt = ] prt.AddCond(name, onoffsets, ccolor);
%
% Input fields:
%
% name condition name
% onoffsets Ox2 list of on and offsets
% ccolor condition color
%
% Output fields:
%
% prt altered PRT object
%
% Note: all input arguments are optional. if none is given, an
% empty condition with a 'Condition Nr.' identifier and
% random color is generated
% Version: v0.7b
% Build: 7090213
% Date: Sep-02 2007, 1:07 PM CEST
% Author: Jochen Weber, Brain Innovation, B.V., Maastricht, NL
% URL/Info: http://wiki.brainvoyager.com/BVQXtools
% argument check
if nargin < 1 || ...
numel(hfile) ~= 1 || ...
~isBVQXfile(hfile, 'prt')
error( ...
'BVQXfile:BadArgument', ...
'Invalid call to %s.', ...
mfilename ...
);
end
bc = bvqxfile_getcont(hfile.L);
ncon = length(bc.Cond);
if nargin > 1 && ...
ischar(cname) && ...
~isempty(cname)
cname = cname(:)';
else
cname = sprintf('Condition %d', ncon + 1);
end
if nargin > 2 && ...
isa(onoffsets, 'double') && ...
length(size(onoffsets)) == 2 && ...
size(onoffsets, 2) == 2 && ...
all(onoffsets(:) >= 0) && ...
~any(isinf(onoffsets(:)) | isnan(onoffsets(:)))
onoffsets = round(onoffsets);
else
onoffsets = [];
end
noo = size(onoffsets, 1);
if nargin > 3 && ...
isa(ccolor, 'double') && ...
numel(ccolor) == 3 && ...
~any(isinf(ccolor) | isnan(ccolor) | ccolor < 0 | ccolor >= 256)
ccolor = floor(ccolor(:)');
else
ccolor = floor(255.99 * rand(1,3));
end
% build new condition
newc = struct( ...
'ConditionName', {{cname}}, ...
'NrOfOnOffsets', noo, ...
'OnOffsets', onoffsets, ...
'Color', ccolor);
% update object
bc.Cond = [bc.Cond(:)', newc];
bc.NrOfConditions = numel(bc.Cond);
bvqxfile_setcont(hfile.L, bc);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -