Skip to content

Commit

Permalink
AIDAconnect Version 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
lscharwaechter committed Dec 2, 2021
1 parent 006a14f commit 7eee895
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 27 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file not shown.
14 changes: 11 additions & 3 deletions DTI/GraphEval/getMergedDTI_data.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function getMergedDTI_data(dtiStruct,thres)
function getMergedDTI_data(dtiStruct,thres_type,thres)

%% getMergedDTI_data
% This function is used by mergeFMRIdata_input.m and is not meant to be
Expand Down Expand Up @@ -39,6 +39,7 @@ function getMergedDTI_data(dtiStruct,thres)
charPathLength = nan(1,length(matFile_cur));
charPathLength_rand = nan(1,length(matFile_cur));
charPathLength_normalized = nan(1,length(matFile_cur));
overallConnectivity = zeros(1,length(matFile_cur));

if length(matFile_cur)<1
error('There is no content in the given path!');
Expand Down Expand Up @@ -66,14 +67,20 @@ function getMergedDTI_data(dtiStruct,thres)
current_matAll(current_matAll<=0) = 0;

% Apply the threshold for the number of fibers
threshold = mean(current_matAll)*thres;
current_matAll(current_matAll<threshold) = 0;
switch(thres_type)
case 0 % Fixed threshold
threshold = mean(current_matAll)*thres;
current_matAll(current_matAll<threshold) = 0;
case 1 % Density-based threshold
current_matAll(:,:,i) = threshold_proportional(current_matAll(:,:,i),thres);
end

% Ensure there are no self-connections
for ii = 1:size(current_matAll,1)
current_matAll(ii,ii,i) = 0;
end
current_mat = current_matAll(:,:,i);
overallConnectivity(i) = mean(current_mat, 'all');

% Hint:
% The calculations of the following metrics using BCT
Expand Down Expand Up @@ -171,6 +178,7 @@ function getMergedDTI_data(dtiStruct,thres)
clustercoef_normalized(:,i) = nanmean(clustercoef(:,i),2)./nanmean(clustercoef_rand(:,i),2);
charPathLength_normalized(i) = charPathLength(i)/charPathLength_rand(i);
infoDTI.smallWorldness = (clustercoef_normalized(:,i)/charPathLength_normalized(i))';
infoDTI.overallConnectivity = overallConnectivity;

%infoDTI.smallWorldness = (nanmean(clustercoef(:,i),2)/charPathLength(i))';

Expand Down
9 changes: 7 additions & 2 deletions DTI/mergeDTIdata_input.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@
% Groups (e.g. "Sham" etc.)
inputDTI.groups = ["Group1", "Group2"];

% Threshold Type (0: Fixed, 1: Density-based)
thres_type = 1;

% Threshold (0-1)
thres = 0;
% For the Density-based threshold, this is the proportion of
% the biggest weights to preserve
thres = 0.8;

% Output path
inputDTI.out_path = "/Volumes/path/to/desired/output";
Expand All @@ -29,7 +34,7 @@
addpath('./GraphEval/')
if ~exist(inputDTI.out_path,'dir')
mkdir(inputDTI.out_path)
getMergedDTI_data(inputDTI,thres);
getMergedDTI_data(inputDTI,thres_type,thres);
end
[graphCell,matrixValues,ids]=graphAnalysis_DTI(inputDTI);
acronyms = load('../Tools/infoData/acronyms_splitted.mat').acronyms;
22 changes: 15 additions & 7 deletions DTI/plotDistribution.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ function plotDistribution(inputDTI, graphCell, strParameter, day)
% Displays the distribution either of the node degree or of the
% node strength (mean over all subjects)
% for all groups at a given time point.
% You can specify a value range in lines 16 and 17 to additionally output
% the region's names whose degree/strength values are within that range.
% You can specify a value range in lines 16 and 17 to limit the range
% in the plot. Region's names whose degree/strength values are within that
% range are furthermore displayed in the Command Window.

% Input Arguments
% inputDTI and graphCell from mergeDTIdata_input.m
% strParameter = 'Degree', 'Strength'
% day = Name of the day to examine as in inputDTI.days (as String)

%% Specifications
lowerBound = 50;
upperBound = 60;
lowerBound = 1;
upperBound = 90;
nbins=20;

%% Example
% plotDistribution(inputDTI, graphCell, 'Degree', 'Baseline')
Expand All @@ -25,7 +27,8 @@ function plotDistribution(inputDTI, graphCell, strParameter, day)
dayIdx = (days == day);
groups = inputDTI.groups;
numOfGroups = size(groups,2);

