diff --git a/SS_TestOpsOnTSClusters.m b/SS_TestOpsOnTSClusters.m index dd23b50..9909f5b 100644 --- a/SS_TestOpsOnTSClusters.m +++ b/SS_TestOpsOnTSClusters.m @@ -3,37 +3,31 @@ load('run_options.mat'); load('HCTSA_N.mat'); load('linkage_clustered_ops.mat'); -load('resid_variance.mat'); +load('auto_chosen_ops.mat'); + +% Create a reduced data matrix using the automatically chosen operations +reducedMat = TS_DataMat(:,autoChosenIdxs); +reducedDists = pdist(reducedMat); % Cluster the time series using the reduced (K-medoids) operation space maxIter = 100; -nrepeats = 500; ts_k = round(size(TS_DataMat,1) / av_ts_cluster_size); -[CCi, Cass, err, Cord] = BF_kmedoids(squareform(S_red), ts_k, maxIter, nrepeats); +[~,Cass,~,Cord] = BF_kmedoids(squareform(reducedDists), ts_k, maxIter, ts_km_repeats); % Sort clusters by size [~,I] = sort(cellfun(@length,Cord),'descend'); -% Plot a few TS from each of the clusters -sPlotNum = 1; -plotsPerGroup = 4; -plotColours = get(0,'DefaultAxesColorOrder'); -numGroups = 10; -for i = 1:numGroups +figure; +plotOptions = struct('plotFreeForm',1,'displayTitles',0,'newFigure',0); +numPerGroup = 40; +maxLength = 500; +numPlots = 12; +for i = 1:numPlots + subplot(2,numPlots / 2,i); series = find(Cass == I(i)); - for j = 1:min(plotsPerGroup,length(series)) - subplot(numGroups,plotsPerGroup,sPlotNum); - plot(TimeSeries(series(j)).Data,'color',plotColours(max(1,mod(i,8)),:)); - set(gca,'XTickLabel','','YTickLabel','') - if j == 1 - title(['Group ',num2str(i)]); - end - title(TimeSeries(series(j)).Keywords); - sPlotNum = sPlotNum + 1; - end - sPlotNum = (plotsPerGroup * i) + 1; -end + TS_plot_timeseries('norm',numPerGroup,series,maxLength,plotOptions); + title(sprintf('Cluster %i (%i time series)',i,length(series))); end