function [ name ] = make_model_name(config, train_split, ...
                                    path_set_ind, feat_set_ind)
    
% Default path_set_ind to 1
if (nargin < 3) || isempty(path_set_ind) || (path_set_ind < 1)
    path_set_ind = 1;
end

% Default feat_set_ind to 1
if (nargin < 4) || isempty(feat_set_ind) || (feat_set_ind < 1)
    feat_set_ind = 1;
end

name = ''; % (prefix and suffix done last)

% Add the path and layer identifiers
hmp_paths = config.path_sets{path_set_ind};
for path_ind = 1:length(hmp_paths)
    name = [name '-' hmp_paths{path_ind}{:}];
end
name = strrep(name, 'hmp_path_', '');
name = strrep(name, 'layer_', '_');

% Add each feature type to the path name
feats = config.feat_sets{feat_set_ind};
for feat_ind = 1:length(feats)
    name = [name '-' feats{feat_ind}];
end    

% Add model params:
model_params = config.model_params;
name = [name '-' model_params.learner];
name = [name '-' model_params.model_type];

if isfield(config, 'norm_each_feat')
    name = [name '-' model_params.norm_each_feat];
end

if model_params.center_data
    name = [name '-center'];
end

if model_params.unit_variance
    name = [name '-unitvar'];
end

if length(model_params.svm_C) == 1
    name = [name sprintf('-C%g', model_params.svm_C)];
end

if isfield(model_params, 'remove_unlabeled') && model_params.remove_unlabeled
    name = [name '-noUL' ];    
end

if model_params.weight_classes
    name = [name '-weighted'];
end

% Add the training split id and a .mat extension 
% when train_split is not empty
% (this means we are returning a string to name a directory)
if isempty(train_split)
    name = [config.split_root name];    
else    
    name = sprintf('%s-TR%d%s.mat', config.split_root, train_split, name);
end
