📄 gui_cb.m
字号:
newdim = size(g_FastICA_pca_D, 1);
set(h_t_newDim, 'String', int2str(newdim));
% Check if the numOfIC now has illegal value entered
% We do that by telling the program that there is new value
% entered for NumOfIC.
gui_cb ChangeNumOfIC;
end
% And now we can calculate whitening...
[g_FastICA_white_sig, g_FastICA_white_wm, g_FastICA_white_dwm] = ...
whitenv(g_FastICA_mixedsig, g_FastICA_pca_E, g_FastICA_pca_D, ...
deblank(c_FastICA_verb_strV(g_FastICA_verbose,:)));
set (h_t_whiteStatus,'String','');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elseif strcmp(action, 'ChangeApproach')
% Get the old value for g
eval(['g_str = c_FastICA_g' int2str(g_FastICA_approach) '_strV;']);
old_g = deblank(g_str(g_FastICA_g,:));
% Get and set the new value for approach
g_FastICA_approach = get(h_pm_approach, 'Value');
% The possible values for g depend on the value of approach...
eval(['g_str = c_FastICA_g' int2str(g_FastICA_approach) '_strD;']);
set(h_pm_g, 'String', g_str);
% Match the old g value from the new g values so that if the
% old_g can be found from the new values (anywhere), then set new g
% to that value, and if it's not found then set the new value to 1.
match = 0;
eval(['g_str = c_FastICA_g' int2str(g_FastICA_approach) '_strV;']);
for i=1:size(g_str,1)
if strcmp(old_g, deblank(g_str(i,:)))
match = i;
end
end
if match == 0
match = 1; % the old g is not availabe anymore, set g = 1.
end
g_FastICA_g = match;
set(h_pm_g, 'Value', match);
% We must also check if the numOfIC can be awailable.
% If symmetric...
if strcmp(deblank(c_FastICA_appr_strV(g_FastICA_approach,:)),'symm')
% The numOfIC must be equal to newDim
set(h_e_numOfIC, 'String', get(h_t_newDim, 'String'), 'Enable', 'off');
g_FastICA_numOfIC = str2num(get(h_t_newDim, 'String'));
% else deflation...
else
% The numOfIC can be different than newDim
set(h_e_numOfIC, 'Enable', 'on');
end
gui_cb NullICA; % The options are changed so we must calculate ICA again
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elseif strcmp(action, 'ChangeNumOfIC')
% Get the new value... and store it later on after some checks
numofic = str2num(get(h_e_numOfIC, 'String'));
% The number of IC can't be less than 1 or more than the reduced dimension.
numoficmax = str2num(get(h_t_newDim, 'String'));
if numofic < 1
set(h_e_numOfIC, 'String', '1');
g_FastICA_numOfIC = 1;
elseif numofic > numoficmax
set(h_e_numOfIC, 'String', int2str (numoficmax));
g_FastICA_numOfIC = numoficmax;
else
g_FastICA_numOfIC = numofic;
end
gui_cb NullICA; % The options are changed so we must calculate ICA again
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elseif strcmp(action, 'ChangeG')
% Get the new value for g.
g_FastICA_g = get(h_pm_g, 'Value');
gui_cb NullICA; % The options are changed so we must calculate ICA again
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elseif strcmp(action, 'AdvOpt')
handle = findobj('Tag','f_FastICAAdvOpt');
if isempty(handle) % Check to see if the window is
pos = get(h_f_FastICA, 'Position'); % already open...
gui_adv(pos(1), pos(2));
else
figure(handle)
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elseif strcmp(action, 'ShowICASig')
if ~isempty(g_FastICA_mixedsig)
handle = findobj('Tag','f_FastICA_ica'); % Check if the window is already
if isempty(handle) % open. If not then open it.
figure('Tag', 'f_FastICA_ica', ...
'Name', 'FastICA: Plot ICs', ...
'NumberTitle', 'off');
else
figure(handle);
clf; % clear the figure for next plots
end
% If the IC's are not already calculated, we'll do it now
if isempty(g_FastICA_ica_sig)
gui_cb DoFPICA;
% If the value for DisplayMode was not 'none' then the signals
% are allready displayed.
if strcmp(deblank(c_FastICA_dMod_strV(g_FastICA_displayMo,:)),'off')
dispsig(g_FastICA_ica_sig')
end
else
dispsig(g_FastICA_ica_sig'); % The FPICA was already done, so we just
end % display the signals
title('Independent components');
else
fprintf('Data not loaded yet!\n\n');
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elseif strcmp(action, 'DoFPICA')
if ~isempty(g_FastICA_mixedsig)
if isempty(g_FastICA_white_sig) % We need the whitened signal here
gui_cb Whiten;
end
set(h_t_icaStatus,'String','Computing...');
% The possible values for g depend on approach
eval(['g_str = c_FastICA_g' int2str(g_FastICA_approach) '_strV;']);
% We'll contruct a command string which we'll later on evaluate...
% This is where the Fixed point algorithm is used.
command_str = ['[g_FastICA_ica_A,g_FastICA_ica_W]=' ...
'fpica(g_FastICA_white_sig, g_FastICA_white_wm, g_FastICA_white_dwm,' ...
'''' deblank(c_FastICA_appr_strV(g_FastICA_approach,:)) ''',' ...
'g_FastICA_numOfIC,' ...
'''' deblank(g_str(g_FastICA_g,:)) ''',' ...
'g_FastICA_a1, g_FastICA_a2, g_FastICA_epsilon, g_FastICA_maxNumIte,' ...
'''' deblank(c_FastICA_iSta_strV(g_FastICA_initState,:)) ''',' ...
'g_FastICA_initGuess,' ...
'''' deblank(c_FastICA_dMod_strV(g_FastICA_displayMo,:)) ''',' ...
'g_FastICA_displayIn,' ...
'''' deblank(c_FastICA_verb_strV(g_FastICA_verbose,:)) ''');'];
% If the user wants to plot while computing...
% let's at least plot it to the right figure then
if ~strcmp(deblank(c_FastICA_dMod_strV(g_FastICA_displayMo,:)),'off')
handle = findobj('Tag','f_FastICA_ica'); % Check if the window is already
if isempty(handle) % open. If not then open it.
figure('Tag', 'f_FastICA_ica', ...
'Name', 'FastICA: Plot ICs', ...
'NumberTitle', 'off');
else
figure(handle);
clf; % clear the figure for next plots
end
end
% ... and so let's do it...
eval(command_str);
g_FastICA_ica_sig = g_FastICA_ica_W * g_FastICA_mixedsig;
set (h_t_icaStatus,'String','Done');
else
fprintf('Data not loaded yet!\n\n');
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elseif strcmp (action, 'SaveData')
handle = findobj('Tag','f_FastICASave'); % Check if the window is already
if isempty(handle) % open. If not then open it.
pos = get(h_f_FastICA, 'Position');
gui_s(pos(1), pos(2));
else
figure(handle); % window. If it wasn't then
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elseif strcmp (action, 'Quit')
% We'll close the other dialogs if they are open.
Tags = ['f_FastICALoad '
'f_FastICAAdvOpt'
'f_FastICASave '
'f_FastICA_mix '
'f_FastICA_white'
'f_FastICA_ica '];
for i=1:size(Tags,1)
handle = findobj('Tag', deblank(Tags(i,:)));
if ~isempty(handle)
close(handle);
end
end
% Close this window
close(h_f_FastICA);
% Clear the used global variables.
gui_cg;
% Use break to 'jump' over the watchoff statement at the end
break;
% ... and we're done.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elseif strcmp (action, 'About')
gui_help('gui_cb_about');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elseif strcmp (action, 'Help')
gui_help('gui_cb_help');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
end % if ... elseif ...
watchoff (watchonInFigure);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -