function example_loop(data,objects, np,vectors,nr,see)
%data ---> 'coil' Images from COIL-100
%           'orl' Faces from ORL 
%objects --> number of classes
%np ---> number of samples per class
%vectors----> array with the dimensions used to make the transformation
%nr ---> number of repetitions of the classification process 
%
% For example: example_loop('coil',10,35,[2 4 6 8 10],10,0)
%%%%%%%%%%%%%% example_loop('coil',100,5,[2 4 6 8 10],10,0)

path(path,'./FastICA_25'); 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
switch data
    case 'coil'
        x=data_coil_100(objects,np,see);% Images from COIL-100 %%http://www1.cs.columbia.edu/CAVE/software/softlib/coil-100.php
    case 'orl'
        x=data_orl_faces(objects,np,see);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
nc=objects;         %number of classes
per_test=0.5;       %percentage of test samples from x (0-1)
selection=0;        %feature selection: (NO ==> 0;  YES ==> 1)
see=0;

cont=0;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for  n_vectors=vectors;        
    
    cont=cont+1;
    
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    algorithm=1; %FastICA
    data_file=extraction(x,nc,np,algorithm,n_vectors,see);%feature extraction (PCA and ICA)
    [p_ica, p_white]=classifier(data_file,nc,np,algorithm,per_test,n_vectors,nr,selection,see)%classification with k-NN
    F(cont)=mean(p_ica);
    WF(cont)=mean(p_white);
    F2(cont)=std(p_ica)/sqrt(nr);
    WF2(cont)=std(p_white)/sqrt(nr);
    
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    algorithm=2 %INFOMAX
    data_file=extraction(x,nc,np,algorithm,n_vectors,see);%feature extraction (PCA and ICA)
    [p_ica, p_white]=classifier(data_file,nc,np,algorithm,per_test,n_vectors,nr,selection,see)%classification with k-NN
    I(cont)=mean(p_ica);
    WI(cont)=mean(p_white);
    I2(cont)=std(p_ica)/sqrt(nr);
    
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure;

% errorbar's mean values
mean_value(:,1) = WF'; % PCA
mean_value(:,2) = F'; % FastICA
mean_value(:,3) = I'; % Infomax

% errorbar's standard deviations
std_value(:,1) = WF2';
std_value(:,2) = F2';
std_value(:,3) = I2';

% errorbar's x-axis
xaxis=[1,1,1];
for i=2:length(vectors)
    xaxis=[xaxis;i i i];
end

for i=1:length(vectors)
    xaxis(i,1)=xaxis(i,1)-0.225;
    xaxis(i,3)=xaxis(i,3)+0.225;
end

% errorbar's colours
colors = [1, 1, 1; 0.8, 0.8, 0.8;0.3, 0.3, 0.3];
colormap(colors);

bar([1:length(vectors)], mean_value);
legend('Whitening', 'FastICA', 'Infomax',2);
hold on;
h = errorbar(xaxis, mean_value, std_value, std_value);
for i=1:3
    set(h(i), 'Color', 'k');
end
for i=4:6
    set(h(i), 'LineStyle', 'none');
end

% bar titles
for i=1:length(vectors)
    bar_title{i} = sprintf('%d', vectors(i));
end

set(gca, 'XTickLabel', bar_title);

xlabel('Number of vectors');
ylabel('Recognition Rate (%)');
axis([0.5 length(vectors)+0.5 min(min(mean_value-std_value))-2 max(max(mean_value+std_value))+2])
title('Whitening - FastICA - Infomax')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%