function[e] = build_averages(e) plotwindow = figure; plotwindow_id = num2str(plotwindow); pos = get(plotwindow, 'Position'); pos(3) = 900; set(plotwindow, 'Position', pos); set(plotwindow, 'Color', [1 1 1]); e.handle(2) = plotwindow; subj_pop = uicontrol('Style','popupmenu'); sess_pop = uicontrol('Style','popupmenu'); trial_pop = uicontrol('Style','popupmenu'); add_group_btn = uicontrol('Style', 'pushbutton'); rem_group_btn = uicontrol('Style', 'pushbutton'); subj_pop_string = 'All subjects|Selection of subjects'; subj_pop_vals =[999 998]; sess_pop_string = 'All sessions|First sessions|Second sessions'; sess_pop_vals =[999 998 997]; trial_pop_string = 'All trials|Selection of trials'; for s = 1:length(e.subjects) subj_pop_string = [subj_pop_string '|' e.subjects(s).name]; subj_pop_vals = [subj_pop_vals s]; end set(subj_pop, 'Position', [10 400 150 20]); set(subj_pop, 'String', subj_pop_string); set(subj_pop, 'Value', 1); set(subj_pop, 'Callback', 'e.enable_selection_edit(''subject'')'); set(subj_pop, 'FontName', 'Verdana'); set(subj_pop, 'FontWeight', 'bold'); set(subj_pop, 'FontSize', 11); sel=get(subj_pop, 'Value'); for s = 1:length(e.subjects(sel).sessions); sess_pop_string = [sess_pop_string '|' e.subjects(sel).sessions(s).name]; sess_pop_vals = [sess_pop_vals s]; end set(sess_pop, 'Position', [10 375 150 20]); set(sess_pop, 'String', sess_pop_string); set(sess_pop, 'Value', 1); set(sess_pop, 'Callback', 'e.enable_selection_edit(''session'')'); set(sess_pop, 'FontName', 'Verdana'); set(sess_pop, 'FontWeight', 'bold'); set(sess_pop, 'FontSize', 11); selsess = get(sess_pop, 'Value'); set(sess_pop, 'Position', [10 375 150 20]); set(sess_pop, 'String', sess_pop_string); set(sess_pop, 'Value', 1); set(sess_pop, 'Callback', ''); set(sess_pop, 'FontName', 'Verdana'); set(sess_pop, 'FontWeight', 'bold'); set(sess_pop, 'FontSize', 11); unique_matches = unique({e.subjects(1).sessions(1).labels.match}); unique_labels = unique({e.subjects(1).sessions(1).labels.label}); for t = 1:length(unique_matches) trial_pop_string = [trial_pop_string '|' unique_matches{t}]; end for t = 1:length(unique_labels) trial_pop_string = [trial_pop_string '|' unique_labels{t}]; end set(trial_pop, 'Position', [10 350 150 20]); set(trial_pop, 'String', trial_pop_string); set(trial_pop, 'Value', 1); set(trial_pop, 'Callback', 'e.enable_selection_edit(''trial'')'); set(trial_pop, 'FontName', 'Verdana'); set(trial_pop, 'FontWeight', 'bold'); set(trial_pop, 'FontSize', 11); select_edit(1) = uicontrol('Style', 'edit'); select_edit(2) = uicontrol('Style', 'edit'); select_edit(3) = uicontrol('Style', 'edit'); set(select_edit(1), 'Position', [170 400 150 20]); set(select_edit(2), 'Position', [170 375 150 20]); set(select_edit(3), 'Position', [170 350 150 20]); set(select_edit, 'Visible' ,'off'); set(select_edit, 'String', []); set(select_edit, 'FontName', 'Verdana'); set(select_edit, 'FontWeight', 'bold'); set(select_edit, 'FontSize', 11); set(select_edit, 'Enable' ,'off'); set(select_edit(1), 'Tag', ['selection_edit.subject.' plotwindow_id]); set(select_edit(1), 'Callback', 'e.evaluate_selection(''subject'')'); set(select_edit(2), 'Tag', ['selection_edit.session.' plotwindow_id]); set(select_edit(2), 'Callback', 'e.evaluate_selection(''session'')'); set(select_edit(3), 'Tag', ['selection_edit.trial.' plotwindow_id]); set(select_edit(3), 'Callback', 'e.evaluate_selection(''trial'')'); plot([]); pos = get(gca, 'Position'); set(gca, 'Position', [.225 .275 .6 .7]); set(gca, 'FontName', 'Verdana'); set(gca, 'FontWeight', 'bold'); set(gca, 'FontSize', 10); set(gca, 'Box', 'on'); set(add_group_btn, 'Position', [10 190 70 20]); set(rem_group_btn, 'Position', [90 190 70 20]); set(add_group_btn, 'String', 'Add'); set(add_group_btn, 'Callback', @e.add_aggregate); set(rem_group_btn, 'String', 'Remove'); set(rem_group_btn, 'Callback', 'e.remove_aggregate'); jList = java.util.ArrayList; %% set Tags set(subj_pop, 'Tag', ['subj_pop.' plotwindow_id]); set(sess_pop, 'Tag', ['sess_pop.' plotwindow_id]); set(trial_pop, 'Tag', ['trial_pop.' plotwindow_id]); %% list aggregates agg_strings={}; for i = 1:length(e.aggregates) add_strings{i,1} = 1; color_str = ['#' sprintf('%02s', dec2hex(e.aggregates(i).color(1)*255)) ... sprintf('%02s', dec2hex(e.aggregates(i).color(2)*255)) ... sprintf('%02s', dec2hex(e.aggregates(i).color(3)*255))]; agg_strings{i,2} = ['