69 lines
1.6 KiB
Matlab
69 lines
1.6 KiB
Matlab
function[] = evaluate_selection(e, type)
|
|
|
|
if strcmp(type,'subject'), code = 'subj'; end
|
|
if strcmp(type,'session'), code = 'sess'; end
|
|
if strcmp(type,'trial'), code = 'trial'; end
|
|
|
|
plotwindow = gcf;
|
|
plotwindow_id = num2str(plotwindow);
|
|
|
|
|
|
|
|
fig = gcf;
|
|
plotwindow_id = num2str(fig);
|
|
select_edit = findobj('Tag', ['selection_edit.' type '.' plotwindow_id]);
|
|
|
|
|
|
selection_cell = get(select_edit, 'String');
|
|
try
|
|
selection = eval(str2num(selection_cell));
|
|
catch
|
|
selection = str2num(selection_cell);
|
|
if ~isnumeric(selection)
|
|
msgbox('Could not parse entered data');
|
|
end
|
|
end
|
|
|
|
%fig = e.handle(2);
|
|
|
|
tmp = get(fig, 'UserData');
|
|
|
|
if (strcmp(type, 'subject'))
|
|
selection = intersect(selection, 1:length(e.subjects));
|
|
if isempty(selection)
|
|
display('Empty selection');
|
|
else
|
|
set(select_edit,'String', num2str(selection));
|
|
tmp.selected_subjects = selection;
|
|
end
|
|
end
|
|
|
|
if (strcmp(type, 'session'))
|
|
tmp.selected_sessions = selection;
|
|
end
|
|
|
|
if (strcmp(type, 'trial'))
|
|
tmp.selected_trials = selection;
|
|
end
|
|
|
|
set(fig, 'UserData', tmp);
|
|
|
|
%% Add the selection to the list and set the popup
|
|
|
|
popup = findobj('Tag', [code '_pop.' plotwindow_id]);
|
|
pop_string = get(popup,'String');
|
|
itemsize= size(pop_string);
|
|
new_item = num2str(selection);
|
|
|
|
newsize = max(length(new_item), itemsize(2));
|
|
pop_string(:,itemsize(2)+1:newsize) = ' ';
|
|
new_item(end+1:newsize)= ' ';
|
|
pop_string(itemsize(1)+1,:) = new_item;
|
|
|
|
[ui ui_ind] = unique(cellstr(pop_string));
|
|
|
|
set(popup, 'String', pop_string(sort(ui_ind),:));
|
|
set(popup, 'Value', length(ui_ind));
|
|
|
|
set(select_edit, 'Visible', 'off');
|
|
assignin('base','e',e); |