📄 erp_select_chan.m
字号:
'label','&File', ...
'tag','menu_file');
h2 = uimenu('parent', h_file, ...
'callback','erp_select_chan({''LOAD_TXT''});', ...
'label','&Load from a text file', ...
'tag', 'menu_load');
h2 = uimenu('parent', h_file, ...
'callback','erp_select_chan({''SAVE_TXT''});', ...
'label','&Save to a text file', ...
'tag', 'menu_save');
h2 = uimenu('parent', h_file, ...
'callback','close(gcbf);', ...
'label','&Close', ...
'visible','off', ...
'tag', 'menu_close');
pause(0.01)
h1 = findobj(gcf,'tag','ChannelList');
set(h1,'string',chan_nam);
selected_chan_nam = chan_nam(str2num(old_chan_order_str),:);
h1 = findobj(gcf,'tag','SelectedChannelList');
set(h1,'string',selected_chan_nam);
set(h1, 'user', str2num(old_chan_order_str));
set(findobj(gcf,'tag','SelectedChannelLabel'),'string', ...
['Selected Channels: ', ...
num2str(length(str2num(old_chan_order_str)))]);
setappdata(gcf,'old_chan_order_str',old_chan_order_str);
setappdata(gcf,'old_system',old_system);
setappdata(gcf,'new_system',old_system);
return; % Init
% --------------------------------------------------------------------
function AddSessionProfile()
h = findobj(gcf,'Tag','ChannelList'); % get the selected file
selected_chan_idx = get(h,'Value')';
% update selected channel list
%
h = findobj(gcf,'Tag','SelectedChannelList');
selected_chan_order_str = get(h,'String');
old_chan_order = get(h,'Userdata');
% check for duplication
%
if ~isempty(intersect(selected_chan_idx, old_chan_order))
msg = 'ERROR: Duplicate channel is not allowed.';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
return;
end;
chan_order = [old_chan_order; selected_chan_idx];
% if isempty(old_chan_order)
if isempty(get(h, 'string'))
set(h, 'value', 1);
end
update_chan_order(chan_order);
return; % AddSessionProfile
% --------------------------------------------------------------------
function MoveUpSessionProfile()
% update the session profile list
%
h = findobj(gcf,'Tag','SelectedChannelList');
list_top = get(h,'ListboxTop');
move_idx = get(h,'Value');
chan_list = get(h,'String');
chan_order = get(h,'user');
if (move_idx == 1), % already on the top of list
return;
end;
temp_buffer = chan_list(move_idx-1,:);
chan_list(move_idx-1,:) = chan_list(move_idx,:);
chan_list(move_idx,:) = temp_buffer;
temp_buffer = chan_order(move_idx-1);
chan_order(move_idx-1) = chan_order(move_idx);
chan_order(move_idx) = temp_buffer;
curr_value = move_idx - 1;
set(h,'String',chan_list,'Userdata',chan_order, ...
'Value',curr_value);
if (curr_value < list_top)
set(h,'ListBoxTop',curr_value);
else
set(h,'ListBoxTop',list_top);
end;
return; % MoveUpSessionProfile
% --------------------------------------------------------------------
function MoveDownSessionProfile()
% update the session profile list
%
h = findobj(gcf,'Tag','SelectedChannelList');
list_top = get(h,'ListboxTop');
move_idx = get(h,'Value');
chan_list = get(h,'String');
chan_order = get(h,'user');
if (move_idx == size(chan_list,1)), % already on the bottom of list
return;
end;
temp_buffer = chan_list(move_idx+1,:);
chan_list(move_idx+1,:) = chan_list(move_idx,:);
chan_list(move_idx,:) = temp_buffer;
temp_buffer = chan_order(move_idx+1);
chan_order(move_idx+1) = chan_order(move_idx);
chan_order(move_idx) = temp_buffer;
curr_value = move_idx + 1;
set(h,'String',chan_list,'Userdata',chan_order, ...
'Value',curr_value);
set(h,'ListBoxTop',list_top);
return; % MoveDownSessionProfile
% --------------------------------------------------------------------
function RemoveSessionProfile()
% update the session profile list
%
h = findobj(gcf,'Tag','SelectedChannelList');
remove_idx = get(h,'Value');
chan_list = get(h,'String');
chan_order = get(h,'Userdata');
if isempty(chan_order)
return;
end
mask = zeros(1,size(chan_list,1));
mask(remove_idx) = 1;
chan_order = chan_order(find(mask == 0));
if length(remove_idx) > 1
set(h, 'value', 1);
elseif remove_idx == size(chan_list,1)
set(h, 'value', remove_idx-1);
end
update_chan_order(chan_order);
return; % RemoveSessionProfile
%----------------------------------------------------------------------------
function update_chan_order(chan_order)
new_system = getappdata(gcf,'new_system');
switch new_system.class
case 1
type_str = 'BESAThetaPhi|EGI128|EGI256';
switch new_system.type
case 1
load('erp_loc_besa148');
case 2
load('erp_loc_egi128');
case 3
load('erp_loc_egi256');
end
case 2
type_str = 'CTF-150';
switch new_system.type
case 1
load('erp_loc_ctf150');
end
end
selected_chan_nam = chan_nam(chan_order,:);
h1 = findobj(gcf,'tag','SelectedChannelList');
set(h1, 'string',selected_chan_nam, 'user', chan_order);
set(findobj(gcf,'tag','SelectedChannelLabel'),'string', ...
['Selected Channels: ', num2str(length(chan_order))]);
return;
%----------------------------------------------------------------------------
function delete_fig
try
load('pls_profile');
pls_profile = which('pls_profile.mat');
erp_select_chan_pos = get(gcbf,'position');
save(pls_profile, '-append', 'erp_select_chan_pos');
catch
end
return;
%----------------------------------------------------------------------------
function load_txt
[fn, pn] = uigetfile('*.txt','Open Electrode Order File');
if isequal(fn,0) | isequal(pn,0)
return;
end
chan_file = fullfile(pn, fn);
try
chan_order = load('-ascii', chan_file);
catch
msg = 'Invalid electrode order file';
uiwait(msgbox(msg,'Error','modal'));
return;
end
if sum(size(chan_order))~=(size(chan_order,1)+1) | ...
size(chan_order,1)~=size(unique(chan_order),1) | ...
all(chan_order~=round(chan_order)) | ...
min(chan_order)<1
msg = 'Invalid electrode order file';
uiwait(msgbox(msg,'Error','modal'));
return;
end
h = findobj(gcf,'Tag','SelectedChannelList');
if isempty(get(h, 'string'))
set(h, 'value', 1);
end
update_chan_order(chan_order);
return
%----------------------------------------------------------------------------
function save_txt
SelectedChannelList = get(findobj(gcf,'Tag','SelectedChannelList'),'Userdata');
[fn, pn] = uiputfile('*.txt','Save Electrode Order File');
chan_file = [pn filesep fn];
if ~fn
% msg = 'WARNING: No file is saved.';
% uiwait(msgbox(msg,'Uncomplete','modal'));
return;
else
try
save(chan_file,'-ascii','SelectedChannelList')
catch
msg = 'ERROR: Cannot save file';
set(findobj(gcf,'Tag','MessageLine'),'String',msg);
return;
end
end
return
%----------------------------------------------------------------------------
function select_class
h_class = findobj(gcf,'tag','CLASSButton');
h_type = findobj(gcf,'tag','TYPEButton');
new_system = getappdata(gcf,'new_system');
class_val = get(h_class,'value');
if class_val == new_system.class
return;
end
switch class_val
case 1
type_str = 'BESAThetaPhi|EGI128|EGI256';
load('erp_loc_besa148');
case 2
type_str = 'CTF-150';
load('erp_loc_ctf150');
end
chan_num = size(chan_loc, 1);
new_system.type = 1;
set(h_type,'string',type_str,'value',1);
new_system.class = class_val;
h1 = findobj(gcf,'tag','ChannelLabel');
set(h1,'string',['Channels: ', num2str(chan_num)]);
h1 = findobj(gcf,'tag','ChannelList');
set(h1,'string',chan_nam,'value',1);
h1 = findobj(gcf,'tag','SelectedChannelList');
set(h1,'string','');
set(h1, 'user', []);
set(findobj(gcf,'tag','SelectedChannelLabel'),'string','Selected Channels: 0');
setappdata(gcf,'new_system',new_system');
return
%----------------------------------------------------------------------------
function select_type
h_class = findobj(gcf,'tag','CLASSButton');
h_type = findobj(gcf,'tag','TYPEButton');
new_system = getappdata(gcf,'new_system');
type_val = get(h_type,'value');
if type_val == new_system.type
return;
end
switch type_val
case 1
switch new_system.class
case 1 % BESA
load('erp_loc_besa148');
case 2 % MEG1
load('erp_loc_ctf150');
end
case 2
switch new_system.class
case 1 % EGI128
load('erp_loc_egi128');
end
case 3
switch new_system.class
case 1 % EGI256
load('erp_loc_egi256');
end
end
chan_num = size(chan_loc, 1);
new_system.type = type_val;
h1 = findobj(gcf,'tag','ChannelLabel');
set(h1,'string',['Channels: ', num2str(chan_num)]);
h1 = findobj(gcf,'tag','ChannelList');
set(h1,'string',chan_nam,'value',1);
h1 = findobj(gcf,'tag','SelectedChannelList');
set(h1,'string','');
set(h1, 'user', []);
set(findobj(gcf,'tag','SelectedChannelLabel'),'string','Selected Channels: 0');
setappdata(gcf,'new_system',new_system');
return
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -