Skip to content

Commit c142024

Browse files
committed
update graph functions
1 parent 7a6bd96 commit c142024

4 files changed

Lines changed: 108 additions & 63 deletions

File tree

braph2/analysis/test_GUIAnalysisSettings.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,13 @@
2525

2626
set(gcf, 'CloseRequestFcn', 'closereq')
2727
close(gcf)
28+
29+
%% Pass a CON cohort
30+
cohort_file = [fileparts(which('example_workflow_CON_WU.m')) filesep() 'example data CON (DTI)' filesep() 'cohort_example.cohort'];
31+
temp = load(cohort_file, '-mat', 'cohort', 'selected_group', 'selected_subjects', 'BUILD');
32+
cohort = temp.cohort;
33+
34+
GUIAnalysisSettings(cohort, 'AnalysisCON_WU')
35+
36+
% set(gcf, 'CloseRequestFcn', 'closereq')
37+
% close(gcf)

braph2/workflows/Connectivity/AnalysisCON_BUD.m

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,22 @@
3838
% getBiNodalComparisonPlot - returns a global comparison plot
3939
% getBiNodalRandomComparisonPlot - returns a global randomcomparison plot
4040
%
41-
% See also Analysis, MeasurementST_BUD, RandomComparisonST_BUD, ComparisonST_BUD
41+
% See also Analysis, MeasurementCON_BUD, RandomComparisonCON_BUD, ComparisonCON_BUD
4242

4343
methods
4444
function analysis = AnalysisCON_BUD(id, label, notes, cohort, measurements, randomcomparisons, comparisons, varargin)
4545
% AnalysisCON_BUD(ID, LABEL, NOTES, COHORT, MEASUREMENTS, RANDOMCOMPARISON, COMPARISONS)
4646
% creates a connectivity analysis of fixed density with ID, LABEL,
47-
% COHORT, MEASUREMENTS, RANDOMCOMPARISON and COMPARISONS. It
48-
% initializes the ANALYSISST_WU with default settings.
47+
% COHORT, MEASUREMENTS, RANDOMCOMPARISON and COMPARISONS. It
48+
% initializes the ANALYSISCON_WU with default settings.
4949
%
5050
% AnalysisCON_BUD(ID, LABEL, NOTES, COHORT, MEASUREMENTS, RANDOMCOMPARISON, COMPARISONS, PROPERTY, VALUE, ...)
5151
% creates a connectivity analysis of fixed density with ID, LABEL,
5252
% COHORT, MEASUREMENTS, RANDOMCOMPARISON and COMPARISONS. It
53-
% initializes the ANALYSISST_WU with specified settings VALUES.
53+
% initializes the ANALYSISCON_WU with specified settings VALUES.
5454
%
55-
% See also MeasurementST_WU, RandomComparisonST_WU, ComparisonST_WU.
56-
55+
% See also MeasurementCON_WU, RandomComparisonCON_WU, ComparisonCON_WU.
56+
5757
analysis = analysis@AnalysisCON_WU(id, label, notes, cohort, measurements, randomcomparisons, comparisons, varargin{:});
5858
end
5959
end
@@ -65,12 +65,12 @@
6565
% creates a measurement ID with the ANALYSIS class, the
6666
% MEASURE_CODE, the GROUP and the DENSITY.
6767
%
68-
% See also getRandomComparisonID, getComparisonID.
68+
% See also getRandomComparisonID, getComparisonID.
6969

7070
measurement_id = getMeasurementID@AnalysisCON_WU(analysis, measure_code, group, varargin{:});
7171

7272
density = get_from_varargin(0, 'density', varargin{:});
73-
measurement_id = [measurement_id ' density=' num2str(density)];
73+
measurement_id = [measurement_id ' density=' num2str(density)];
7474
end
7575
function randomcomparison_id = getRandomComparisonID(analysis, measure_code, group, varargin)
7676
% GETRANDOMCOMPARISONID returns a random comparison ID
@@ -79,8 +79,8 @@
7979
% creates a random comparison ID with the ANALYSIS class, the
8080
% MEASURE_CODE, the GROUP and the DENSITY.
8181
%
82-
% See also getMeasurementID, getComparisonID.
83-
82+
% See also getMeasurementID, getComparisonID.
83+
8484
randomcomparison_id = getRandomComparisonID@AnalysisCON_WU(analysis, measure_code, group, varargin{:});
8585

