function [seg_Xs, seg_Ys, seg_SZs, file_id] = ...
        aggregate_features(config, file_info, feat_types);

n_files = file_info.num_files;

seg_Xs  = cell(1, n_files);             % features
seg_Ys  = cell(n_files, 1);             % labels
seg_SZs = cell(n_files, 1);             % segment sizes
file_id = zeros(n_files, 1);            % number of segments from each file

%% Aggregate Features for each image.
parfor file_i = 1:n_files 
    % File name and paths
    [parent_dirs, name_root] = get_file_info_entry(file_info, file_i);

    % [seg_X, seg_Y, seg_SZ, ~] = ...
    %     aggregate_img_features(parent_dirs, name_root, config, feat_types);

    % For the cornell comparison.
    [seg_X, seg_Y, seg_SZ, ~] = ...
        aggregate_box_features(parent_dirs, name_root, config, feat_types);
    
    seg_Xs{file_i} = seg_X;
    seg_Ys{file_i} = seg_Y;
    seg_SZs{file_i} = seg_SZ;
    file_id(file_i) = size(seg_Y, 1);    
end

% Where N is the number of samples:
seg_Xs = sparse(cell2mat(seg_Xs))'; % we want X to be N x n_dim
seg_Ys = double(cat(1, seg_Ys{:})); % we want Y to be N x 1
seg_SZs = cat(2, seg_SZs{:});

end
