Skip to content
Permalink
8251bfc29a
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
79 lines (50 sloc) 2.27 KB
function [ClusterTable] = Cluster_Overlap_main(ImageFiles)
%%%% ----- Cluster Overlap Task ----- %%%%
%---------------------------------------------------------------------------------------------------------------%
% Documentation: Run this script to obtain proportion of brain
% regions detected in the cluster images. The output will appear in the
% command window as the number of clusters detected
% and the proportion (in percentage) of different brain regions present in
% each cluster.
% 'CodeDir' contains the fullpath to the folder into which the Toolbox is copied.
% 'DataDir' is the fullpath to the directory whose data needs to be analysed
% by this pipeline.
%
% -----------------------------------------%
% Tanusree Chaudhuri
% Max Planck Institute of Psychiatry, Munich
% -----------------------------------------%
%---------------------------------------------------------------------------------------------------------------%
global DataDir;
global TemplatesDir;
cd(DataDir);
% ----- Binarizing cluster image ------ %
ImagesToBeMasked = ImageFiles;
InputFilename = cellstr(ImagesToBeMasked);
[pth,nam,ext] = spm_fileparts(ImageFiles);
OutputFilename = strcat(pth,'/Mask_',nam,ext);
MaskingClusterImages(InputFilename,OutputFilename);
% ------ Cluster Labelling.------ %
ClusterMask = spm_vol(OutputFilename);
ClusterMask = spm_read_vols(ClusterMask);
CC = bwconncomp(ClusterMask);
NumberOfClusters = CC.NumObjects;
for img_cluster = 1:NumberOfClusters
[ClusterLabels,ClusterParents,ClusterLabelsPercent] = ClusterProportionInPercentages(TemplatesDir,CC,img_cluster);
if(isempty(ClusterLabels))
Cluster_blob_num = cellstr(repmat(['Cluster',' ',num2str(img_cluster)],[1, 1]));
ClusterLabels{end + 1} = [];
ClusterLabelsPercent = 100;
ClusterParents{end + 1} = [];
end
Cluster_blob_num = cellstr(repmat(['Cluster',' ',num2str(img_cluster)],[length(ClusterLabels) 1]));
ClusterParents = ClusterParents';
ClusterImageInfo = table(Cluster_blob_num,ClusterLabels,ClusterParents,ClusterLabelsPercent);
disp(strcat('Blob','_',num2str(img_cluster),'_','done'));
if(img_cluster == 1)
ClusterTable = ClusterImageInfo;
else
ClusterTable = [ClusterTable;ClusterImageInfo];
end
end
end