8686
density = get_from_varargin(0, 'density', varargin{:});
@@ -102,36 +102,46 @@
102102
end
103103
end
104104
methods (Access = protected)
105-
function g = get_graph_for_subjects(analysis, subjects, varargin)
106-
% GET_GRAPH_FOR_SUBJECTS returns the graph created with the correlation matrix
105+
function graphs = get_graphs_for_group(analysis, group, varargin)
106+
% GET_GRAPH_FOR_GROUP returns the graph created with the group data
107107
%
108-
% G = GET_GRAPH_FOR_SUBJECTS(ANALYSIS, SUBJECTS, PROPERY, VALUE, ...) creates a
108+
% G = GET_GRAPH_FOR_GROUP(ANALYSIS, GROUP) creates a
109109
% graph with the correlation matrix made of the data of
110-
% subjects. It will binarize the matrix depending on the
111-
% PROPERTY and VALUE.
110+
% subjects of the group
112111
%
113112
% See also calculate_measurement.
114113

115-
atlases = analysis.cohort.getBrainAtlases();
116-
atlas = atlases{1};
114+
graph_type = analysis.getGraphType();
115+
subjects = group.getSubjects();
116+
graphs = cell(1, group.subjectnumber());
117117

118-
subject_number = numel(subjects);
119-
120-
data = zeros(subject_number, atlas.getBrainRegions().length());
121-
for i = 1:1:subject_number
118+
for i = 1:1:group.subjectnumber()
122119
subject = subjects{i};
123-
data(i, :) = subject.getData('CON').getValue(); % st data
120+
A = subject.getData('CON').getValue(); % CON matrix
121+
122+
density = get_from_varargin(0, 'density', varargin{:});
123+
A = binarize(A, 'density', density, varargin{:});
124+
125+
graphs{i} = Graph.getGraph(graph_type, A);
124126
end
127+
end
128+
function graph = get_graph_for_subject(analysis, subject, varargin)
129+
% GET_GRAPH_FOR_SUBJECT returns the graph created with the correlation matrix
130+
%
131+
% G = GET_GRAPH_FOR_SUBJECT(ANALYSIS, SUBJECT, PROPERY, VALUE, ...) creates a
132+
% graph with the correlation matrix made of the data of
133+
% subject. It will binarize the matrix depending on the
134+
% PROPERTY and VALUE.
135+
%
136+
% See also calculate_measurement.
125137

126-
correlation_rule = analysis.getSettings('AnalysisCON.CorrelationRule');
127-
negative_weight_rule = analysis.getSettings('AnalysisCON.NegativeWeightRule');
128-
A = Correlation.getAdjacencyMatrix(data, correlation_rule, negative_weight_rule);
138+
data = subject.getData('CON').getValue();
129139

130140
density = get_from_varargin(0, 'density', varargin{:});
131-
A = binarize(A, 'density', density, varargin{:});
141+
A = binarize(data, 'density', density, varargin{:});
132142

133-
graph_type = AnalysisCON_WU.getGraphType();
134-
g = Graph.getGraph(graph_type, A);
143+
graph_type = analysis.getGraphType();
144+
graph = Graph.getGraph(graph_type, A);
135145
end
136146
end
137147
methods (Static) % Descriptive functions
@@ -172,7 +182,7 @@
172182
function graph_type = getGraphType()
173183
% GETGRAPHTYPE returns the compatible type of graph
174184
%
175-
% GRAPH_TYPE = GETGRAPHTYPE() returns the compatible type of
185+
% GRAPH_TYPE = GETGRAPHTYPE() returns the compatible type of
176186
% graph 'GraphBU'.
177187
%
178188
% See also getSubjectClass.
@@ -222,9 +232,9 @@
222232
% See also getGraphPanel, getGlobalPanel.
223233

