% - we quickly check that all partitionings are verified
% - afterwards a few testplots in dependence of nC and/or nH follow

% clear all
% close all

%% Script Switches
part2 = 1;      % this will only work properly, if measures are generated and tested
% examples filter
ex_filter = {'generic_potash_alum', ...
             'generic_paracetamol', ...
             'generic_MgSO4_11H2O'};
% measures filter
meas_filter = {'volume', ...
               'surface', ...
               'feret'};

%% Load Data
if ~exist('data', 'var')
    data = load('SRdata.mat');
    data = data.data;
end

%% Filter examples
example = fieldnames(data);
idx = 1;
while idx <= length(example)
    valid = 0;
    for i = 1:length(ex_filter)
        valid = valid || (...
            length(example{idx}) >= length(ex_filter{i}) && ...
            strcmp(ex_filter{i}, example{idx}(1:length(ex_filter{i})))...
            );
        if valid
            tmp_ex_idx = i;
            break
        end
    end
    valid = valid && isfield(data.(example{idx}), 'SR_part');
    
    if ~valid
        example(idx) = [];
    else
        ex_idx(idx) = tmp_ex_idx;
        idx = idx + 1;
    end
end

%% Verified partitions
all_verified = 1;
for i_example = 1:length(example)
    if ~data.(example{i_example}).verpart
        disp([example{i_example} ' NOT VERIFIED!']);
        all_verified = 0;
    end
end
if all_verified
    disp('All examples verified');
end