function image_db = get_image_db(rel_directory)
% funkce nacte data ze strukturovane slozky do struktury uvnitr Matlabu

dir_img = fullfile(rel_directory, 'img');
dir_mask = fullfile(rel_directory, 'mask');

list_img = dir(dir_img);
list_mask = dir(dir_mask);


list_img = list_img(~[list_img.isdir]);
list_mask = list_mask(~[list_mask.isdir]);

% assert(numel(list_img) == numel(list_mask))

image_db = struct;

for m = 1:numel(list_img)
    
    name_split = split(list_img(m).name,'.');
    if ~strcmpi(name_split{2}, 'dcm')
        continue
    end
    
    file_name = fullfile(list_img(m).folder, list_img(m).name);

    [image_db(m).img, image_db(m).pix_size] = func.load_dicom_data(file_name);
    
    file_name = fullfile(list_mask(m).folder, list_mask(m).name);
    image_db(m).mask = logical(imread(file_name));
    
    
    image_db(m).name = name_split{1};
    
    params_split = split(name_split{1}, '_');
    
    image_db(m).disc = params_split{1};
    image_db(m).modality = params_split{2};
    image_db(m).series = params_split{3};
    image_db(m).num = params_split{4};
end

end