224234
X = analysis.selectMeasurements(measure_code, group, '.getDensity()');
225-
if subject == 1
235+
if subject == 1
226236
Y = analysis.selectMeasurements(measure_code, group, '.getGroupAverageValue()');
227-
else
237+
else
228238
measurements = analysis.selectMeasurements(measure_code, group, '.getMeasureValues()');
229239
Y = cellfun(@(x) x(subject-1), measurements);
230240
end

braph2/workflows/Connectivity/AnalysisCON_BUT.m

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
% COHORT, MEASUREMENTS, RANDOMCOMPARISON and COMPARISONS. It
5353
% initializes the ANALYSISST_WU with specified settings VALUES.
5454
%
55-
% See also MeasurementST_WU, RandomComparisonST_WU, ComparisonST_WU.
55+
% See also MeasurementCON_WU, RandomComparisonCON_WU, ComparisonCON_WU.
5656

5757
analysis = analysis@AnalysisCON_WU(id, label, notes, cohort, measurements, randomcomparisons, comparisons, varargin{:});
5858
end
@@ -102,37 +102,47 @@
102102
end
103103
end
104104
methods (Access = protected)
105-
function g = get_graph_for_subjects(analysis, subjects, varargin)
106-
% GET_GRAPH_FOR_SUBJECTS returns the graph created with the correlation matrix
105+
function graphs = get_graphs_for_group(analysis, group, varargin)
106+
% GET_GRAPH_FOR_GROUP returns the graph created with the group data
107107
%
108-
% G = GET_GRAPH_FOR_SUBJECTS(ANALYSIS, SUBJECTS, PROPERY, VALUE, ...) creates a
108+
% G = GET_GRAPH_FOR_GROUP(ANALYSIS, GROUP) creates a
109109
% graph with the correlation matrix made of the data of
110-
% subjects. It will binarize the matrix depending on the
111-
% PROPERTY and VALUE.
110+
% subjects of the group
112111
%
113112
% See also calculate_measurement.
114113

115-
atlases = analysis.cohort.getBrainAtlases();
116-
atlas = atlases{1};
117-
118-
subject_number = numel(subjects);
114+
graph_type = analysis.getGraphType();
115+
subjects = group.getSubjects();
116+
graphs = cell(1, group.subjectnumber());
119117

120-
data = zeros(subject_number, atlas.getBrainRegions().length());
121-
for i = 1:1:subject_number
118+
for i = 1:1:group.subjectnumber()
122119
subject = subjects{i};
123-
data(i, :) = subject.getData('CON').getValue(); % st data
120+
A = subject.getData('CON').getValue(); % CON matrix
121+
122+
threshold = get_from_varargin(0, 'threshold', varargin{:});
123+
A = binarize(A, 'threshold', threshold, varargin{:});
124+
125+
graphs{i} = Graph.getGraph(graph_type, A);
124126
end
127+
end
128+
function graph = get_graph_for_subject(analysis, subject, varargin)
129+
% GET_GRAPH_FOR_SUBJECT returns the graph created with the correlation matrix
130+
%
131+
% G = GET_GRAPH_FOR_SUBJECT(ANALYSIS, SUBJECT, PROPERY, VALUE, ...) creates a
132+
% graph with the correlation matrix made of the data of
133+
% subject. It will binarize the matrix depending on the
134+
% PROPERTY and VALUE.
135+
%
136+
% See also calculate_measurement.
125137

126-
correlation_rule = analysis.getSettings('AnalysisCON.CorrelationRule');
127-
negative_weight_rule = analysis.getSettings('AnalysisCON.NegativeWeightRule');
128-
A = Correlation.getAdjacencyMatrix(data, correlation_rule, negative_weight_rule);
138+
data = subject.getData('CON').getValue();
129139

130140
threshold = get_from_varargin(0, 'threshold', varargin{:});
131-
A = binarize(A, 'threshold', threshold, varargin{:});
141+
A = binarize(data, 'threshold', threshold, varargin{:});
132142

