ET_PDToolkit/PDToolkit/@PDSession/setPattern.m

51 lines
1.5 KiB
Matlab

function[objs] = setPattern(objs, type, pattern)
%% define possible coding styles of markers
ton_codings = {'trial onset','trial on', 'start trial', 'trial start', 'trial_start'};
toff_codings = {'trial offset','trial off', 'end trial', 'trial end', 'trial_end'};
son_codings = {'stimulus onset','stimulus on', 'soa', 'stim on', 'stim_on', 'stimulus start', 'stim_start'};
soff_codings = {'stimulus offset','stimulus off', 'stim off', 'stim_off', 'stim end', 'stim_end'};
bon_codings = {'baseline on', 'baseline start', 'baseline onset', 'bl on', 'bl'};
boff_codings = {'baseline off', 'baseline end', 'baseline offset', 'bl off'};
if (~ischar(pattern))
error('Pattern must be character array')
end
for i = 1:length(objs)
obj = objs(i);
%% trial onset
if (ismember(lower(type), ton_codings))
obj.trial_start_pattern = pattern;
end
if (ismember(lower(type), toff_codings))
obj.trial_end_pattern = pattern;
end
%% stimulus onset
if (ismember(lower(type), son_codings))
obj.stimulus_onset_pattern = pattern;
end
%% stimulus offset
if (ismember(lower(type), soff_codings))
obj.stimulus_offset_pattern = pattern;
end
%% baseline onset
if (ismember(lower(type), bon_codings))
obj.baseline_onset_pattern = pattern;
end
%% baseline offset
if (ismember(lower(type), boff_codings))
obj.baseline_offset_pattern = pattern;
end
objs(i) = obj;
end