diff --git a/Allen_to_GroupSpace.m b/Allen_to_GroupSpace.m index d18d6ac..09cdd3f 100644 --- a/Allen_to_GroupSpace.m +++ b/Allen_to_GroupSpace.m @@ -1,6 +1,13 @@ function Allen_to_GroupSpace(Templates) -% ------ Transformation of ANO to group template space ------ % +% Description: Transformation of ANO file to group template space +% -----------------------------------------% +% Tanusree Chaudhuri +% Max Planck Institute of Psychiatry, Munich +% tanusree_chaudhuri@psych.mpg.de +% -----------------------------------------% + +% ----------------------------------------------------------------------------------------% global DataDir; global TemplatesDir; diff --git a/ClusterLabelling.m b/ClusterLabelling.m index 9b8f3a8..82c4730 100644 --- a/ClusterLabelling.m +++ b/ClusterLabelling.m @@ -1,5 +1,14 @@ function [ClusterLabels, ClusterParents] = ClusterLabelling(ClusterIntensities,ANO) + +% Description: Labelling detected brain regions in each cluster blob in the +% cluster image. + +% -----------------------------------------% +% Tanusree Chaudhuri +% Max Planck Institute of Psychiatry, Munich +% tanusree_chaudhuri@psych.mpg.de +% -----------------------------------------% Region = table2array(ANO(:,1)); ID = table2array(ANO(:,4)); colHex = table2array(ANO(:,2)); diff --git a/Cluster_Overlap_main.m b/Cluster_Overlap_main.m index de62108..2910e09 100644 --- a/Cluster_Overlap_main.m +++ b/Cluster_Overlap_main.m @@ -1,20 +1,22 @@ function [ClusterTable] = Cluster_Overlap_main(ImageFiles) +% %----Description----% +% Run this script to obtain proportion of brain regions detected in the cluster images. -%%%% ----- 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. +% FORMAT [ClusterTable] = Cluster_Overlap_main(ImageFiles) +% +% %----Input----% +% ImageFiles: Filename of cluster image. + +% %----Output----% +% ClusterTable: Table array showing percentages and parent regions of +% detected brain regions in each cluster blob. % % -----------------------------------------% % Tanusree Chaudhuri % Max Planck Institute of Psychiatry, Munich +% tanusree_chaudhuri@psych.mpg.de % -----------------------------------------% + %---------------------------------------------------------------------------------------------------------------% global DataDir; diff --git a/Cluster_Overlap_main.m~ b/Cluster_Overlap_main.m~ new file mode 100644 index 0000000..d7d08ee --- /dev/null +++ b/Cluster_Overlap_main.m~ @@ -0,0 +1,88 @@ +function [ClusterTable] = Cluster_Overlap_main(ImageFiles) + +%%%% ----- Cluster Overlap Task ----- %%%% +%---------------------------------------------------------------------------------------------------------------% + +% '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. +% +% %----Description----% +% Run this script to obtain proportion of brain regions detected in the cluster images. + +% FORMAT [ClusterTable] = Cluster_Overlap_main(ImageFiles) +% +% %----Input----% +% ImageFiles: Filename of cluster image. + +% %----Output----% +% ClusterTable: Table array showing per +% +% -----------------------------------------% +% Tanusree Chaudhuri +% Max Planck Institute of Psychiatry, Munich +% tanusree_chaudhuri@psych.mpg.de +% -----------------------------------------% + +%---------------------------------------------------------------------------------------------------------------% + +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 + + + + + + + + + + + + + + + diff --git a/Start_ARET.m b/Start_ARET.m index 797cad1..dc27a5f 100644 --- a/Start_ARET.m +++ b/Start_ARET.m @@ -1,4 +1,14 @@ %%% ------ START ARET ------ %%%% +% ------------------------------ % + +% Description: start Allen ROI Extraction Toolbox to perform two +% functionalities - ROI Extraction and Cluster Labelling. + +% -----------------------------------------% +% Tanusree Chaudhuri +% Max Planck Institute of Psychiatry, Munich +% tanusree_chaudhuri@psych.mpg.de +% -----------------------------------------% %% ----- Variables to be changed before running this script ----- %%% diff --git a/annotation_tan.m b/annotation_tan.m index 2f49e57..e854566 100644 --- a/annotation_tan.m +++ b/annotation_tan.m @@ -2,42 +2,30 @@ function [Int_ROI,ROI] = annotation_tan(brain_region) % %----Description----% -% Create masks of user specified gray matter regions using the latest antx templates, -% specifically the annotation template(ANO.nii) and the allen table. -% Both files are located in TemplatesDir directory. +% Create masks of user specified brain regions using the annotation +% template(ANO.nii) and the allen table in the templates folder. -% FORMAT [Int,mask,idxLUT] = annotation_tan(brain_region) +% FORMAT [Int_ROI,ROI] = annotation_tan(brain_region) % % %----Input----% -% DataDir: fullpath to the directory with the cluster data. -% TemplatesDir = fullpath to the templates directory, which contains the -% latest templates from the following link: -% https://drive.google.com/drive/folders/1q5XOOVLvUYLqYsQJLqNRF7OK8fNwYhI9 % brain_region: name of brain region whose mask will be generated by this % function. % Please refer to manual to know how to give brain_region as an input. % %----Output----% % Int: the allen intensities present in brain_region -% mask: image volume of brain_region +% ROI: image volume of brain_region % % -----------------------------------------% % Tanusree Chaudhuri % Max Planck Institute of Psychiatry, Munich +% tanusree_chaudhuri@psych.mpg.de % -----------------------------------------% -%global DataDir global TemplatesDir global ROI_ResultsDir -% % ---- Creating subfolder for output images ---- % -% cd(DataDir); -% % if ~exist('ROI_Masks', 'dir') -% % mkdir('ROI_Masks') -% % end -% mkdir(ROI_ResultsDir); - % ---------- 1. ANO table ------------ %%%%% ANO = readtable(strcat(TemplatesDir,'/ANO.xlsx')); Regions = table2array(ANO(:,1));