133-
graph_type = AnalysisCON_WU.getGraphType();
134-
g = Graph.getGraph(graph_type, A);
135-
end
143+
graph_type = analysis.getGraphType();
144+
graph = Graph.getGraph(graph_type, A);
145+
end
136146
end
137147
methods (Static) % Descriptive functions
138148
function analysis_class = getClass()

braph2/workflows/Connectivity/AnalysisCON_WU.m

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
% getComparisonID - returns the comparison ID
1919
%
2020
% AnalysisCON_WU calcultion methods (Access = protected):
21-
% get_graph_for_subjects - returns the graph of the correlated matrix
21+
% get_graph_for_group - returns the graph of the correlated matrix
22+
% get_graph_for_subject - returns the graph of the correlated matrix
2223
% calculate_measurement - returns the measurement
2324
% calculate_random_comparison - returns the random comparison
2425
% calculate_comparison - returns the comparison
@@ -134,6 +135,20 @@
134135
graphs{i} = Graph.getGraph(graph_type, A);
135136
end
136137
end
138+
function graph = get_graph_for_subject(analysis, subject, varargin)
139+
% GET_GRAPH_FOR_SUBJECT returns the graph created with the correlation matrix
140+
%
141+
% G = GET_GRAPH_FOR_SUBJECT(ANALYSIS, SUBJECT, PROPERY, VALUE, ...) creates a
142+
% graph with the correlation matrix made of the data of
143+
% subject. It will binarize the matrix depending on the
144+
% PROPERTY and VALUE.
145+
%
146+
% See also calculate_measurement.
147+
148+
data = subject.getData('CON').getValue();
149+
graph_type = analysis.getGraphType();
150+
graph = Graph.getGraph(graph_type, data);
151+
end
137152
function measurement = calculate_measurement(analysis, measure_code, group, varargin) %#ok<*INUSL>
138153
% CALCULATE_MEASUREMENT returns a measurement
139154
%
@@ -802,7 +817,7 @@ function init_global_panel()
802817
GUI.setUnits(ui_mainpanel)
803818

804819
set(ui_global_tbl, 'BackgroundColor', GUI.TABBKGCOLOR)
805-
if isequal(analysis.getMeasurementClass(), 'MeasurementFNC_WU')
820+
if isequal(analysis.getMeasurementClass(), 'MeasurementCON_WU')
806821
set(ui_global_tbl, 'Position', [.02 .19 .96 .79])
807822
GUI.setUnits(ui_plot_measure_panel)
808823
GUI.setBackgroundColor(ui_plot_measure_panel)
@@ -1329,7 +1344,7 @@ function init_nodal_panel()
13291344
GUI.setUnits(ui_mainpanel)
13301345

13311346
set(ui_nodal_tbl, 'BackgroundColor', GUI.TABBKGCOLOR)
1332-
if isequal(analysis.getMeasurementClass(), 'MeasurementFNC_WU')
1347+
if isequal(analysis.getMeasurementClass(), 'MeasurementCON_WU')
13331348
set(ui_nodal_tbl, 'Position', [.02 .21 .96 .77])
13341349
GUI.setUnits(ui_plot_measure_panel)
13351350
GUI.setBackgroundColor(ui_plot_measure_panel)
@@ -1849,7 +1864,7 @@ function init_binodal_panel()
18491864
GUI.setUnits(ui_mainpanel)
18501865

18511866
set(ui_binodal_tbl, 'BackgroundColor', GUI.TABBKGCOLOR)
1852-
if isequal(analysis.getMeasurementClass(), 'MeasurementFNC_WU')
1867+
if isequal(analysis.getMeasurementClass(), 'MeasurementCON_WU')
18531868
set(ui_binodal_tbl, 'Position', [.02 .21 .96 .77])
18541869
GUI.setUnits(ui_plot_measure_panel)
18551870
GUI.setBackgroundColor(ui_plot_measure_panel)
@@ -2778,9 +2793,9 @@ function init_graph()
27782793
set(ui_link_type, 'Position', [.62 .06 .3 .05])
27792794
set(ui_link_type, 'Callback', {@cb_link_type});
27802795

