function do_ols_hdf5(feat_file,out_file,param_file,label_file,D)
    
    training = true;
    
    if(nargin < 3)
        fprintf('Not enough input parameters!\n');
        exit(1);
    elseif(nargin == 3)
        training = false;
        D = 100;
    end
    
    X = h5read(feat_file,'/fv_matrix');
    
    if training
        patids = h5read(feat_file,'/patient_ids');
        patids = patids + 1;
        load(label_file)
        
        Y = zeros(size(X,2),1);
        
        npats = length(unique(patids));
        for i = 1:npats
            Y(patids == i) = label_list(i);
        end
        
        redidx = pls_multiclass_v2(X,Y,unique(Y),D);
        
        save(param_file,'redidx')
        
        features = cell(1,npats);
        for i = 1:npats
            cfmtx = X(:,patids == i);
            features{i} = cfmtx(logical(redidx),:)';
        end
        
        save(out_file,'features') 
        
%         h5write(out_file,'/fv_matrix',X(redidx,:))
%         h5write(out_file,'/patient_ids',patids)
              
    else
        error('Testing not currently supported!')
    end

end