ET_PDToolkit/PDToolkit/@PDExperiment/get_trials_based_on_label.m

38 lines
825 B
Matlab

function[trial_list] = get_trials_based_on_label(e, session, trial_query)
trial_list = [];
if strcmp(trial_query, 'All trials')
trial_list= 1:length(session.trials);
return
end
if ~isempty(trial_query)
label_list = {};
match_list = {};
ind=1;
for t = 1:length(session.trials)
for l = 1:length(session.trials(t).labels)
label_list{ind} = session.trials(t).labels(l).label;
match_list{ind} = session.trials(t).labels(l).match;
trial_ids(ind) = t;
ind=ind+1;
end
end
m_m = regexp(trial_query, match_list);
m_l = regexp(trial_query, label_list);
matches = find(~cellfun(@isempty,m_l));
labels = find(~cellfun(@isempty,m_l));
trial_list = sort([matches, labels]);
end