2781-
if isequal(class(analysis), 'AnalysisFNC_BUT')
2796+
if isequal(class(analysis), 'AnalysisCON_BUT')
27822797
change_to_threshold()
2783-
elseif isequal(class(analysis), 'AnalysisFNC_BUD')
2798+
elseif isequal(class(analysis), 'AnalysisCON_BUD')
27842799
change_to_density()
27852800
else
27862801
change_to_weighted()
@@ -3767,14 +3782,14 @@ function cb_meas_labelfincolor(~, ~) % (src, event)
37673782
update_brain_meas_plot()
37683783
end
37693784
function update_figure_panel()
3770-
if isequal(ga.getClass(), 'AnalysisFNC_WU')
3785+
if isequal(ga.getClass(), 'AnalysisCON_WU')
37713786
set(ui_list_gr, 'Position', [.02 .02 .30 .68])
37723787
set(ui_list_threshold_or_density, 'Position', [0 0 0 0])
37733788
else
37743789
set(ui_list_gr, 'Position', [.02 .36 .3 .36])
37753790
set(ui_list_threshold_or_density, 'Position', [.02 .02 .3 .3])
37763791
set(list_tittle, 'Position', [.02 .32 .25 .04])
3777-
if isequal(ga.getClass(), 'AnalysisFNC_BUT')
3792+
if isequal(ga.getClass(), 'AnalysisCON_BUT')
37783793
set(list_tittle, 'String', 'Select Threshold')
37793794
else % desity
37803795
set(list_tittle, 'String', 'Select Density')
@@ -3811,7 +3826,7 @@ function update_figure_panel()
38113826
end
38123827
end
38133828
function update_list_t_d(selected_case)
3814-
if isequal(ga.getClass(), 'AnalysisFNC_BUT')
3829+
if isequal(ga.getClass(), 'AnalysisCON_BUT')
38153830
if get(ui_action_comparison_checkbox, 'Value')
38163831
[a, b] = selected_case.getGroups();
38173832
set(ui_list_threshold_or_density, 'String', analysis.selectComparisons(selected_case.getMeasureCode(), a, b, '.getThreshold()'))
@@ -3820,7 +3835,7 @@ function update_list_t_d(selected_case)
38203835
else
38213836
set(ui_list_threshold_or_density, 'String', analysis.selectMeasurements(selected_case.getMeasureCode(), selected_case.getGroup(), '.getThreshold()'))
38223837
end
3823-
elseif isequal(ga.getClass(), 'AnalysisFNC_BUD')
3838+
elseif isequal(ga.getClass(), 'AnalysisCON_BUD')
38243839
if get(ui_action_comparison_checkbox, 'Value')
38253840
[a, b] = selected_case.getGroups();
38263841
set(ui_list_threshold_or_density, 'String', analysis.selectComparisons(selected_case.getMeasureCode(), a, b, '.getDensity()'))
@@ -3898,7 +3913,7 @@ function update_measure_data(init_or_selection)
38983913
if isempty(selected_case)
38993914
errordlg(['The measure: ' measure ' for ' selected_action ' does not exist.'])
39003915
else
3901-
if isequal(analysis.getClass(), 'AnalysisFNC_WU')
3916+
if isequal(analysis.getClass(), 'AnalysisCON_WU')
39023917
switch selected_action
39033918
case 'Measurement'
39043919
measure_data = selected_case.getGroupAverageValue();
@@ -3919,7 +3934,7 @@ function update_measure_data(init_or_selection)
39193934
p2 = selected_case.getP2();
39203935
calculate_fdr_lim()
39213936
end
3922-
elseif isequal(analysis.getClass(), 'AnalysisFNC_BUT')
3937+
elseif isequal(analysis.getClass(), 'AnalysisCON_BUT')
39233938
a = get(ui_list_threshold_or_density, 'String');
39243939
b = a{get(ui_list_threshold_or_density, 'Value')};
39253940

0 commit comments

Comments
 (0)