📄 gui_cb.m
字号:
function gui_cb (action)
% This file is used by FASTICAG
% This file holds the callbacks to the main window
% 3.4.1998
% Hugo G鋠ert
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Global variables
% Handle to the main figure
global h_f_FastICA;
% Handles for needed controls in main figure;
global h_t_mixedStatus;
global h_t_dim;
global h_t_numOfSamp;
global h_t_newDim;
global h_t_whiteStatus;
global h_t_icaStatus;
global h_pm_approach;
global h_e_numOfIC;
global h_pm_g;
% Global variable used by gui_cb & gui_lc
global g_mix_meanremoved;
% Main values are stored here
global g_FastICA_mixedsig;
global g_FastICA_pca_D;
global g_FastICA_pca_E;
global g_FastICA_white_sig;
global g_FastICA_white_wm;
global g_FastICA_white_dwm;
global g_FastICA_ica_sig;
global g_FastICA_ica_A;
global g_FastICA_ica_W;
global g_FastICA_initGuess;
global g_FastICA_approach;
global g_FastICA_numOfIC;
global g_FastICA_g;
global g_FastICA_a1;
global g_FastICA_a2;
global g_FastICA_epsilon;
global g_FastICA_maxNumIte;
global g_FastICA_initState;
global g_FastICA_displayMo;
global g_FastICA_displayIn;
global g_FastICA_verbose;
% String values are here
global c_FastICA_appr_strV;
global c_FastICA_g1_strD;
global c_FastICA_g1_strV;
global c_FastICA_g2_strD;
global c_FastICA_g2_strV;
global c_FastICA_iSta_strV;
global c_FastICA_dMod_strV;
global c_FastICA_verb_strV;
% What is the load type of load dialog
global g_FastICA_loadType;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% What ever we do, it will take some time... not much, but some :-)
watchonInFigure = watchon;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if strcmp(action, 'InitAll')
% If the data is already loaded, then get the information from data
% and show to the user (also set g_FastICA_numOfIC)
if ~isempty(g_FastICA_mixedsig)
set(h_t_mixedStatus, 'String', '');
[dim, numofsamp] = size(g_FastICA_mixedsig);
set(h_t_dim, 'String', int2str(dim));
set(h_t_numOfSamp, 'String', int2str(numofsamp));
set(h_t_newDim, 'String', int2str(dim));
set(h_e_numOfIC, 'String', int2str(dim));
g_FastICA_numOfIC = dim;
g_mix_meanremoved = 0;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elseif strcmp(action, 'LoadData')
handle = findobj('Tag','f_FastICALoad'); % Check if the window is already
if isempty(handle) % open. If not then open it.
pos = get(h_f_FastICA, 'Position');
gui_l(pos(1), pos(2));
else
if strcmp(g_FastICA_loadType, 'data') % Check if it was the same load
figure(handle); % window. If it wasn't then
else % close the other window first
close(handle); % and then open the load window
fprintf('''Load initial guess'' -dialog closed!\n');
pos = get(h_f_FastICA, 'Position');
gui_l(pos(1), pos(2));
end
end
% gui_cb NewData; - is called from the load function if not canceled...
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elseif strcmp(action, 'NewData')
% New data is loaded or the old data changed. We need to find out
% somethings about the new data... and do some other stuff also...
[dim, numofsamp] = size(g_FastICA_mixedsig);
set(h_t_dim, 'String', dim);
set(h_t_newDim, 'String', dim);
set(h_t_numOfSamp, 'String', numofsamp);
set(h_e_numOfIC, 'String', int2str(dim));
g_FastICA_numOfIC = dim; % Default for numOfIC = the new dimension
% PCA needs to be calculated again.
g_FastICA_pca_E = []; % We use this to check if PCA is calculated
gui_cb NullWhite; % Whitening needs to be done again also
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elseif strcmp(action, 'NullWhite')
% Whitening needs to done again next time it's needed
g_FastICA_white_sig = []; % We use this to check if whitening is calculated
gui_cb NullICA; % The FPICA must be calculated again
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elseif strcmp(action, 'NullICA')
% If IC's are needed they have to bee calculated again
g_FastICA_ica_sig = []; % We use this to check if FPICA is calculated
set(h_t_icaStatus,'String','Not yet done');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elseif strcmp(action, 'Transpose')
g_FastICA_mixedsig = g_FastICA_mixedsig';
gui_cb NewData; % Data has been changed
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elseif strcmp(action, 'DoPCA')
if ~isempty(g_FastICA_mixedsig)
% We'll remove mean of the data here also just in case...
if ~(g_mix_meanremoved)
g_mix_meanremoved = 1;
g_FastICA_mixedsig = remmean(g_FastICA_mixedsig);
end
% Do PCA interactively: ask the user for eigenvalues
[g_FastICA_pca_E, g_FastICA_pca_D] = pcamat(g_FastICA_mixedsig, ...
0, 0, 'gui', deblank(c_FastICA_verb_strV(g_FastICA_verbose,:)));
newdim = size(g_FastICA_pca_D, 1);
set(h_t_newDim, 'String', int2str(newdim));
set(h_e_numOfIC, 'String', int2str(newdim));
g_FastICA_numOfIC = newdim;
gui_cb NullWhite; % Whitening needs to be done again also
% but we'll do it when it's needed.
else
fprintf('Data not loaded yet!\n\n');
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elseif strcmp(action, 'OrigDim')
gui_cb NewData;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elseif strcmp(action, 'ShowMixed')
if ~isempty(g_FastICA_mixedsig)
handle = findobj('Tag','f_FastICA_mix'); % Check if the window is already
if isempty(handle) % open. If not then open it.
figure('Tag', 'f_FastICA_mix', ...
'Name', 'FastICA: Plot data', ...
'NumberTitle', 'off');
else
figure(handle);
clf; % clear the figure for next plots
end
dispsig(g_FastICA_mixedsig');
if g_mix_meanremoved
title('Mixed signals (mean removed)');
else
title('Mixed signals');
end
else
fprintf('Data not loaded yet!\n\n');
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elseif strcmp(action, 'ShowWhite')
if ~isempty(g_FastICA_mixedsig)
if isempty(g_FastICA_white_sig) % if whitening is not done, we need to
gui_cb Whiten; % do it before we can display the
end % whitened signals
handle = findobj('Tag','f_FastICA_white'); % Check if the window is already
if isempty(handle) % open. If not then open it.
figure('Tag', 'f_FastICA_white', ...
'Name', 'FastICA: Plot whitened', ...
'NumberTitle', 'off');
else
figure(handle);
clf; % clear the figure for next plots
end
dispsig(g_FastICA_white_sig');
title('Whitened signals');
else
fprintf('Data not loaded yet!\n\n');
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elseif strcmp (action, 'Whiten')
set(h_t_whiteStatus,'String','Computing...');
% If PCA is not calculated, we'll have to calculate it now,
% we'll do it without guestions - we don't reduce the dimension
% here - but PCAMAT might reduce the dimension automatically.
if isempty(g_FastICA_pca_E)
% We'll remove mean of the data here also just in case...
if ~(g_mix_meanremoved)
g_mix_meanremoved = 1;
g_FastICA_mixedsig = remmean(g_FastICA_mixedsig);
end
[g_FastICA_pca_E, g_FastICA_pca_D] = pcamat(g_FastICA_mixedsig, ...
1, size(g_FastICA_mixedsig, 1), 'off', ...
deblank(c_FastICA_verb_strV(g_FastICA_verbose,:)));
% Check if the dimension was reduced automatically
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -