Skip to content

Commit f129416

Browse files
committed
added to network test result doc
1 parent 288c647 commit f129416

3 files changed

Lines changed: 84 additions & 42 deletions

File tree

+nla/+net/+result/NetworkTestResult.m

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,16 @@
11
classdef NetworkTestResult < matlab.mixin.Copyable
2-
%NETWORKTESTRESULT Network Test Results
3-
% This is the super class that all network test results will be in
4-
% When a result is created the three repositories (within_network_pair, full_connectome, no_permutations) are set
5-
% to false. This makes it easier to do an if/else check on them.
6-
% The three private methods create the structures and trimatrices to keep the data.
7-
% Notation:
8-
% Test Methods: The method used for ranking the statistics (within net pair, full connectome, no permutation)
9-
% Statistics: The statistical results from a specific network test (chi-squared, t-tests)
10-
%
11-
% Output object:
12-
% test_name: The name of the network test run (chi_squared, hypergeometric, etc)
13-
% test_options: The options passed in. Method, plotting methods (formerly input_struct)
14-
% within_network_pair: Results from within_network_pair tests
15-
% full_connectome: Results from full_connectome tests
16-
% no_permutations: Results from the no permutation test
17-
% permutation_results: Results from all the permutations of the network tests. These are used in the ranking to create
18-
% the results for the test methods
19-
%
20-
% Within each of the three results structures will be properties containing the tri-matrices. Each test is different,
21-
% but all contain:
22-
% p_value: TriMatrix with p-values
23-
% single_sample_p_value: TriMatrix with the single sample p-value (if available)
2+
% Network level test results
3+
% Class to store all relevant results for a network level test. Each test will create an instance of this to store results
244
%
5+
% :param test_name: The name of the network test run
6+
% :param test_display_name: The name of the network test for display
7+
% :param test_options: Options and inputs for tests to be run (also called input_struct)
8+
% :param ranking_statistic: The statistic to be used in ranking to determine p-value
9+
% :param within_network_pair: Results of the within network pair test. Single sample p-values (except :math:`\chi^2`\ and hypergeometric tests). "legacy_" results use the individual test p-values to rank and determine the final p-value. Multiple ranking strategies available
10+
% :param full_connectome: Results of the full_connectome test. Same format as above.
11+
% :param no_permutations: Results for the non-permuted test. Same format as above.
12+
% :param permutation_results: Results of each permutation. Statistics and p-values. Note: The p-values are for each individual permutation test, not the overall p-value.
13+
2514
properties
2615
test_name = "" % Name of the network test run
2716
test_display_name = "" % Name of the network test for the front-end to display
@@ -43,23 +32,13 @@
4332
end
4433

4534
properties (Constant)
46-
% TODO: replace wtih enums
4735
test_methods = ["no_permutations", "full_connectome", "within_network_pair"]
4836
noncorrelation_input_tests = ["chi_squared", "hypergeometric"] % These are tests that do not use correlation coefficients as inputs
4937
end
5038

5139
methods
5240
function obj = NetworkTestResult(test_options, number_of_networks, test_name, test_display_name,...
5341
test_specific_statistics, ranking_statistic)
54-
%CONSTRUCTOR Used for creating results.
55-
%
56-
% Arguments:
57-
% test_options [Struct]: Options for the test. Formerly 'input_struct'
58-
% number_of_networks [Int]: The number of networks in the data being analyzed
59-
% test_name [String]: The name of the network test being run
60-
% test_specific_statistics [Array[String]]: Test statistics for a test. (Example: t_statistic for a t-Test)
61-
% ranking_statistic [String]: Test statistic that will be used in ranking
62-
6342
import nla.TriMatrix nla.TriMatrixDiag
6443

6544
if nargin == 6
@@ -74,7 +53,15 @@
7453
end
7554
end
7655

