% function [clustID] = classicalLinkage(data, method, distance, cutThreshold) 
% classicalLinkage simply takes care of calling the MATLAB function LINKAGE
% (with parameters 'method' and 'distance', type 'help linkage' for more 
% details on these) for performing hierarchical clustering on 'data', and 
% the cutDendrogram function  for extracting from the resulting dendrogram 
% the clustering solution corresponding to the cutThreshold parameter.
% A vector clustID is returned, listing for each input point the ID of the
% cluster it has been assigned to.
%
% This file is part of Cluster4MetaAnalysis.
%     Cluster4MetaAnalysis is free software: you can redistribute it 
%     and/or modify it under the terms of the GNU General Public License 
%     as published by the Free Software Foundation, either version 3 of 
%     the License, or (at your option) any later version.
% 
%     Cluster4MetaAnalysis is distributed in the hope that it will be 
%     useful, but WITHOUT ANY WARRANTY; without even the implied warranty 
%     of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%     GNU General Public License for more details.
% 
%     You should have received a copy of the GNU General Public License
%     along with Cluster4MetaAnalysis.  If not, see
%     <http://www.gnu.org/licenses/>.


function [clustID, clusterData] = classicalLinkage(data, method, distance, cutThreshold)

% calling linkage.m for performing hierchical clustering
den = linkage(data, method, distance);

% cutting the dendrogram according to the cutThreshold parameter to extract
% the clustering solution (cluster IDs for each data point)
clustID = cutDendrogram(den, data, cutThreshold, 0);
clusterData = []; % this is going to be computed later
