Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
82381a5
[NET-214] Error plotting Chi-squared and Hypergeometric within networ…
pollaro Aug 28, 2024
8f66140
Tried to clean up and organize better. Still messy
pollaro Feb 19, 2024
5d875fb
Added error check to ensure both limit values are input and not none …
pollaro Feb 20, 2024
2b8ea95
added caption to colorbar for trimatrix plots
pollaro Mar 7, 2024
47ec414
Starting repository for quick-fix network test refactor over since I …
pollaro Jan 9, 2024
70aa0cb
Added new tests for Network Tests
pollaro Jan 9, 2024
0a6851f
Added result class for new network tests and fixed some of the test c…
pollaro Jan 9, 2024
7bd1ae0
add unit tests for new test classes
pollaro Jan 9, 2024
d49c2db
lots of edits to NetworkTestResult for methods. I don't think its goi…
pollaro Jan 9, 2024
1163669
remove a class i made to test a few things
pollaro Jan 9, 2024
0ffe91c
fixed NetworkTestResult to account for different test methods
pollaro Jan 10, 2024
8ae1c9b
did a better job with NetworkTestResult and tests. now its ready to i…
pollaro Jan 10, 2024
2afd6c5
start fixing up testpool and result rank.
pollaro Jan 10, 2024
c0abc49
added unit tests for NetworkTestResult
pollaro Jan 11, 2024
6f67842
this seems way too easy.
pollaro Jan 11, 2024
847225a
copied lots of files needed for permutations and test/result running.…
pollaro Jan 12, 2024
ee6b4a2
lots of work on network test results and the result app front to get …
pollaro Jan 17, 2024
342d299
first batch of plotting tools made. not very pleased, but what can yo…
pollaro Jan 19, 2024
87dd320
bug squash to get no permutations to display figures
pollaro Jan 22, 2024
63fa66b
got most of the interfaces and even some of the plotting done. switch…
pollaro Jan 26, 2024
4dea458
within net pair plotting
pollaro Jan 30, 2024
f0f3648
fix some code to be more concise
pollaro Jan 30, 2024
c3a03dd
added edge tests back that were lost
pollaro Feb 5, 2024
6757505
rewrite network tests tests
pollaro Feb 6, 2024
ba03798
Added some unit tests and fixed a few errors
pollaro Feb 7, 2024
c1b1a09
added a test for result rank
pollaro Feb 8, 2024
e54e34e
Added MatrixPlot in
pollaro Feb 13, 2024
d39ad9a
just a few cleanups
pollaro Feb 8, 2024
543d890
cleaned up some code and bug fixes
pollaro Feb 14, 2024
2d77387
network level chords working
pollaro Feb 27, 2024
d4da735
remove two unneeded files
pollaro Feb 27, 2024
9d805db
Attempting to get edge chord plotting working
pollaro Feb 28, 2024
6059b31
chordplot used in all chord plotting instead of old function
pollaro Feb 28, 2024
2851699
integrate chordplot class into net refactor
pollaro Mar 1, 2024
4a97698
touch up on formatting
pollaro Mar 1, 2024
1fbde70
[NET-148] Statistical Rank of refactored Network Test Results (#7)
pollaro Apr 11, 2024
4f9f6f9
[NET-59] Better scaling options for TriMatrix plots (#9)
pollaro Apr 16, 2024
3cd87f1
[NET-157] Enable colormap choice for TriMatrix (#10)
pollaro Apr 16, 2024
1880b6c
[NET-159] Unit testing framework (#8)
pollaro Apr 19, 2024
aaac01e
[NET-161] remove "Import nla.*" (#16)
pollaro Apr 25, 2024
c36a6f5
Development merging in master (#30)
pollaro Jun 4, 2024
b9ba17e
Revert "Development merging in master" (#34)
pollaro Jun 7, 2024
4d7e961
Merge master into development and rebase (#37)
pollaro Jun 11, 2024
6af486a
[NET-192] Diagnostic Plot Fix (#33)
pollaro Jun 11, 2024
fbb2487
[NET-193] New Rankings...and other junk? (#39)
pollaro Jun 26, 2024
ccd1ac3
[NET-196] Fix Cohen's D (#44)
pollaro Jul 8, 2024
cf2c195
[NET-197] Fix math in winkler (#46)
pollaro Jul 9, 2024
fe446bd
[NET-142] Paired-T Edge Test (#48)
pollaro Jul 11, 2024
94d5793
[NET-203] Network Test selection for figures fix (#52)
pollaro Jul 25, 2024
5ccc2c4
Exported mlapp files
actions-user Aug 20, 2024
35d7759
Exported mlapp files
actions-user Aug 29, 2024
d345dc7
remove unneeded file
pollaro Aug 29, 2024
a68d78f
add back deleted variables
pollaro Aug 29, 2024
19222f8
Merge branch 'dev_master_sync' of https://github.com/WheelockLab/Netw…
pollaro Aug 29, 2024
7e49381
remove unneeded file
pollaro Aug 29, 2024
5c6a0d2
remove 3 unneeded files
pollaro Aug 29, 2024
e702779
fix file mismatch
pollaro Aug 29, 2024
d83d268
remove unneeded lines
pollaro Aug 29, 2024
66034da
remove extra end
pollaro Aug 29, 2024
67e1a35
remove comment
pollaro Aug 29, 2024
3c6f915
remove duplicate code added from rebase
pollaro Aug 29, 2024
f6ccae8
remove old code
pollaro Aug 29, 2024
a71e62d
remove unneeded line
pollaro Aug 29, 2024
e5103af
fix testpool
pollaro Aug 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions +nla/+edge/+result/Base.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ function output(obj, net_atlas, flags, prob_label)
if ~isfield(flags, 'display_sig')
flags.display_sig = true;
end

if flags.display_sig
if ~exist('prob_label', 'var')
prob_label = [sprintf('Edge-level Significance (P < %g)', obj.prob_max), prob_label_appended];
Expand Down
35 changes: 35 additions & 0 deletions +nla/+edge/unittests/EdgeResultsTest.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
classdef EdgeResultsTest < matlab.unittest.TestCase
properties
variables
end

methods (TestClassSetup)
end

methods (TestClassTeardown)
function clearTestData(testCase)
clear
end
end

methods (Test)
function precalculatedInitTest(testCase)
import nla.edge.result.Precalculated
result = Precalculated();
testCase.verifyEqual(result.coeff.size, uint32(2));
testCase.verifyEqual(result.prob_max, -1);
end

function welchTInitTest(testCase)
import nla.edge.result.WelchT
result = WelchT();
testCase.verifyEqual(result.prob_max, -1);

result = WelchT(15, 1, {'group_1', 'group_2'});
testCase.verifyEqual(result.coeff.size, uint32(15));
testCase.verifyEqual(result.dof, nla.TriMatrix(15));
testCase.verifyEqual(result.behavior_name, "group_1 > group_2");
testCase.verifyEqual(result.coeff_range, [-3 3]);
end
end
end
31 changes: 31 additions & 0 deletions +nla/+edge/unittests/PermutationMethodsTest.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
classdef PermutationMethodsTest < matlab.unittest.TestCase
properties
variables
end

methods (TestClassSetup)
function loadTestData(testCase)
testCase.variables = load("edgeTestInputStruct.mat");
end
end

methods (TestClassTeardown)
function clearTestData(testCase)
clear
end
end

methods (Test)
function behaviorVecTest(testCase)
permutation_method = nla.edge.permutationMethods.BehaviorVec();
permuted_input_struct = permutation_method.permute(testCase.variables.input_struct);

testCase.verifyNotEqual(testCase.variables.input_struct.behavior, permuted_input_struct.behavior);

[counts, original_values] = groupcounts(testCase.variables.input_struct.behavior);
[permuted_counts, permuted_values] = groupcounts(permuted_input_struct.behavior);
testCase.verifyEqual(counts, permuted_counts);
testCase.verifyEqual(original_values, permuted_values);
end
end
end
139 changes: 139 additions & 0 deletions +nla/+gfx/unittest/ChordPlotTest.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
classdef ChordPlotTest < matlab.unittest.TestCase
properties
network_atlas
edge_test_options
chord_plot
plot_axes
axis_width
plot_matrix
direction
color_map
chord_type
upper_limit
lower_limit
z_order
end

methods (TestClassSetup)
function loadTestData(testCase)
import nla.TriMatrix
import nla.gfx.chord.ChordPlot

root_path = nla.findRootPath();

% Load up a network atlas
network_atlas_path = strcat(root_path, fullfile('support_files',...
'Wheelock_2020_CerebralCortex_15nets_288ROI_on_MNI.mat'));
testCase.network_atlas = nla.NetworkAtlas(network_atlas_path);

precalculated_path = strcat(root_path, fullfile('examples', 'precalculated/'));
observed_p_file = load(strcat(precalculated_path, 'SIM_obs_p.mat'));
testCase.edge_test_options.precalc_obs_p = TriMatrix(testCase.network_atlas.numROIs);
testCase.edge_test_options.precalc_obs_p.v = observed_p_file.SIM_obs_p;

testCase.plot_axes = axes();
testCase.axis_width = 500;
testCase.plot_matrix = testCase.edge_test_options.precalc_obs_p;
testCase.direction = nla.gfx.SigType.INCREASING;
testCase.color_map = parula(256);
testCase.chord_type = nla.PlotType.CHORD_EDGE;
testCase.upper_limit = 1;
testCase.lower_limit = 0;
testCase.z_order = true;

testCase.chord_plot = ChordPlot(testCase.network_atlas, testCase.plot_axes, testCase.axis_width,...
testCase.plot_matrix, 'direction', testCase.direction, 'color_map', testCase.color_map,...
'chord_type', testCase.chord_type, 'upper_limit', testCase.upper_limit, 'lower_limit', testCase.lower_limit,...
'random_z_order', testCase.z_order);
end
end

methods (TestClassTeardown)
function clearTestData(testCase)
close all
clear
end
end

methods (Test)
function initailizeChordPlotTest(testCase)

testCase.verifyEqual(testCase.plot_axes, testCase.chord_plot.axes);
testCase.verifyEqual(testCase.axis_width, testCase.chord_plot.axis_width);
testCase.verifyEqual(testCase.plot_matrix, testCase.chord_plot.plot_matrix);
testCase.verifyEqual(testCase.direction, testCase.chord_plot.direction);
testCase.verifyEqual(testCase.color_map, testCase.chord_plot.color_map);
testCase.verifyEqual(testCase.chord_type, testCase.chord_plot.chord_type);
testCase.verifyEqual([testCase.upper_limit testCase.lower_limit],...
[testCase.chord_plot.upper_limit testCase.chord_plot.lower_limit]);
testCase.verifyEqual(testCase.z_order, testCase.chord_plot.random_z_order);
end

function getCircleRadiusTest(testCase)
testCase.verifyEqual(testCase.chord_plot.circle_radius, 200);
end

function getTextRadiusTest(testCase)
testCase.verifyEqual(testCase.chord_plot.text_radius, (...
testCase.chord_plot.circle_radius + (testCase.chord_plot.text_width / 4)));
end

function getSpaceBetweenNetworksAndLabelsTest(testCase)
testCase.verifyEqual(testCase.chord_plot.space_between_networks_and_labels, 6);
testCase.chord_plot.chord_type = nla.PlotType.CHORD;
testCase.verifyEqual(testCase.chord_plot.space_between_networks_and_labels, 3);
end

function getSpaceBetweenNetworksAndLabelsRadiansTest(testCase)
testCase.verifyEqual(testCase.chord_plot.space_between_networks_radians,...
atan(testCase.chord_plot.space_between_networks / testCase.chord_plot.circle_radius));
end

function getInnerCircleRadiusTest(testCase)
testCase.verifyEqual(testCase.chord_plot.inner_circle_radius,...
testCase.chord_plot.circle_radius - testCase.chord_plot.circle_thickness);
end

function getChordRadiusTest(testCase)
testCase.verifyEqual(testCase.chord_plot.chord_radius,...
testCase.chord_plot.inner_circle_radius - testCase.chord_plot.space_between_networks_and_labels);
end

function getNetworkSizeRadiansTest(testCase)
testCase.verifyEqual(testCase.chord_plot.network_size_radians, (2 * pi / testCase.network_atlas.numNets()));
end

function getNetworkPairSizeRadiansTest(testCase)
expected_value = (testCase.chord_plot.network_size_radians - testCase.chord_plot.space_between_networks_radians) /...
(testCase.network_atlas.numNets() + 1);
testCase.verifyEqual(testCase.chord_plot.network_pair_size_radians, expected_value);
end

function getROISizeRadiansTest(testCase)
expected_value = ((2 * pi) - (testCase.chord_plot.space_between_networks_radians * testCase.network_atlas.numNets())) ./...
testCase.network_atlas.numROIs();
testCase.verifyEqual(testCase.chord_plot.ROI_size_radians, expected_value);
end

function getNumberOfNetworksTest(testCase)
testCase.verifyEqual(testCase.chord_plot.number_of_networks, testCase.network_atlas.numNets());
end

function getNumberOfROIsTest(testCase)
testCase.verifyEqual(testCase.chord_plot.number_of_ROIs, testCase.network_atlas.numROIs());
end

function getNetworkSizeRadiansArrayTest(testCase)
network_size = [];
for network = 1:testCase.network_atlas.numNets()
network_size(network) = testCase.network_atlas.nets(network).numROIs();
end
expected_value = network_size .* testCase.chord_plot.ROI_size_radians + testCase.chord_plot.space_between_networks_radians;
testCase.verifyEqual(testCase.chord_plot.network_size_radians_array, expected_value);
end

function getCumulativeNetworkSizeTest(testCase)
testCase.verifyEqual(testCase.chord_plot.cumulative_network_size, cumsum(testCase.chord_plot.network_size_radians_array));
end
end
end
6 changes: 4 additions & 2 deletions +nla/+net/+result/NetworkResultPlotParameter.m
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,10 @@ function brainFigureButtonCallback(network1, network2)

function statistic = getStatsFromMethodAndName(obj, test_method, plot_statistic)
% combining the method and stat name to get the data. With a fail safe for forgetting 'single_sample'
if test_method == "within_network_pair" && ~startsWith(plot_statistic, "single_sample")
plot_statistic = strcat("single_sample_", plot_statistic);
if isequal(test_method, "within_network_pair")...
&& ~startsWith(plot_statistic, "single_sample")...
&& ~any(ismember(obj.noncorrelation_input_tests, obj.network_test_results.test_name))
plot_statistic = strcat("single_sample_", plot_statistic);
end
statistic = obj.network_test_results.(test_method).(plot_statistic);
end
Expand Down
1 change: 0 additions & 1 deletion +nla/+net/+result/NetworkTestResult.m
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ function fullConnectomePlotting(obj, network_atlas, edge_test_options, edge_test

if flags.plot_type == nla.PlotType.FIGURE


p_value_vs_network_size_parameters = result_plot_parameters.plotProbabilityVsNetworkSize("no_permutations",...
p_value);
full_connectome_p_value_vs_network_size_parameters = result_plot_parameters.plotProbabilityVsNetworkSize(...
Expand Down
2 changes: 1 addition & 1 deletion +nla/+net/ResultRank.m
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
%% Getters for dependent properties
% This takes the above statistic and gets the property to use its size to find the number of permutations
function value = get.permutations(obj)
value = size(obj.permuted_network_results.permutation_results.p_value_permutations.v, 2);
value = size(obj.permuted_network_results.permutation_results.p_value_permutations.v, 2);
end

function value = get.number_of_networks(obj)
Expand Down
129 changes: 129 additions & 0 deletions +nla/unittests/TestPoolTest.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
classdef TestPoolTest < matlab.unittest.TestCase

properties
variables
end

methods (TestClassSetup)
function loadTestData(testCase)
testCase.variables = {};

load(fullfile('nla', 'tests', 'inputStruct'), 'input_struct');
testCase.variables.input_struct = input_struct;
load(fullfile('nla', 'tests', 'edgeResultsPermuted'), 'edge_results_perm');
testCase.variables.edge_results_perm = edge_results_perm;
load(fullfile('nla', 'tests', 'networkInputStruct'), 'net_input_struct');
testCase.variables.net_input_struct = net_input_struct;
load(fullfile('nla', 'tests', 'networkResultsNonPermuted'), 'net_results_nonperm');
testCase.variables.net_results_nonperm = net_results_nonperm;
load(fullfile('nla', 'tests', 'networkResultsPermuted'), 'net_results_perm');
testCase.variables.net_results_perm = net_results_perm;
load(fullfile('nla', 'tests', 'networkAtlas'), 'net_atlas');
testCase.variables.net_atlas = net_atlas;
end
end

methods (TestClassTeardown)
function clearTestData(testCase)
clear testCase.variables
end
end

methods (Test)
function permutationEdgeTest(testCase)
import nla.TestPool

test_pool = TestPool();
permuted_edge_results = test_pool.runEdgeTestPerm(testCase.variables.input_struct, 20, 1);
testCase.verifyEqual(permuted_edge_results, testCase.variables.edge_results_perm);
end

function chiSquaredPermutationTest(testCase)
import nla.TestPool nla.net.test.ChiSquared

test_pool = TestPool();
test_pool.net_tests{1} = ChiSquared();
network_level_results = test_pool.runNetTestsPerm(testCase.variables.net_input_struct, testCase.variables.net_atlas, testCase.variables.edge_results_perm);
nonpermuted_network_results = {};
nonpermuted_network_results{1} = testCase.variables.net_results_nonperm{1};
network_results_ranked = test_pool.rankResults(testCase.variables.input_struct, nonpermuted_network_results, network_level_results, testCase.variables.net_atlas.numNetPairs());
testCase.verifyEqual(network_results_ranked{1}, testCase.variables.net_results_perm{1});
end

function cohenDPermutationTest(testCase)
import nla.TestPool nla.net.test.CohenD

test_pool = TestPool();
test_pool.net_tests{1} = CohenD();
network_level_results = test_pool.runNetTestsPerm(testCase.variables.net_input_struct, testCase.variables.net_atlas, testCase.variables.edge_results_perm);
nonpermuted_network_results = {};
nonpermuted_network_results{1} = testCase.variables.net_results_nonperm{2};
network_results_ranked = test_pool.rankResults(testCase.variables.input_struct, nonpermuted_network_results, network_level_results, testCase.variables.net_atlas.numNetPairs());

% The following line is due to an error in creation of CohenD results. Since this doesn't technically exist, every value is 1/(1+permutations). The permutation result sets them to zero. We set them equal to pass
testCase.variables.net_results_perm{2}.within_np_prob.v = network_results_ranked{1}.within_np_prob.v;

testCase.verifyEqual(network_results_ranked{1}, testCase.variables.net_results_perm{2});
end

function hyperGeoPermutationTest(testCase)
import nla.TestPool nla.net.test.HyperGeo

test_pool = TestPool();
test_pool.net_tests{1} = HyperGeo();
network_level_results = test_pool.runNetTestsPerm(testCase.variables.net_input_struct, testCase.variables.net_atlas, testCase.variables.edge_results_perm);
nonpermuted_network_results = {};
nonpermuted_network_results{1} = testCase.variables.net_results_nonperm{3};
network_results_ranked = test_pool.rankResults(testCase.variables.input_struct, nonpermuted_network_results, network_level_results, testCase.variables.net_atlas.numNetPairs());
testCase.verifyEqual(network_results_ranked{1}, testCase.variables.net_results_perm{3});
end

function kolmogorovSmirnovPermutationTest(testCase)
import nla.TestPool nla.net.test.KolmogorovSmirnov

test_pool = TestPool();
test_pool.net_tests{1} = KolmogorovSmirnov();
network_level_results = test_pool.runNetTestsPerm(testCase.variables.net_input_struct, testCase.variables.net_atlas, testCase.variables.edge_results_perm);
nonpermuted_network_results = {};
nonpermuted_network_results{1} = testCase.variables.net_results_nonperm{4};
network_results_ranked = test_pool.rankResults(testCase.variables.input_struct, nonpermuted_network_results, network_level_results, testCase.variables.net_atlas.numNetPairs());
testCase.verifyEqual(network_results_ranked{1}, testCase.variables.net_results_perm{4});
end

function studentTPermutationTest(testCase)
import nla.TestPool nla.net.test.StudentT

test_pool = TestPool();
test_pool.net_tests{1} = StudentT();
network_level_results = test_pool.runNetTestsPerm(testCase.variables.net_input_struct, testCase.variables.net_atlas, testCase.variables.edge_results_perm);
nonpermuted_network_results = {};
nonpermuted_network_results{1} = testCase.variables.net_results_nonperm{5};
network_results_ranked = test_pool.rankResults(testCase.variables.input_struct, nonpermuted_network_results, network_level_results, testCase.variables.net_atlas.numNetPairs());
testCase.verifyEqual(network_results_ranked{1}, testCase.variables.net_results_perm{5});
end

function welchTPermutationTest(testCase)
import nla.TestPool nla.net.test.WelchT

test_pool = TestPool();
test_pool.net_tests{1} = WelchT();
network_level_results = test_pool.runNetTestsPerm(testCase.variables.net_input_struct, testCase.variables.net_atlas, testCase.variables.edge_results_perm);
nonpermuted_network_results = {};
nonpermuted_network_results{1} = testCase.variables.net_results_nonperm{6};
network_results_ranked = test_pool.rankResults(testCase.variables.input_struct, nonpermuted_network_results, network_level_results, testCase.variables.net_atlas.numNetPairs());
testCase.verifyEqual(network_results_ranked{1}, testCase.variables.net_results_perm{6});
end

function wilcoxonPermutationTest(testCase)
import nla.TestPool nla.net.test.Wilcoxon

test_pool = TestPool();
test_pool.net_tests{1} = Wilcoxon();
network_level_results = test_pool.runNetTestsPerm(testCase.variables.net_input_struct, testCase.variables.net_atlas, testCase.variables.edge_results_perm);
nonpermuted_network_results = {};
nonpermuted_network_results{1} = testCase.variables.net_results_nonperm{7};
network_results_ranked = test_pool.rankResults(testCase.variables.input_struct, nonpermuted_network_results, network_level_results, testCase.variables.net_atlas.numNetPairs());
testCase.verifyEqual(network_results_ranked{1}, testCase.variables.net_results_perm{7});
end
end
end
Binary file added +nla/unittests/edgeResultsNonPermuted.mat
Binary file not shown.
Binary file added +nla/unittests/edgeResultsPermuted.mat
Binary file not shown.
Binary file added +nla/unittests/inputStruct.mat
Binary file not shown.
Binary file added +nla/unittests/networkAtlas.mat
Binary file not shown.
Binary file added +nla/unittests/networkInputStruct.mat
Binary file not shown.
Binary file added +nla/unittests/networkResultsNonPermuted.mat
Binary file not shown.
Binary file added +nla/unittests/networkResultsPermuted.mat
Binary file not shown.