function options = setoptions(varargin)

start = 1;
if (~isempty(varargin) && isstruct(varargin{1}))
    options = varargin{1};
    start = start+1;
else
    %defaults
    options.feature_select = 10000;
    options.subsample = 0.2;
    options.out_bag_estimate = false;
    options.lasso_alpha = 1.0;
end

for iter=start:2:length(varargin)
    
    if (strcmpi(varargin{iter},'SelectFeatures'))
        options.feature_select = varargin{iter+1};
    elseif (strcmpi(varargin{iter},'Subsample'))
        options.subsample = varargin{iter+1};
    elseif (strcmpi(varargin{iter},'LassoAlpha'))
        options.lasso_alpha = varargin{iter+1};
    elseif (strcmpi(varargin{iter},'OutBagEstimate'))
        options.subsample = varargin{iter+1};
    else
        error(['Unknown option ',varargin{iter}]);
    end
    
end;