56+
% Used for plotting
7757
function output(obj, edge_test_options, updated_test_options, network_atlas, edge_test_result, flags)
58+
% Outputs data to be plotted using nla.net.result.plot.NetworkTestPlot
59+
%
60+
% :param edge_test_options: The test_options used to instantiate the class. Contains the functional connectivity and network atlas among other options
61+
% :param updated_test_options: The network test options. These can also include the options for plotting.
62+
% :param network_atlas: The network atlas
63+
% :param edge_test_result: Results of the edge level test.
64+
% :param flags: More options that are used after the tests have run. One of them is which test method to plot.
7865
import nla.NetworkLevelMethod
7966

8067
if isfield(flags, "show_nonpermuted") && flags.show_nonpermuted
@@ -90,8 +77,12 @@ function output(obj, edge_test_options, updated_test_options, network_atlas, edg
9077
network_result_plot.drawFigure(nla.PlotType.FIGURE)
9178
end
9279

80+
% Use for merging multiple results together into one
9381
function merge(obj, other_objects)
94-
%MERGE Merge two groups of results together. Not guaranteed to be ordered
82+
% Used to merge multiple results together into one
83+
%
84+
% :param other_objects: The other result objects to merge into this result object
85+
9586
if ~iscell(other_objects)
9687
other_objects = {other_objects};
9788
end
@@ -108,7 +99,9 @@ function merge(obj, other_objects)
10899
end
109100

110101
function concatenateResult(obj, other_object)
111-
%CONCATENATERESULT Add a result to the back of a TriMatrix. Used to keep permutation data.
102+
% Concatenate results together. This is used to preserve the individual permutation results.
103+
%
104+
% :param other_object: The object to append to the end of the current result
112105

113106
statistics = fieldnames(obj.permutation_results);
114107
for statistic_index = 1:numel(statistics)
@@ -201,18 +194,21 @@ function runDiagnosticPlots(obj, edge_test_options, updated_test_options, edge_t
201194
end
202195
end
203196

197+
% Convenience method to determine if inputs were correlation coefficients, or "significance" values
204198
function value = get.is_noncorrelation_input(obj)
205-
% Convenience method to determine if inputs were correlation coefficients, or "significance" values
206199
value = any(strcmp(obj.noncorrelation_input_tests, obj.test_name));
207200
end
208201
%%
209202
end
210203

211204
methods (Access = private)
212205
function createResultsStorage(obj, test_options, number_of_networks, test_specific_statistics)
213-
%CREATERESULTSSTORAGE Create the substructures for the methods chosen
206+
% Creates the objects to hold results. Uses statistic names from test objects.
207+
%
208+
% :param test_options: The test options
209+
% :param number_of_networks: The number of networks. Used to determine the size of the TriMatrix result. A property of the Network Atlas
210+
% :param test_specific_statistics: The statistics used in each test. A property of each test.
214211

215-
% create the results containers. This replaces the false boolean with a struct of TriMatrices
216212
for test_method_index = 1:numel(obj.test_methods)
217213
if isequal(obj.(obj.test_methods(test_method_index)), false) &&...
218214
isequal(test_options.(obj.test_methods(test_method_index)), true)
@@ -225,7 +221,6 @@ function createResultsStorage(obj, test_options, number_of_networks, test_specif
225221
end
226222

227223
function createTestSpecificResultsStorage(obj, number_of_networks, test_specific_statistics)
228-
%CREATETESTSPECIFICRESULTSSTORAGE Create the substructures for the specific statistical tests
229224
import nla.TriMatrix nla.TriMatrixDiag
230225

231226
for statistic_index = 1:numel(test_specific_statistics)
@@ -237,7 +232,6 @@ function createTestSpecificResultsStorage(obj, number_of_networks, test_specific
237232
end
238233

239234
function createPValueTriMatrices(obj, number_of_networks, test_method)
240-
%CREATEPVALUETRIMATRICES Creates the p-value substructure for the test method
241235
import nla.TriMatrix nla.TriMatrixDiag
242236

243237
non_correlation_test = any(strcmp(obj.test_name, obj.noncorrelation_input_tests));
@@ -306,9 +300,10 @@ function createPValueTriMatrices(obj, number_of_networks, test_method)
306300

307301
methods (Static)
308302
function options = editableOptions()
309-
% options that can be edited post-run (ie: are simple
310-
% thresholds etc. for summary statistics, or generally can be
311-
% modified without requiring re-permutation)
303+
% Static method to return options that can be adjusted afterwards.
304+
%
305+
% :return: Options. Defaults to behavior_count, prob_max (The threshold for p-values), d_max (The threshold for Cohen's D values)
306+
312307
import nla.inputField.Integer nla.inputField.Number
313308
options = {...
314309
Integer('behavior_count', 'Test count:', 1, 1, Inf),...
@@ -318,6 +313,12 @@ function createPValueTriMatrices(obj, number_of_networks, test_method)
318313
end
319314

320315
function probability = getPValueNames(test_method, test_name)
316+
% Static method to determine prefixes of p-values for test results
317+
%
318+
% :param test_method: No permutations, full connectome, or within network pair
319+
% :param test_name: The name of the test run
320+
% :return: The full name of the p-value. (example: "single_sammple_p_value")
321+
321322
import nla.NetworkLevelMethod
322323
noncorrelation_input_tests = ["chi_squared", "hypergeometric"];
323324
non_correlation_test = any(strcmp(test_name, noncorrelation_input_tests));

docs/source/network_level_tests.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,30 @@ To create a network-level test, a test class must be added to the codebase. Refe
8585

8686
Network Level results
8787
---------------------------------------
88+
.. mat:module:: .
8889
90+
All network level tests use ``nla.net.NetworkTestResult`` as the result object. This object uses the properties of the test
91+
to name the results.
8992

93+
.. mat:autoclass:: NetworkTestResult
94+
95+
.. mat:automethod:: merge
96+
97+
.. mat:automethod:: concatenateResult
98+
99+
.. mat:automethod:: output
100+
101+
.. mat:automethod:: createResultsStorage
102+
103+
.. mat:automethod:: editableOptions
104+
105+
.. mat:automethod:: getPValueNames
106+
107+
The three test methods (no_permutations, full_connectome, within_network_pair) will each contain multiple TriMatrices (lower half of a square matrix) of results.::
108+
109+
:d: This is the results of a Cohen's D test (effects size) using the results of the test method
110+
:uncorrected_<single/two>_sample_p_value: The uncorrected p-value found by ranking the observed (non-permuted) result versus the
111+
test results of all the permutations.
112+
:legacy_<single/two>_sample_p_value: The p-value found using the individual test p-values. Not verified for correctness.
113+
:westfall_<single/two>_sample_p_value: The uncorrected p-value corrected for family-wise error rate using the method described by Westfall and Young :cite:p:`WestfallPH`
114+
:winkler_<single/two>_sample_p_value: The uncorrected p-value corrected using the method described in :cite:p:`WinklerA`

docs/source/refs.bib

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,5 +446,21 @@ @Article{SeitzmanB
446446
pages = {116290}
447447
}
448448

449+
@Book{WestfallP,
450+
title = {Resampling-Based Multiple Testing: Examples and Methods for p-Value Adjustment.},
451+
author = {Westfall P.H. & Young S.S.},
452+
publisher = {Wiley},
453+
year = {1993}
454+
}
455+
456+
@Article{WinklerA,
457+
title = {Permutation inference for the general linear model.},
458+
author = {Winkler A. Ridgway G. Webster M. Smith S. & Nichols T.},
459+
journal = {NeuroImage},
460+
year = {2014},
461+
volume = {92},
462+
pages = {381-397}
463+
}
464+
449465
.. |oumlat| unicode:: U+00D6 .. O umlaut
450466
.. |alpha| unicode:: U+03B1 .. alpha

0 commit comments

Comments
 (0)