Home > functions > gui > preAnalysis > trial_extractor > vb_te_channel_selector_new.m

vb_te_channel_selector_new

PURPOSE ^

SYNOPSIS ^

function [selected_ch_list, cancel] = vb_te_channel_selector_new(all_ch_list, selected_ch_list)

DESCRIPTION ^

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [selected_ch_list, cancel] = vb_te_channel_selector_new(all_ch_list, selected_ch_list)
0002 
0003 %
0004 % Copyright (C) 2011, ATR All Rights Reserved.
0005 % License : New BSD License(see VBMEG_LICENSE.txt)
0006 
0007 h = openfig('vb_te_channel_selector.fig');
0008 H = guihandles(h);
0009 
0010 cancel = false;
0011 
0012 data = struct;
0013 data.H = H;
0014 data.cancel_flag = false;
0015 guidata(h, data);
0016 
0017 % Dummy data for test
0018 if ~exist('all_ch_list', 'var')
0019     for k=1:400
0020         all_ch_list{k} = num2str(k);
0021     end
0022 end
0023 
0024 if ~exist('selected_ch_list', 'var')
0025     i=1;
0026     for k=1:8:400
0027         selected_ch_list{i} = num2str(k);
0028         i = i+1;
0029     end
0030 end
0031 
0032 % Create table
0033 table = cell(0);
0034 title = {'Channel', 'ON/OFF'};
0035 for k=1:length(all_ch_list)
0036     ix = strmatch(all_ch_list{k}, selected_ch_list, 'exact');
0037     flag = false;
0038     if ~isempty(ix)
0039         flag = true;
0040     end
0041     table{k, 1} = all_ch_list{k};
0042     table{k, 2} = flag;
0043 end
0044 if vb_matlab_version('>=', '7.6')
0045     table_h = uitable('v0', h, table, title);
0046 else
0047     table_h = uitable(h, table, title);
0048 end
0049 
0050 data.table_h = table_h;
0051 set(table_h, 'Units', 'normalized');
0052 
0053 pop_pos = get(H.channel_selecter_popup, 'Position');
0054 ok_pos = get(H.ok_push, 'Position');
0055 
0056 MARGIN = 0.05;
0057 set(table_h, 'Position', [pop_pos(1), ok_pos(2)+ok_pos(4)+MARGIN, 0.8, 0.7]);
0058 set(table_h, 'Units', 'normalized');
0059 
0060 guidata(h, data);
0061 
0062 waitfor(h, 'Visible', 'off');
0063 if ishandle(h)
0064     data = guidata(h);
0065     if data.cancel_flag
0066         selected_ch_list = [];
0067         cancel = true;
0068     else
0069         tableData = cell(get(table_h, 'data'));
0070         flags = [tableData{:, 2}];
0071         ix = find(flags == 1);
0072         if ~isempty(ix)
0073             selected_ch_list = all_ch_list(ix);
0074         else
0075             selected_ch_list = [];
0076         end
0077     end
0078     delete(h);
0079 end

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005