edges=linspace(lowerBound,upperBound,nbins+1);

figure('Name', 'plotDistribution');
for i = 1:numOfGroups
subplot(numOfGroups,1,i);
Expand All @@ -39,13 +42,15 @@ function plotDistribution(inputDTI, graphCell, strParameter, day)
end
end
% Plot the distribution
hist = histogram(groupMeanValues{i});
histo = histogram(groupMeanValues{i}, edges);
binCounts = histo.BinCounts;
binEdges = histo.BinEdges;
title(strrep(groups(i),'_',' ')+" at "+day);
xlabel(strcat("Mean",plotxLabel));
ylabel('Frequency of occurrence');
set(gca,'FontSize',12)
% Prevent scientific notation
axes = ancestor(hist, 'axes');
axes = ancestor(histo, 'axes');
axes.XAxis.Exponent = 0;
xtickformat('%.0f')
% Display all regions that have a degree/strength within a specified range
Expand All @@ -54,6 +59,9 @@ function plotDistribution(inputDTI, graphCell, strParameter, day)
regionsValues = groupMeanValues{i}(valueIdxFiltered);
groupTable = table(regionsNames, regionsValues);
groupTable.Properties.VariableNames = {'Region', strcat('Mean',plotxLabel)};
%h = findobj(gcf, 'Type', 'histogram');
%hdata = h(BinEdges);
%disp(h.Values);
disp(strcat("Regions with a mean",lower(plotxLabel)," between ",string(lowerBound)," and ",string(upperBound)," of ",strrep(groups(i),'_',' ')," at ",day,":"));
if size(groupTable) ~= 0
disp(groupTable);
Expand Down
6 changes: 5 additions & 1 deletion DTI/plotGlobalParameter.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function plotGlobalParameter(inputDTI, graphCell, strParameter)
% Input Arguments
% inputDTI and graphCell from mergeDTIdata_input.m
% strParameter = 'Density', 'Transitivity', 'Efficiency', 'Assortativity',
% 'Modularity', 'charPathLength', 'smallWorldness'
% 'Modularity', 'charPathLength', 'smallWorldness', 'overallconnectivity'

%% Example
% plotGlobalParameter(inputDTI, graphCell, 'Density')
Expand Down Expand Up @@ -53,6 +53,10 @@ function plotGlobalParameter(inputDTI, graphCell, strParameter)
tempFile = load(fullfile(path,groups(gIdx),[char(days(dIdx)) '.mat']));
currValues = tempFile.infoDTI.smallWorldness;
valuesGroup{gIdx}(1:size(currValues,2),dIdx) = currValues;
case 'overallconnectivity'
tempFile = load(fullfile(path,groups(gIdx),[char(days(dIdx)) '.mat']));
currValues = tempFile.infoDTI.overallConnectivity;
valuesGroup{gIdx}(1:size(currValues,2),dIdx) = currValues;
otherwise
error('No valid Argument')
end
Expand Down
Binary file modified T2/.DS_Store
Binary file not shown.
Binary file modified Tools/.DS_Store
Binary file not shown.
11 changes: 8 additions & 3 deletions fMRI/mergeFMRIdata_input.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@
% Groups e.g. “Sham” etc.
inputFMRI.groups = ["Group1", "Group2"];

% Threshold
thres = 0.1;
% Threshold Type (0: Fixed, 1: Density-based)
thres_type = 1;

% Threshold (0-1)
% For the Density-based threshold, this is the proportion of
% the biggest weights to preserve
thres = 0.8;

% Output path
inputFMRI.out_path = "/Volumes/path/to/desired/output";
Expand All @@ -29,7 +34,7 @@
addpath('./rsfMRI_Processing/')
if ~exist(inputFMRI.out_path,'dir')
mkdir(inputFMRI.out_path)
getMergedFMRI_data(inputFMRI,thres);
getMergedFMRI_data(inputFMRI,thres_type,thres);
end
[graphCell,matrixValues,ids]=graphAnalysis_fMRI(inputFMRI);
acronyms = load('../Tools/infoData/acronyms_splitted.mat').acronyms;
22 changes: 15 additions & 7 deletions fMRI/plotDistribution.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ function plotDistribution(inputFMRI, graphCell, strParameter, day)
% Displays the distribution either of the node degree or of the
% node strength (mean over all subjects)
% for all groups at a given time point.
% You can specify a value range in lines 16 and 17 to additionally output
% the region's names whose degree/strength values are within that range.
% You can specify a value range in lines 16 and 17 to limit the range
% in the plot. Region's names whose degree/strength values are within that
% range are furthermore displayed in the Command Window.

