-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNLAResult_exported.m
More file actions
790 lines (634 loc) · 34.3 KB
/
NLAResult_exported.m
File metadata and controls
790 lines (634 loc) · 34.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
classdef NLAResult < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
FileMenu matlab.ui.container.Menu
SaveButton matlab.ui.container.Menu
SaveSummaryTableMenu matlab.ui.container.Menu
ResultTree matlab.ui.container.Tree
FlipNestingButton matlab.ui.control.Button
EdgeLevelLabel matlab.ui.control.Label
ViewEdgeLevelButton matlab.ui.control.Button
NetLevelLabel matlab.ui.control.Label
RunButton matlab.ui.control.Button
BranchLabel matlab.ui.control.Label
OpenTriMatrixPlotButton matlab.ui.control.Button
OpenDiagnosticPlotsButton matlab.ui.control.Button
SelectContrastLabel matlab.ui.control.Label
SelectContrastDropdown matlab.ui.control.DropDown
end
properties (Access = private)
input_struct
net_input_struct
test_pool = false
edge_result = false
results = false
nesting_by_method = true
prog_bar = false
net_adjustable_fields
cur_iter = 0
old_data = false % data from old result objects, not NetworkTestResult
multi_contrast_edge_result = false
multi_contrast_net_result = false
selected_contrast_name = ''
end
methods (Access = private)
function node = createNode(app, parent, text, node_data)
import nla.* % required due to matlab package system quirks
node = uitreenode(parent);
node.Text = text;
if exist('node_data', 'var')
node.NodeData = node_data;
end
end
function moveCurrFigToParentLocation(app)
currPos = get(gcf, 'Position');
currWidth = currPos(3);
currHeight = currPos(4);
appWindowPos = app.UIFigure.Position;
%Position sets bottom left of figure, but we want to match the
%top left (to ensure that top of new figure is on screen()
vertOffset = currHeight - appWindowPos(4);
additionalOffset = [10, -10];
moveFigTo_x = appWindowPos(1) + additionalOffset(1);
moveFigTo_y = appWindowPos(2) + additionalOffset(2) - vertOffset;
set(gcf, 'Position', [moveFigTo_x moveFigTo_y currWidth currHeight]);
end
function setNesting(app)
% clear old nodes
for i = 1:size(app.ResultTree.Children, 1)
for j = 1:size(app.ResultTree.Children(1).Children, 1)
delete(app.ResultTree.Children(1).Children(1));
end
delete(app.ResultTree.Children(1))
end
% add new nodes
if app.nesting_by_method
if app.net_input_struct.no_permutations
root = app.createNode(app.ResultTree, 'Non-permuted');
for i = 1:size(app.results.network_test_results, 2)
result = app.results.network_test_results{i};
% All our tests have non-permuted data
flags = struct();
flags.show_nonpermuted = true;
app.createNode(root, result.test_display_name, {result, flags});
end
end
if app.net_input_struct.full_connectome
root = app.createNode(app.ResultTree, 'Full connectome');
for i = 1:size(app.results.permutation_network_test_results, 2)
result = app.results.permutation_network_test_results{i};
if ~isequal(result.full_connectome, false)
flags = struct();
flags.show_full_conn = true;
app.createNode(root, result.test_display_name, {result, flags});
end
end
end
if app.net_input_struct.within_network_pair
root = app.createNode(app.ResultTree, 'Within Net-pair');
for i = 1:size(app.results.permutation_network_test_results, 2)
result = app.results.permutation_network_test_results{i};
try
test_allows_within_net_pair = result.allows_within_net_pair;
catch ex
%If this is an old result without this
%property, default to show within net pair results
test_allows_within_net_pair = true;
end
if ~isequal(result.within_network_pair, false) && test_allows_within_net_pair
flags = struct();
flags.show_within_net_pair = true;
app.createNode(root, result.test_display_name, {result, flags});
end
end
end
else
for i = 1:size(app.results.network_test_results, 2)
root = app.createNode(app.ResultTree, app.results.network_test_results{i}.test_display_name);
result = app.results.network_test_results{i};
if app.net_input_struct.no_permutations
flags = struct();
flags.show_nonpermuted = true;
app.createNode(root, 'Non-permuted', {result, flags});
end
if app.net_input_struct.full_connectome && ~isequal(result.full_connectome, false)
perm_result = app.results.permutation_network_test_results{i};
if app.net_input_struct.full_connectome && ~isequal(result.full_connectome, false)
flags = struct();
flags.show_full_conn = true;
app.createNode(root, 'Full connectome', {perm_result, flags});
end
if app.net_input_struct.within_network_pair && ~isequal(result.within_network_pair, false)
flags = struct();
flags.show_within_net_pair = true;
app.createNode(root, 'Within Net-pair', {perm_result, flags});
end
end
end
end
end
function updateProgPermStats(app, ~)
if ~islogical(app.prog_bar)
app.cur_iter = app.cur_iter + 1;
if app.cur_iter < app.net_input_struct.perm_count
app.prog_bar.Message = sprintf('Running edge-level statistics (%d/%d permutations)', mod(app.cur_iter, app.net_input_struct.perm_count), app.net_input_struct.perm_count);
else
app.prog_bar.Message = sprintf('Running net-level statistics (%d/%d permutations)', mod(app.cur_iter, app.net_input_struct.perm_count), app.net_input_struct.perm_count);
end
app.prog_bar.Value = mod(app.cur_iter, app.net_input_struct.perm_count) ./ app.net_input_struct.perm_count;
if app.prog_bar.CancelRequested
pool = gcp('nocreate');
delete(pool);
close(app.prog_bar);
end
end
end
function initFromInputs(app, test_pool, input_struct, net_input_struct, ~)
import nla.* % required due to matlab package system quirks
app.ViewEdgeLevelButton.Enable = false;
app.RunButton.Enable = false;
if numel(test_pool.net_tests) == 0
app.RunButton.Visible = false;
end
app.SaveButton.Enable = false;
enableNetButtons(app, false);
branchLabel(app, helpers.git.commitString(), helpers.git.commitString());
app.EdgeLevelLabel.Text = test_pool.edge_test.name;
prog = uiprogressdlg(app.UIFigure, 'Title', 'Running edge-level statistic', 'Message', sprintf('Running %s (non-permuted)', test_pool.edge_test.name), 'Indeterminate', true);
drawnow;
app.edge_result = test_pool.runEdgeTest(input_struct);
if app.edgeResultIsMultiContrast(app.edge_result)
app.multi_contrast_edge_result = app.edge_result;
app.initializeContrastSelectorFromResult(app.multi_contrast_edge_result);
%set edge result to the one corresponding to the first
%contrast
all_contrast_names = app.multi_contrast_edge_result.contrastsAsStrings();
app.edge_result = app.multi_contrast_edge_result.getNamedResult(all_contrast_names{1});
end
app.input_struct = input_struct;
app.net_input_struct = net_input_struct;
app.test_pool = test_pool;
app.ViewEdgeLevelButton.Enable = true;
app.SaveButton.Enable = true;
app.RunButton.Enable = true;
close(prog);
end
function initFromResult(app, result, file_name, ~, old_data)
import nla.* % required due to matlab package system quirks
app.UIFigure.Name = sprintf('%s - NLA Result', file_name);
if (isstruct(result) && ~isfield(result, "commit_short")) || ~isprop(result, "commit_short")
commit_short = "";
else
commit_short = result.commit_short();
end
branchLabel(app, helpers.git.commitString(), commit_short);
if isprop(result, "edge_test_results") % We're basically checking for NetworkTestResult object or older here
app.EdgeLevelLabel.Text = result.edge_test_results.name;
app.input_struct = result.test_options;
app.net_input_struct = result.network_test_options;
app.edge_result = result.edge_test_results;
else
app.EdgeLevelLabel.Text = result.edge_result.name;
app.input_struct = result.input_struct;
app.net_input_struct = result.net_input_struct;
app.edge_result = result.edge_result;
end
if isfield(app.net_input_struct, 'prob_max_original')
app.net_input_struct.prob_max = app.net_input_struct.prob_max_original;
end
if app.edgeResultIsMultiContrast(app.edge_result)
app.multi_contrast_edge_result = app.edge_result;
app.initializeContrastSelectorFromResult(app.multi_contrast_edge_result);
%set edge result to the one corresponding to the first
%contrast
all_contrast_names = app.multi_contrast_edge_result.contrastsAsStrings();
app.edge_result = app.multi_contrast_edge_result.getNamedResult(all_contrast_names{1});
end
app.results = result;
app.old_data = old_data;
app.ViewEdgeLevelButton.Enable = true;
app.SaveButton.Enable = true;
app.RunButton.Enable = false;
app.RunButton.Visible = false;
enableNetButtons(app, ~islogical(result.network_test_results));
drawnow();
if ~islogical(result.network_test_results)
app.setNesting();
else
app.results = false;
end
end
function initializeContrastSelectorFromResult(app, edge_result)
if app.edgeResultIsMultiContrast(edge_result)
app.SelectContrastDropdown.Items = edge_result.contrastsAsStrings();
app.SelectContrastDropdown.Enable = true;
app.SelectContrastDropdown.Value = app.SelectContrastDropdown.Items{1};
app.SelectContrastLabel.Enable = true;
else
app.SelectContrastDropdown.Enable = false;
app.SelectContrastLabel.Enable = false;
app.SelectContrastDropdown.Items = {};
app.SelectContrastDropdown.Value = {};
end
end
function is_multi_contrast = edgeResultIsMultiContrast(app, edge_result)
if isa(edge_result, 'nla.edge.result.MultiContrast')
is_multi_contrast = true;
else
is_multi_contrast = false;
end
end
function is_multi_contrast = resultPoolIsMultiContrast(app, result_pool)
if isa(result_pool, 'nla.MultiContrastResult')
is_multi_contrast = true;
else
is_multi_contrast = false;
end
end
function enableNetButtons(app, val)
% buttons that need net-level data to be used
net_buttons = {app.ResultTree, app.FlipNestingButton, app.SaveSummaryTableMenu};
for i = 1:numel(net_buttons)
net_buttons{i}.Enable = val;
end
net_inputs_enabled = val;
if ~isfield(app.net_input_struct, 'behavior_count') || ~isfield(app.net_input_struct, 'prob_max')
net_inputs_enabled = false;
end
end
function displayManyPlots(app, extra_flags, plot_type)
import nla.* % required due to matlab package system quirks
prog = uiprogressdlg(app.UIFigure, 'Title', sprintf('Generating %s', plot_type), 'Message', sprintf('Generating %s', plot_type));
prog.Value = 0.02;
drawnow;
selected_nodes = app.ResultTree.SelectedNodes;
for i = 1:size(selected_nodes, 1)
if ~isempty(selected_nodes(i).NodeData)
result = selected_nodes(i).NodeData{1};
node_flags = selected_nodes(i).NodeData{2};
prog.Message = sprintf('Generating %s %s', result.test_display_name, plot_type);
% result.output(app.input_struct, app.net_input_struct, app.input_struct.net_atlas, app.edge_result, helpers.mergeStruct(node_flags, extra_flags));
nla.net.result.plot.NetworkTestPlotApp(result, app.edge_result, node_flags, app.input_struct, app.net_input_struct, app.old_data)
prog.Value = i / size(selected_nodes, 1);
end
end
close(prog);
end
function branchLabel(app, gui, result)
app.BranchLabel.Text = sprintf('gui | %s\nresult | %s', gui, result);
end
end
% Callbacks that handle component events
methods (Access = private)
% Code that executes after component creation
function startupFcn(app, test_pool, input_struct, net_input_struct, old_data)
import nla.* % required due to matlab package system quirks
app.UIFigure.Name = 'NLA Result';
app.UIFigure.Icon = [findRootPath() 'thumb.png'];
if isa(test_pool, 'nla.ResultPool')
initFromResult(app, test_pool, input_struct, net_input_struct, old_data);
else
initFromInputs(app, test_pool, input_struct, net_input_struct, false);
end
end
% Button pushed function: RunButton
function RunButtonPushed(app, event)
import nla.* % required due to matlab package system quirks
prog = uiprogressdlg(app.UIFigure, 'Title', 'Running statistics', 'Message', 'Running net-level statistics', 'Cancelable', 'on');
prog.Value = 0.02;
drawnow;
if app.multi_contrast_edge_result == false
edge_result = app.edge_result;
else
%If multiple contrast result exists, we'll
%run all of them, rather than just the currently selected
%one
edge_result = app.multi_contrast_edge_result;
end
net_results = app.test_pool.runNetTests(app.net_input_struct, edge_result, app.input_struct.net_atlas, false);
if app.net_input_struct.full_connectome
prog.Message = 'Starting parallel pool...';
prog.Value = 0.05;
gcp;
prog.Message = sprintf('Running net-level statistics (0/%d permutations)', app.net_input_struct.perm_count);
prog.Value = 0;
% Set handle reference
app.prog_bar = prog;
app.cur_iter = 0;
% Data queue to output iteration # from parallel pool
data_queue = parallel.pool.DataQueue;
afterEach(data_queue, @app.updateProgPermStats);
% Run permuted statistics
app.test_pool.data_queue = data_queue;
resultPool = app.test_pool.runPerm(app.input_struct, app.net_input_struct, app.input_struct.net_atlas, edge_result, net_results, app.net_input_struct.perm_count);
if ~app.resultPoolIsMultiContrast(resultPool)
app.results = resultPool;
else
app.multi_contrast_net_result = resultPool;
contrastName = app.SelectContrastDropdown.Value;
app.results = app.multi_contrast_net_result.getNamedResult(contrastName);
end
% Delete the data queue
delete(data_queue);
% Unset handle reference
app.prog_bar = false;
else
app.results = ResultPool(app.input_struct, app.net_input_struct, app.input_struct.net_atlas, edge_result, net_results, false, false);
end
prog.Value = 0.98;
app.RunButton.Enable = false;
app.RunButton.Visible = false;
enableNetButtons(app, true);
drawnow();
app.setNesting();
close(prog);
end
% Menu selected function: SaveButton
function SaveButtonPushed(app, event)
import nla.* % required due to matlab package system quirks
if islogical(app.results)
% save just edge-level results
result = ResultPool(app.input_struct, app.net_input_struct, app.input_struct.net_atlas, app.edge_result, false, false, false);
else
result = app.results;
result.test_options = app.input_struct;
result.network_test_options = app.net_input_struct;
result.edge_test_results = app.edge_result;
end
[file, path] = uiputfile({'*.mat', 'Result (*.mat)'}, 'Save Result File', 'result.mat');
if file ~= 0
prog = uiprogressdlg(app.UIFigure, 'Title', 'Saving results', 'Message', sprintf('Saving to %s', file), 'Indeterminate', true);
drawnow;
result.to_file([path file]);
app.UIFigure.Name = sprintf('%s - NLA Result', file);
close(prog);
end
end
% Button pushed function: FlipNestingButton
function FlipNestingButtonPushed(app, event)
app.nesting_by_method = ~app.nesting_by_method;
app.setNesting()
end
% Button pushed function: ViewEdgeLevelButton
function ViewEdgeLevelButtonPushed(app, event)
import nla.* % required due to matlab package system quirks
prog = uiprogressdlg(app.UIFigure, 'Title', 'Generating figures', 'Message', sprintf('Generating %s figures', app.edge_result.name), 'Indeterminate', true);
drawnow;
flags = struct();
flags.display_sig = true;
app.edge_result.output(app.input_struct.net_atlas, flags)
close(prog);
if ispc
nla.gfx.moveFigToParentUILocation(gcf, app.UIFigure);
end
end
% Button pushed function: OpenTriMatrixPlotButton
function OpenTriMatrixPlotButtonPushed(app, event)
displayManyPlots(app, struct('plot_type', nla.PlotType.FIGURE), 'figures');
end
% Button pushed function: OpenDiagnosticPlotsButton
function OpenDiagnosticPlotsButtonPushed(app, event)
prog = uiprogressdlg(app.UIFigure, 'Title', sprintf('Generating Diagnostic Plots'), 'Message', sprintf('Generating Diagnostic Plots'));
prog.Value = 0.02;
drawnow;
selected_nodes = app.ResultTree.SelectedNodes;
for i = 1:size(selected_nodes, 1)
if ~isempty(selected_nodes(i).NodeData)
result = selected_nodes(i).NodeData{1};
node_flags = selected_nodes(i).NodeData{2};
result.runDiagnosticPlots(app.input_struct, app.net_input_struct, app.edge_result, app.input_struct.net_atlas, node_flags);
if ispc
nla.gfx.moveFigToParentUILocation(gcf, app.UIFigure);
end
prog.Value = i / size(selected_nodes, 1);
end
end
close(prog)
end
% Callback function
function PValModeDropDownValueChanged(app, event)
import nla.* % required due to matlab package system quirks
value = app.NetlevelplottingDropDown.Value;
if strcmp(value, 'linear')
% Plot p-values on linear scale
app.net_input_struct.prob_plot_method = gfx.ProbPlotMethod.DEFAULT;
elseif strcmp(value, 'p-value log')
% Plot p-values on logarithmic scale
app.net_input_struct.prob_plot_method = gfx.ProbPlotMethod.LOG;
elseif strcmp(value, 'p-value -log')
% Plot p-values on negative logarithmic scale
app.net_input_struct.prob_plot_method = gfx.ProbPlotMethod.NEG_LOG_10;
else
app.net_input_struct.prob_plot_method = gfx.ProbPlotMethod.STATISTIC;
end
end
% Callback function
function DisplayConvergenceButtonPushed(app, event)
import nla.* % required due to matlab package system quirks
prog = uiprogressdlg(app.UIFigure, 'Title', sprintf('Generating convergence map'), 'Message', 'Generating net-level convergence map');
prog.Value = 0.02;
drawnow;
num_tests = 0;
sig_count_mat = TriMatrix(app.input_struct.net_atlas.numNets(), 'double', TriMatrixDiag.KEEP_DIAGONAL);
names = [];
selected_nodes = app.ResultTree.SelectedNodes;
for i = 1:size(selected_nodes, 1)
if ~isempty(selected_nodes(i).NodeData)
result = selected_nodes(i).NodeData{1};
flags = selected_nodes(i).NodeData{2};
[num_tests_part, sig_count_mat_part, names_part] = result.getSigMat(app.net_input_struct, app.input_struct.net_atlas, flags);
num_tests = num_tests + num_tests_part;
sig_count_mat.v = sig_count_mat.v + sig_count_mat_part.v;
names = [names names_part];
prog.Value = i / size(selected_nodes, 1);
end
end
color_map_idx = app.ColormapDropDown.Value;
if color_map_idx == 1
color_map = flip(bone());
elseif color_map_idx == 2
color_map = [[1,1,1]; flip(winter())];
elseif color_map_idx == 3
color_map = [[1,1,1]; flip(autumn())];
elseif color_map_idx == 4
color_map = [[1,1,1]; flip(copper())];
end
gfx.drawConvergenceMap(app.input_struct, app.net_input_struct, app.input_struct.net_atlas, sig_count_mat, num_tests, names, app.edge_result, color_map);
close(prog);
if ispc
nla.gfx.moveFigToParentUILocation(gcf, app.UIFigure);
end
%These mlapp files are really just the worst
end
% Callback function
function DisplayChordNetButtonPushed(app, event)
import nla.* % required due to matlab package system quirks
displayManyPlots(app, struct('plot_type', PlotType.CHORD), 'chord plots');
end
% Callback function
function DisplayChordEdgeButtonPushed(app, event)
import nla.* % required due to matlab package system quirks
displayManyPlots(app, struct('plot_type', PlotType.CHORD_EDGE), 'chord plots');
end
% Menu selected function: SaveSummaryTableMenu
function SaveSummaryTableButtonPushed(app, event)
import nla.* % required due to matlab package system quirks
[file, path] = uiputfile({'*.txt', 'Summary Table (*.txt)'}, 'Save Summary Table', 'result.txt');
if file ~= 0
prog = uiprogressdlg(app.UIFigure, 'Title', 'Saving summary table', 'Message', sprintf('Saving to %s', file), 'Indeterminate', true);
drawnow;
app.results.saveSummaryTable([path file]);
close(prog);
end
end
% Callback function
function EdgeLevelTypeDropDownValueChanged(app, event)
import nla.* % required due to matlab package system quirks
value = app.EdgeLevelTypeDropDown.Value;
if strcmp(value, 'prob')
app.net_input_struct.edge_chord_plot_method = gfx.EdgeChordPlotMethod.PROB;
elseif strcmp(value, 'coeff')
app.net_input_struct.edge_chord_plot_method = gfx.EdgeChordPlotMethod.COEFF;
elseif strcmp(value, 'coeff (split)')
app.net_input_struct.edge_chord_plot_method = gfx.EdgeChordPlotMethod.COEFF_SPLIT;
elseif strcmp(value, 'coeff (basic)')
app.net_input_struct.edge_chord_plot_method = gfx.EdgeChordPlotMethod.COEFF_BASE;
else
app.net_input_struct.edge_chord_plot_method = gfx.EdgeChordPlotMethod.COEFF_BASE_SPLIT;
end
end
% Callback function
function FDRCorrectionValueChanged(app, event)
import nla.* % required due to matlab package system quirks
value = app.FDRCorrection.Value;
if strcmp(value, 'Benjamini-Hochberg')
app.net_input_struct.fdr_correction = net.mcc.BenjaminiHochberg();
elseif strcmp(value, 'Benjamini-Yekutieli')
app.net_input_struct.fdr_correction = net.mcc.BenjaminiYekutieli();
else
app.net_input_struct.fdr_correction = net.mcc.Bonferroni();
end
end
% Callback function
function showROIcentroidsinbrainplotsCheckBoxValueChanged(app, event)
include_centroids = app.showROIcentroidsinbrainplotsCheckBox.Value;
app.net_input_struct.show_ROI_centroids = include_centroids;
end
% Callback function
function CohensDthresholdchordplotsCheckBoxValueChanged(app, event)
d_thresh = app.CohensDthresholdchordplotsCheckBox.Value;
app.net_input_struct.d_thresh_chord_plot = d_thresh;
end
% Value changed function: SelectContrastDropdown
function SelectContrastDropdownValueChanged(app, event)
app.selected_contrast_name = app.SelectContrastDropdown.Value;
app.edge_result = app.multi_contrast_edge_result.getNamedResult(app.selected_contrast_name);
if app.resultPoolIsMultiContrast(app.multi_contrast_net_result)
app.results = app.multi_contrast_net_result.getNamedResult(app.selected_contrast_name);
app.setNesting();
end
end
end
% Component initialization
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Create UIFigure and hide until all components are created
app.UIFigure = uifigure('Visible', 'off');
app.UIFigure.Position = [100 100 435 659];
app.UIFigure.Name = 'MATLAB App';
app.UIFigure.Resize = 'off';
% Create FileMenu
app.FileMenu = uimenu(app.UIFigure);
app.FileMenu.Text = 'File';
% Create SaveButton
app.SaveButton = uimenu(app.FileMenu);
app.SaveButton.MenuSelectedFcn = createCallbackFcn(app, @SaveButtonPushed, true);
app.SaveButton.Accelerator = 's';
app.SaveButton.Text = 'Save';
% Create SaveSummaryTableMenu
app.SaveSummaryTableMenu = uimenu(app.FileMenu);
app.SaveSummaryTableMenu.MenuSelectedFcn = createCallbackFcn(app, @SaveSummaryTableButtonPushed, true);
app.SaveSummaryTableMenu.Text = 'Save Summary Table';
% Create ResultTree
app.ResultTree = uitree(app.UIFigure);
app.ResultTree.Multiselect = 'on';
app.ResultTree.Position = [9 90 418 482];
% Create FlipNestingButton
app.FlipNestingButton = uibutton(app.UIFigure, 'push');
app.FlipNestingButton.ButtonPushedFcn = createCallbackFcn(app, @FlipNestingButtonPushed, true);
app.FlipNestingButton.Position = [345 577 81 22];
app.FlipNestingButton.Text = 'Flip nesting';
% Create EdgeLevelLabel
app.EdgeLevelLabel = uilabel(app.UIFigure);
app.EdgeLevelLabel.Position = [9 633 275 22];
app.EdgeLevelLabel.Text = 'Edge-level statistic';
% Create ViewEdgeLevelButton
app.ViewEdgeLevelButton = uibutton(app.UIFigure, 'push');
app.ViewEdgeLevelButton.ButtonPushedFcn = createCallbackFcn(app, @ViewEdgeLevelButtonPushed, true);
app.ViewEdgeLevelButton.Position = [9 610 47 22];
app.ViewEdgeLevelButton.Text = 'View';
% Create NetLevelLabel
app.NetLevelLabel = uilabel(app.UIFigure);
app.NetLevelLabel.Position = [9 573 302 22];
app.NetLevelLabel.Text = 'Network-level statistics (Ctrl or Shift+click for multiple)';
% Create RunButton
app.RunButton = uibutton(app.UIFigure, 'push');
app.RunButton.ButtonPushedFcn = createCallbackFcn(app, @RunButtonPushed, true);
app.RunButton.Position = [18 523 49 40];
app.RunButton.Text = 'Run';
% Create BranchLabel
app.BranchLabel = uilabel(app.UIFigure);
app.BranchLabel.HorizontalAlignment = 'right';
app.BranchLabel.VerticalAlignment = 'top';
app.BranchLabel.FontColor = [0.8 0.8 0.8];
app.BranchLabel.Position = [1 41 418 29];
app.BranchLabel.Text = {'gui | unknown_branch:0000000'; 'result produced by | unknown_branch:0000000'};
% Create OpenTriMatrixPlotButton
app.OpenTriMatrixPlotButton = uibutton(app.UIFigure, 'push');
app.OpenTriMatrixPlotButton.ButtonPushedFcn = createCallbackFcn(app, @OpenTriMatrixPlotButtonPushed, true);
app.OpenTriMatrixPlotButton.Position = [11 58 146 22];
app.OpenTriMatrixPlotButton.Text = 'Open TriMatrix Plot';
% Create OpenDiagnosticPlotsButton
app.OpenDiagnosticPlotsButton = uibutton(app.UIFigure, 'push');
app.OpenDiagnosticPlotsButton.ButtonPushedFcn = createCallbackFcn(app, @OpenDiagnosticPlotsButtonPushed, true);
app.OpenDiagnosticPlotsButton.Position = [11 28 147 22];
app.OpenDiagnosticPlotsButton.Text = 'Open Diagnostic Plots';
% Create SelectContrastLabel
app.SelectContrastLabel = uilabel(app.UIFigure);
app.SelectContrastLabel.Enable = 'off';
app.SelectContrastLabel.Position = [143 633 152 22];
app.SelectContrastLabel.Text = 'Select Contrast';
% Create SelectContrastDropdown
app.SelectContrastDropdown = uidropdown(app.UIFigure);
app.SelectContrastDropdown.Items = {};
app.SelectContrastDropdown.ValueChangedFcn = createCallbackFcn(app, @SelectContrastDropdownValueChanged, true);
app.SelectContrastDropdown.Enable = 'off';
app.SelectContrastDropdown.Position = [141 610 154 22];
app.SelectContrastDropdown.Value = {};
% Show the figure after all components are created
app.UIFigure.Visible = 'on';
end
end
% App creation and deletion
methods (Access = public)
% Construct app
function app = NLAResult(varargin)
% Create UIFigure and components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.UIFigure)
% Execute the startup function
runStartupFcn(app, @(app)startupFcn(app, varargin{:}))
if nargout == 0
clear app
end
end
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.UIFigure)
end
end
end