function [feat_matrix]=statComp

% Funkce pro vypocet statistickych parametru z MIR parametru
% Stepan Miklanek, 2018

DBpath = uigetdir;
if DBpath == 0
fprintf('Chyba. Zadej cestu k MIR parametrum.\n')
return
end

DBinfo = dir(DBpath);
filenames = extractfield(DBinfo(3:end),'name');
nFeatures = length(filenames);
mkdir(DBpath,'statPar');

%%
for n = 1:nFeatures
        
    currentFile = filenames{n};  
    filename = [DBpath,'\',currentFile]; 
    [~,name,~] = fileparts(filename);
    load(filename,name);
    
    loadedStruct = load(filename,name);
    featureCell = struct2array(loadedStruct);   
    
    statFeatures = statParFromMir(featureCell);

    savepath = [DBpath,'\statPar\',name,'.mat'];
    
    save(savepath,'statFeatures')
        
end

% Spojeni vsech matic statistickych parametru

% statnames = cell(10,1);
% statnames{1,1} = 'mean';
% statnames{2,1} = 'median';
% statnames{3,1} = 'std';
% statnames{4,1} = 'var';
% statnames{5,1} = 'Q1';
% statnames{6,1} = 'Q3';
% statnames{7,1} = 'IQR';
% statnames{8,1} = '1p';
% statnames{9,1} = '99p';
% statnames{10,1} = 'ir';
% 

statPath = [DBpath,'\statPar'];
statInfo = dir(statPath);

filenames = extractfield(statInfo(3:end),'name');
nFiles = length(filenames);

feat_matrix = [];

% featNames = []; 
% tempNames = [];
% 
% for n = 1:nFiles
%         
%     currentFile = filenames{n};  
%     filename = [statPath,'\',currentFile];
%     [~,name,~] = fileparts(filename);
%     
%     data = load(filename);
%     dataCell = struct2cell(data);
%     
%     [tempNames{1:length(statnames),1}] = deal(name);
%     tempNames = strcat(tempNames,'_',statnames);  
% 
%     featNames = [featNames; tempNames];    
%     
% end

for n = 1:nFiles
        
    currentFile = filenames{n};  
    filename = [statPath,'\',currentFile];
    
    data = load(filename);
    dataCell = struct2cell(data);
    
    feat_matrix = [feat_matrix,  dataCell{1,1}];    
        
end

end