% Input Arguments
% inputFMRI and graphCell from mergeFMRIdata_input.m
% strParameter = 'Degree', 'Strength'
% day = Name of the day to examine as in inputFMRI.days (as String)

%% Specifications
lowerBound = 50;
upperBound = 60;
lowerBound = 70;
upperBound = 90;
nbins=20;

%% Example
% plotDistribution(inputFMRI, graphCell, 'Degree', 'Baseline')
Expand All @@ -25,7 +27,8 @@ function plotDistribution(inputFMRI, graphCell, strParameter, day)
dayIdx = (days == day);
groups = inputFMRI.groups;
numOfGroups = size(groups,2);

edges=linspace(lowerBound,upperBound,nbins+1);

figure('Name', 'plotDistribution');
for i = 1:numOfGroups
subplot(numOfGroups,1,i);
Expand All @@ -39,13 +42,15 @@ function plotDistribution(inputFMRI, graphCell, strParameter, day)
end
end
% Plot the distribution
hist = histogram(groupMeanValues{i});
histo = histogram(groupMeanValues{i}, edges);
binCounts = histo.BinCounts;
binEdges = histo.BinEdges;
title(strrep(groups(i),'_',' ')+" at "+day);
xlabel(strcat("Mean",plotxLabel));
ylabel('Frequency of occurrence');
set(gca,'FontSize',12)
% Prevent scientific notation
axes = ancestor(hist, 'axes');
axes = ancestor(histo, 'axes');
axes.XAxis.Exponent = 0;
xtickformat('%.0f')
% Display all regions that have a degree/strength within a specified range
Expand All @@ -54,6 +59,9 @@ function plotDistribution(inputFMRI, graphCell, strParameter, day)
regionsValues = groupMeanValues{i}(valueIdxFiltered);
groupTable = table(regionsNames, regionsValues);
groupTable.Properties.VariableNames = {'Region', strcat('Mean',plotxLabel)};
%h = findobj(gcf, 'Type', 'histogram');
%hdata = h(BinEdges);
%disp(h.Values);
disp(strcat("Regions with a mean",lower(plotxLabel)," between ",string(lowerBound)," and ",string(upperBound)," of ",strrep(groups(i),'_',' ')," at ",day,":"));
if size(groupTable) ~= 0
disp(groupTable);
Expand Down
3 changes: 2 additions & 1 deletion fMRI/plotGlobalParameter.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ function plotGlobalParameter(inputFMRI, graphCell, strParameter)

% Input Arguments
% inputFMRI and graphCell from mergeFMRIdata_input.m
% strParameter = 'Density', 'Transitivity', 'Efficiency', 'Assortativity', 'Modularity', 'charPathLength', 'smallWorldness'
% strParameter = 'Density', 'Transitivity', 'Efficiency', 'Assortativity',
% 'Modularity', 'charPathLength', 'smallWorldness', 'overallconnectivity'

%% Example
% plotGlobalParameter(inputFMRI, graphCell, 'Modularity')
Expand Down
14 changes: 11 additions & 3 deletions fMRI/rsfMRI_Processing/getMergedFMRI_data.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function getMergedFMRI_data(fmriStruct,thres)
function getMergedFMRI_data(fmriStruct,thres_type,thres)

%% getMergedFMRI_data
% This function is used by mergeFMRIdata_input.m and is not meant to be
Expand Down Expand Up @@ -68,10 +68,18 @@ function getMergedFMRI_data(fmriStruct,thres)

[coMat(:,:,i),labels] = matrixMaker_rsfMRI((fullfile(matFile_cur(i).folder,matFile_cur(i).name)));
current_matAll = abs(coMat); % Absolute values of the matrices
current_matAll(current_matAll<thres) = 0; % Threshold for correlations

% Threshold for correlations
switch(thres_type)
case 0 % Fixed threshold
current_matAll(current_matAll<thres) = 0;
case 1 % Density-based threshold
current_matAll(:,:,i) = threshold_proportional(current_matAll(:,:,i),thres);
end

% Ensure there are no self-connections
for ii = 1:size(current_matAll,1)
current_matAll(ii,ii,i) = 0; % Ensure there are no self-connections
current_matAll(ii,ii,i) = 0;
end
current_mat = current_matAll(:,:,i);
overallConnectivity(i) = mean(current_mat, 'all');
Expand Down

0 comments on commit 7eee895

Please sign in to comment.