From eece73111a412636cd61c4db74161a644a724956 Mon Sep 17 00:00:00 2001 From: Jim Pollaro Date: Mon, 22 Apr 2024 14:05:19 -0500 Subject: [PATCH 1/4] removed as many import nla.* as I could find and attempted to wrap lines longer than 120 --- +nla/+edge/+result/Base.m | 12 +- +nla/+edge/+result/Precalculated.m | 2 - +nla/+edge/+result/WelchT.m | 4 +- +nla/+edge/+test/KendallB.m | 2 - +nla/+edge/+test/Pearson.m | 1 - +nla/+edge/+test/Precalculated.m | 18 ++- +nla/+edge/+test/Spearman.m | 1 - +nla/+edge/+test/SpearmanEstimator.m | 4 +- +nla/+edge/+test/WelchT.m | 13 +- +nla/+edge/BaseTest.m | 5 +- +nla/+gfx/anatToMesh.m | 17 +-- +nla/+gfx/colorChunk.m | 1 - +nla/+gfx/createFigure.m | 2 +- +nla/+gfx/drawBrainVis.m | 46 +++--- +nla/+gfx/drawChord.m | 87 ++++++----- +nla/+gfx/drawConvergenceMap.m | 26 ++-- +nla/+gfx/drawCortex.m | 33 +++-- +nla/+gfx/drawCortexHemi.m | 2 +- +nla/+gfx/drawDesignMtx.m | 9 +- +nla/+gfx/drawNetworkROIs.m | 14 +- +nla/+gfx/drawROIsOnCortex.m | 30 ++-- +nla/+gfx/drawSphere.m | 5 +- +nla/+gfx/findCircleFromTwoTangents.m | 10 +- +nla/+gfx/genArcSegmentHandlePoorlyDefined.m | 4 +- +nla/+gfx/hideAxes.m | 2 +- +nla/+gfx/valToColor.m | 4 +- +nla/+helpers/+git/commitString.m | 3 +- +nla/+helpers/classToStructRecursive.m | 7 +- +nla/+helpers/euclidianDistanceROIs.m | 1 - +nla/+helpers/firstInstanceOfClass.m | 1 - +nla/+helpers/normClipped.m | 1 - +nla/+helpers/permuteVector.m | 1 - +nla/+helpers/rotationMatrix.m | 1 - +nla/+inputField/Behavior.m | 97 +++++++------ +nla/+inputField/EdgeLevelMatrix.m | 45 +++--- +nla/+inputField/Integer.m | 1 - +nla/+inputField/NetworkAtlas.m | 77 +++++----- +nla/+inputField/NetworkAtlasFuncConn.m | 105 ++++++++------ +nla/+inputField/Number.m | 11 +- +nla/+inputField/NumberWithoutDefault.m | 11 +- +nla/+inputField/String.m | 11 +- +nla/+mex/run.m | 8 +- +nla/+net/+mcc/BenjaminiHochberg.m | 7 +- +nla/+net/+mcc/BenjaminiYekutieli.m | 7 +- +nla/+net/+mcc/Bonferroni.m | 5 +- +nla/+net/+mcc/None.m | 5 +- +nla/+net/+result/ChiSquared.m | 5 +- +nla/+net/+result/CohenD.m | 57 ++++---- +nla/+net/+result/HyperGeo.m | 3 - +nla/+net/+result/KolmogorovSmirnov.m | 4 +- +nla/+net/+result/StudentT.m | 4 +- +nla/+net/+result/WelchT.m | 4 +- +nla/+net/+result/Wilcoxon.m | 7 +- +nla/+net/+test/ChiSquared.m | 9 +- +nla/+net/+test/CohenD.m | 16 +-- +nla/+net/+test/HyperGeo.m | 14 +- +nla/+net/+test/KolmogorovSmirnov.m | 8 +- +nla/+net/+test/StudentT.m | 8 +- +nla/+net/+test/WelchT.m | 8 +- +nla/+net/+test/Wilcoxon.m | 8 +- +nla/+net/BaseCorrResult.m | 37 +++-- +nla/+net/BaseCorrTest.m | 4 +- +nla/+net/BasePermResult.m | 144 +++++++++++-------- +nla/+net/BaseResult.m | 44 +++--- +nla/+net/BaseSigResult.m | 31 ++-- +nla/+net/BaseSigTest.m | 1 - +nla/+net/BaseTest.m | 14 +- +nla/+net/genBaseInputs.m | 6 +- +nla/+qualityControl/checkHeadMotion.m | 25 ++-- +nla/+qualityControl/viewSilhouetteCoeff.m | 5 +- +nla/DeepCopyable.m | 1 - +nla/Network.m | 2 - +nla/NetworkAtlas.m | 15 +- +nla/ROI.m | 1 - +nla/ResultPool.m | 17 +-- +nla/TestPool.m | 1 - +nla/TriMatrix.m | 13 +- +nla/findRootPath.m | 1 - +nla/genTests.m | 3 +- +nla/partialVariance.m | 5 +- +nla/silhouetteCoeff.m | 1 - +nla/validateInputStruct.m | 1 - +nla/welchT.m | 1 - NLAResult_exported.m | 6 +- main_pipeline.m | 39 +++-- precalculated_pipeline.m | 27 ++-- 86 files changed, 705 insertions(+), 654 deletions(-) diff --git a/+nla/+edge/+result/Base.m b/+nla/+edge/+result/Base.m index a64238a9..2cb85374 100755 --- a/+nla/+edge/+result/Base.m +++ b/+nla/+edge/+result/Base.m @@ -15,7 +15,8 @@ methods function obj = Base(size, prob_max) - import nla.* % required due to matlab package system quirks + import nla.TriMatrix + if nargin ~= 0 obj.coeff = TriMatrix(size); obj.prob = TriMatrix(size); @@ -25,7 +26,6 @@ end function output(obj, net_atlas, flags, prob_label) - import nla.* % required due to matlab package system quirks coeff_label = sprintf('Edge-level %s', obj.coeff_name); prob_label_appended = ''; @@ -34,8 +34,8 @@ function output(obj, net_atlas, flags, prob_label) prob_label_appended = sprintf(' (%s)', obj.behavior_name); end - fig = gfx.createFigure(); - matrix_plot = gfx.plots.MatrixPlot(fig, coeff_label, obj.coeff, net_atlas.nets, gfx.FigSize.LARGE, 'lower_limit', obj.coeff_range(1),... + fig = nla.gfx.createFigure(); + matrix_plot = nla.gfx.plots.MatrixPlot(fig, coeff_label, obj.coeff, net_atlas.nets, nla.gfx.FigSize.LARGE, 'lower_limit', obj.coeff_range(1),... 'upper_limit', obj.coeff_range(2)); matrix_plot.displayImage(); w = matrix_plot.image_dimensions("image_width"); @@ -45,7 +45,7 @@ function output(obj, net_atlas, flags, prob_label) if ~exist('prob_label', 'var') prob_label = [sprintf('Edge-level Significance (P < %g)', obj.prob_max), prob_label_appended]; end - matrix_plot2 = gfx.plots.MatrixPlot(fig, prob_label, obj.prob_sig, net_atlas.nets, gfx.FigSize.LARGE,... + matrix_plot2 = nla.gfx.plots.MatrixPlot(fig, prob_label, obj.prob_sig, net_atlas.nets, nla.gfx.FigSize.LARGE,... 'draw_legend', false, 'draw_colorbar', false, 'color_map', [[1,1,1];[0,0,0]], 'x_position', w, 'lower_limit', 0, 'upper_limit', 1); w2 = matrix_plot2.image_dimensions("image_width"); h2 = matrix_plot2.image_dimensions("image_height"); @@ -58,7 +58,7 @@ function output(obj, net_atlas, flags, prob_label) %prob_log.v = -1 * log10(obj.prob.v); cm_base = parula(1000); cm = flip(cm_base(ceil(logspace(-3, 0, 256) .* 1000), :)); - matrix_plot2 = gfx.plots.MatrixPlot(fig, prob_label, obj.prob, net_atlas.nets, gfx.FigSize.LARGE,... + matrix_plot2 = nla.gfx.plots.MatrixPlot(fig, prob_label, obj.prob, net_atlas.nets, nla.gfx.FigSize.LARGE,... 'draw_legend', false, 'color_map', cm, 'x_position', w, 'lower_limit', 0, 'upper_limit', 1); w2 = matrix_plot2.image_dimensions("image_width"); h2 = matrix_plot2.image_dimensions("image_height"); diff --git a/+nla/+edge/+result/Precalculated.m b/+nla/+edge/+result/Precalculated.m index 421a37f0..efe155ba 100755 --- a/+nla/+edge/+result/Precalculated.m +++ b/+nla/+edge/+result/Precalculated.m @@ -3,8 +3,6 @@ methods function obj = Precalculated(size, prob_max) - import nla.* % required due to matlab package system quirks - % hack because superclass constructor can't be optional?? if nargin == 0 size = 2; prob_max = -1; diff --git a/+nla/+edge/+result/WelchT.m b/+nla/+edge/+result/WelchT.m index 05a42e2f..51c2936e 100755 --- a/+nla/+edge/+result/WelchT.m +++ b/+nla/+edge/+result/WelchT.m @@ -7,8 +7,6 @@ methods function obj = WelchT(size, prob_max, group_names) - import nla.* % required due to matlab package system quirks - % hack because superclass constructor can't be optional?? if nargin == 0 size = 2; prob_max = -1; @@ -18,7 +16,7 @@ obj@nla.edge.result.Base(size, prob_max); if nargin ~= 0 - obj.dof = TriMatrix(size); + obj.dof = nla.TriMatrix(size); obj.behavior_name = sprintf("%s > %s", group_names{1}, group_names{2}); obj.coeff_range = [-3 3]; end diff --git a/+nla/+edge/+test/KendallB.m b/+nla/+edge/+test/KendallB.m index 8131930c..256ca822 100755 --- a/+nla/+edge/+test/KendallB.m +++ b/+nla/+edge/+test/KendallB.m @@ -7,12 +7,10 @@ methods function obj = KendallB() - import nla.* % required due to matlab package system quirks obj@nla.edge.BaseTest(); end function result = run(obj, input_struct) - import nla.* % required due to matlab package system quirks [tau_vec, p_vec] = mex.run('kendallTauB', input_struct.behavior, input_struct.func_conn.v'); result = obj.composeResult(input_struct.net_atlas, tau_vec', p_vec', input_struct.prob_max); end diff --git a/+nla/+edge/+test/Pearson.m b/+nla/+edge/+test/Pearson.m index 654bced4..675b8126 100755 --- a/+nla/+edge/+test/Pearson.m +++ b/+nla/+edge/+test/Pearson.m @@ -7,7 +7,6 @@ methods function obj = Pearson() - import nla.* % required due to matlab package system quirks obj@nla.edge.BaseTest(); end diff --git a/+nla/+edge/+test/Precalculated.m b/+nla/+edge/+test/Precalculated.m index 29596ceb..4b833a09 100755 --- a/+nla/+edge/+test/Precalculated.m +++ b/+nla/+edge/+test/Precalculated.m @@ -7,7 +7,6 @@ methods function obj = Precalculated() - import nla.* % required due to matlab package system quirks obj@nla.edge.BaseTest(); end @@ -31,10 +30,19 @@ methods (Static) function inputs = requiredInputs() - import nla.* % required due to matlab package system quirks - npairs_x_nperms = [inputField.DimensionType.NROIPAIRS, inputField.DimensionType.NPERMS]; - npairs_x_1 = [inputField.DimensionType.NROIPAIRS, 1]; - inputs = {inputField.NumberWithoutDefault('coeff_min', 'Coeff minimum', -Inf, Inf), inputField.NumberWithoutDefault('coeff_max', 'Coeff maximum', -Inf, Inf), inputField.NetworkAtlas(), inputField.EdgeLevelMatrix('precalc_obs_p', 'Precalculated observed significance (thresholded p-value)', npairs_x_1), inputField.EdgeLevelMatrix('precalc_obs_coeff', 'Precalculated observed coeff', npairs_x_1), inputField.EdgeLevelMatrix('precalc_perm_p', 'Precalculated permuted significance (thresholded p-value)', npairs_x_nperms), inputField.EdgeLevelMatrix('precalc_perm_coeff', 'Precalculated permuted coeff', npairs_x_nperms)}; + import nla.inputField.DimensionType nla.inputFieldNumberWithoutDefault nla.inputFieldEdgeLevelMatrix + + npairs_x_nperms = [DimensionType.NROIPAIRS,DimensionType.NPERMS]; + npairs_x_1 = [DimensionType.NROIPAIRS, 1]; + inputs = {... + NumberWithoutDefault('coeff_min', 'Coeff minimum', -Inf, Inf),... + NumberWithoutDefault('coeff_max', 'Coeff maximum', -Inf, Inf),... + inputField.NetworkAtlas(),... + EdgeLevelMatrix('precalc_obs_p', 'Precalculated observed significance (thresholded p-value)', npairs_x_1),... + EdgeLevelMatrix('precalc_obs_coeff', 'Precalculated observed coeff', npairs_x_1),... + EdgeLevelMatrix('precalc_perm_p', 'Precalculated permuted significance (thresholded p-value)', npairs_x_nperms),... + EdgeLevelMatrix('precalc_perm_coeff', 'Precalculated permuted coeff', npairs_x_nperms)... + }; end end end diff --git a/+nla/+edge/+test/Spearman.m b/+nla/+edge/+test/Spearman.m index 3fb84adf..f26f4e04 100755 --- a/+nla/+edge/+test/Spearman.m +++ b/+nla/+edge/+test/Spearman.m @@ -7,7 +7,6 @@ methods function obj = Spearman() - import nla.* % required due to matlab package system quirks obj@nla.edge.BaseTest(); end diff --git a/+nla/+edge/+test/SpearmanEstimator.m b/+nla/+edge/+test/SpearmanEstimator.m index 57bd5e64..8db1f069 100755 --- a/+nla/+edge/+test/SpearmanEstimator.m +++ b/+nla/+edge/+test/SpearmanEstimator.m @@ -21,12 +21,10 @@ methods function obj = SpearmanEstimator() - import nla.* % required due to matlab package system quirks obj@nla.edge.BaseTest(); end function result = run(obj, input_struct) - import nla.* % required due to matlab package system quirks %% input y = input_struct.func_conn.v'; @@ -78,7 +76,7 @@ ok = (abs(rho_vec) < 1); t(ok) = rho_vec(ok) .* sqrt((n - 2) ./ (1 - rho_vec(ok) .^ 2)); - result = obj.composeResult(input_struct.net_atlas, fisherR2Z(rho_vec), (2 * tcdf(-abs(t), n - 2)), input_struct.prob_max); + result = obj.composeResult(input_struct.net_atlas, nla.fisherR2Z(rho_vec), (2 * tcdf(-abs(t), n - 2)), input_struct.prob_max); end end end diff --git a/+nla/+edge/+test/WelchT.m b/+nla/+edge/+test/WelchT.m index 43ee2cbe..f2376612 100755 --- a/+nla/+edge/+test/WelchT.m +++ b/+nla/+edge/+test/WelchT.m @@ -9,12 +9,10 @@ methods function obj = WelchT() - import nla.* % required due to matlab package system quirks obj@nla.edge.BaseTest(); end function result = run(obj, input_struct) - import nla.* % required due to matlab package system quirks % This function calculates the t-test between 2 sets of data using the % Welch method that does not assume equal mean or variance or samples. The % function returns the t-statistic, p-value, and degrees of freedom. @@ -48,17 +46,16 @@ methods (Static) function inputs = requiredInputs() - import nla.* % required due to matlab package system quirks inputs = requiredInputs@nla.edge.BaseTest(); % disable adding/modifying covariates in behavior - behavior_handle = helpers.firstInstanceOfClass(inputs, 'nla.inputField.Behavior'); + behavior_handle = nla.helpers.firstInstanceOfClass(inputs, 'nla.inputField.Behavior'); behavior_handle.covariates_enabled = nla.inputField.CovariatesEnabled.ONLY_FC; - inputs{end + 1} = inputField.String('group1_name', 'Group 1 name:', 'Group1'); - inputs{end + 1} = inputField.Number('group1_val', 'Group 1 behavior value:', -Inf, 1, Inf); - inputs{end + 1} = inputField.String('group2_name', 'Group 2 name:', 'Group2'); - inputs{end + 1} = inputField.Number('group2_val', 'Group 2 behavior value:', -Inf, 0, Inf); + inputs{end + 1} = nla.inputField.String('group1_name', 'Group 1 name:', 'Group1'); + inputs{end + 1} = nla.inputField.Number('group1_val', 'Group 1 behavior value:', -Inf, 1, Inf); + inputs{end + 1} = nla.inputField.String('group2_name', 'Group 2 name:', 'Group2'); + inputs{end + 1} = nla.inputField.Number('group2_val', 'Group 2 behavior value:', -Inf, 0, Inf); end end end diff --git a/+nla/+edge/BaseTest.m b/+nla/+edge/BaseTest.m index a1d7cbee..00aa6b28 100755 --- a/+nla/+edge/BaseTest.m +++ b/+nla/+edge/BaseTest.m @@ -7,7 +7,6 @@ methods function obj = BaseTest() - import nla.* % required due to matlab package system quirks end end @@ -33,8 +32,8 @@ methods (Static) function inputs = requiredInputs() - import nla.* % required due to matlab package system quirks - inputs = {inputField.Number('prob_max', 'Edge-level P threshold <', 0, 0.05, 1), inputField.NetworkAtlasFuncConn(), inputField.Behavior()}; + inputs = {nla.inputField.Number('prob_max', 'Edge-level P threshold <', 0, 0.05, 1),... + nla.inputField.NetworkAtlasFuncConn(), nla.inputField.Behavior()}; end end end diff --git a/+nla/+gfx/anatToMesh.m b/+nla/+gfx/anatToMesh.m index 24c4fbac..f06b7d75 100755 --- a/+nla/+gfx/anatToMesh.m +++ b/+nla/+gfx/anatToMesh.m @@ -1,20 +1,21 @@ function [mesh_l, mesh_r] = anatToMesh(anat, ctx, view_pos) + import nla.gfx.ViewPos nla.gfx.MeshType + %ANATTOMESH generate cortex hemisphere mesh from anatomy % anat: anatomy struct, contained in cortex mesh files % ctx: MeshType value, what inflation level of mesh to use % view_pos: ViewPos value, which standard view to use % mesh_l: mesh of left hemisphere of brain % mesh_r: mesh of right hemisphere of brain - import nla.* % required due to matlab package system quirks %% Choose inflation switch ctx - case gfx.MeshType.STD + case MeshType.STD mesh_l = anat.hemi_l.nodes; mesh_r = anat.hemi_r.nodes; - case gfx.MeshType.INF + case MeshType.INF mesh_l = anat.hemi_l.Inodes; mesh_r = anat.hemi_r.Inodes; - case gfx.MeshType.VINF + case MeshType.VINF mesh_l = anat.hemi_l.VInodes; mesh_r = anat.hemi_r.VInodes; end @@ -24,18 +25,18 @@ mesh_r(:,1) = mesh_r(:,1) - min(mesh_r(:,1)); %% Rotate if necessary - if view_pos == gfx.ViewPos.LAT || view_pos == gfx.ViewPos.MED + if view_pos == ViewPos.LAT || view_pos == ViewPos.MED dy = -5; % rotate right hemi around and move to position for visualization cmL = mean(mesh_l, 1); cmR = mean(mesh_r, 1); - rm = helpers.rotationMatrix(Dir.Z, pi); + rm = nla.helpers.rotationMatrix(Dir.Z, pi); % Rotate switch view_pos - case gfx.ViewPos.LAT + case ViewPos.LAT mesh_r = (mesh_r - (repmat(cmR, size(mesh_r, 1), 1))) * rm + (repmat(cmR, size(mesh_r, 1), 1)); - case gfx.ViewPos.MED + case ViewPos.MED mesh_l = (mesh_l - (repmat(cmL, size(mesh_l, 1), 1))) * rm + (repmat(cmL, size(mesh_l, 1), 1)); end mesh_r(:, 1) = mesh_r(:, 1) + (cmL(:, 1) - cmR(:, 1)); % Shift over to same YZ plane diff --git a/+nla/+gfx/colorChunk.m b/+nla/+gfx/colorChunk.m index fd96eb49..483100e2 100755 --- a/+nla/+gfx/colorChunk.m +++ b/+nla/+gfx/colorChunk.m @@ -1,5 +1,4 @@ function chunk = colorChunk(color, h, w) - import nla.* % required due to matlab package system quirks %COLORCHUNK create a matrix of size h * w * 3, filled with color chunk = repmat(reshape(color,1,1,[]), h, w); end diff --git a/+nla/+gfx/createFigure.m b/+nla/+gfx/createFigure.m index ca6911a7..7aa51652 100755 --- a/+nla/+gfx/createFigure.m +++ b/+nla/+gfx/createFigure.m @@ -3,7 +3,7 @@ %toolbar, etc. settings. % w: width in pixels % h: height in pixels - import nla.* % required due to matlab package system quirks + fig = figure('Color', 'w', 'Resize', 'off', 'Name', 'NLA Figure', 'NumberTitle','off'); %fig.Icon = [findRootPath() 'thumb.png']; if exist('w', 'var') && exist('h', 'var') diff --git a/+nla/+gfx/drawBrainVis.m b/+nla/+gfx/drawBrainVis.m index 2f19d5bd..a38535b8 100755 --- a/+nla/+gfx/drawBrainVis.m +++ b/+nla/+gfx/drawBrainVis.m @@ -13,8 +13,6 @@ function drawBrainVis(edge_input_struct, input_struct, net_atlas, ctx, mesh_alph % net2: Network to view correlations between % sig_based: whether the net-level test is based on p-values % thresholded by significance (for example, Chi2, HG) - - import nla.* % required due to matlab package system quirks fc_exists = isfield(edge_input_struct, 'func_conn'); @@ -26,7 +24,7 @@ function drawBrainVis(edge_input_struct, input_struct, net_atlas, ctx, mesh_alph end %% Display figures - fig = gfx.createFigure(1550, 750); + fig = nla.gfx.createFigure(1550, 750); figure_title = sprintf('Brain Visualization: Average of edge-level correlations between nets in [%s - %s] Network Pair', net_atlas.nets(net1).name, net_atlas.nets(net2).name); if sig_based @@ -98,13 +96,15 @@ function drawBrainVis(edge_input_struct, input_struct, net_atlas, ctx, mesh_alph end function cols = valsToColor(ROI_vals, fc_vals, color_map, color_map_p, color_map_n, color_fc, llimit, ulimit) + import nla.gfx.valToColor + if color_fc - cols_p = gfx.valToColor(fc_vals, -0.5, 0.5, color_map_p); - cols_n = gfx.valToColor(fc_vals, -0.5, 0.5, color_map_n); + cols_p = valToColor(fc_vals, -0.5, 0.5, color_map_p); + cols_n = valToColor(fc_vals, -0.5, 0.5, color_map_n); cols(ROI_vals > 0, :) = cols_p(ROI_vals > 0, :); cols(ROI_vals <= 0, :) = cols_n(ROI_vals <= 0, :); else - cols = gfx.valToColor(ROI_vals, llimit, ulimit, color_map); + cols = valToColor(ROI_vals, llimit, ulimit, color_map); end end @@ -121,7 +121,7 @@ function drawROISpheres(ROI_pos, ax, net_atlas, net1, net2, ROI_radius, conn_map if conn_map(j) % render a sphere at each ROI location - gfx.drawSphere(ax, ROI_pos(j, :), net_atlas.nets(n).color, ROI_radius); + nla.gfx.drawSphere(ax, ROI_pos(j, :), net_atlas.nets(n).color, ROI_radius); end end end @@ -148,7 +148,8 @@ function drawEdges(ROI_pos, ax, net_atlas, net1, net2, color_map, color_map_p, c if ~isempty(val) col = valsToColor(val, fc_val_avg, color_map, color_map_p, color_map_n, color_fc && fc_exists, llimit, ulimit); col = [reshape(col, [1, 3]), 0.5]; - p = plot3(ax, [ROI_pos(n1, 1), ROI_pos(n2, 1)], [ROI_pos(n1, 2), ROI_pos(n2, 2)], [ROI_pos(n1, 3), ROI_pos(n2, 3)], 'Color', col, 'LineWidth', 5); + p = plot3(ax, [ROI_pos(n1, 1), ROI_pos(n2, 1)], [ROI_pos(n1, 2), ROI_pos(n2, 2)],... + [ROI_pos(n1, 3), ROI_pos(n2, 3)], 'Color', col, 'LineWidth', 5); p.Annotation.LegendInformation.IconDisplayStyle = 'off'; end end @@ -156,11 +157,14 @@ function drawEdges(ROI_pos, ax, net_atlas, net1, net2, color_map, color_map_p, c end function onePlot(ax, pos, color_mode, color_mat) - if color_mode == gfx.BrainColorMode.NONE - ROI_final_pos = gfx.drawROIsOnCortex(ax, net_atlas, ctx, mesh_alpha, ROI_radius, pos, surface_parcels, gfx.BrainColorMode.NONE); - drawEdges(ROI_final_pos, ax, net_atlas, net1, net2, color_map, color_map_p, color_map_n, color_fc, fc_exists, llimit, ulimit, edge_input_struct, edge_result, sig_based); + if color_mode == nla.gfx.BrainColorMode.NONE + ROI_final_pos = nla.gfx.drawROIsOnCortex(ax, net_atlas, ctx, mesh_alpha, ROI_radius, pos, surface_parcels,... + nla.gfx.BrainColorMode.NONE); + drawEdges(ROI_final_pos, ax, net_atlas, net1, net2, color_map, color_map_p, color_map_n, color_fc, fc_exists,... + llimit, ulimit, edge_input_struct, edge_result, sig_based); else - ROI_final_pos = gfx.drawROIsOnCortex(ax, net_atlas, ctx, 1, ROI_radius, pos, surface_parcels, gfx.BrainColorMode.COLOR_ROIS, color_mat); + ROI_final_pos = nla.gfx.drawROIsOnCortex(ax, net_atlas, ctx, 1, ROI_radius, pos, surface_parcels,... + nla.gfx.BrainColorMode.COLOR_ROIS, color_mat); end if show_ROI_centroids @@ -169,13 +173,13 @@ function onePlot(ax, pos, color_mode, color_mat) end if surface_parcels && ~islogical(net_atlas.parcels) - onePlot(subplot('Position',[.45,0.505,.53,.45]), gfx.ViewPos.LAT, gfx.BrainColorMode.COLOR_ROIS, color_mat); - onePlot(subplot('Position',[.45,0.055,.53,.45]), gfx.ViewPos.MED, gfx.BrainColorMode.COLOR_ROIS, color_mat); + onePlot(subplot('Position',[.45,0.505,.53,.45]), nla.gfx.ViewPos.LAT, nla.gfx.BrainColorMode.COLOR_ROIS, color_mat); + onePlot(subplot('Position',[.45,0.055,.53,.45]), nla.gfx.ViewPos.MED, nla.gfx.BrainColorMode.COLOR_ROIS, color_mat); else - onePlot(subplot('Position',[.45,0.505,.26,.45]), gfx.ViewPos.BACK, gfx.BrainColorMode.NONE); - onePlot(subplot('Position',[.73,0.505,.26,.45]), gfx.ViewPos.FRONT, gfx.BrainColorMode.NONE); - onePlot(subplot('Position',[.45,0.055,.26,.45]), gfx.ViewPos.LEFT, gfx.BrainColorMode.NONE); - onePlot(subplot('Position',[.73,0.055,.26,.45]), gfx.ViewPos.RIGHT, gfx.BrainColorMode.NONE); + onePlot(subplot('Position',[.45,0.505,.26,.45]), nla.gfx.ViewPos.BACK, nla.gfx.BrainColorMode.NONE); + onePlot(subplot('Position',[.73,0.505,.26,.45]), nla.gfx.ViewPos.FRONT, nla.gfx.BrainColorMode.NONE); + onePlot(subplot('Position',[.45,0.055,.26,.45]), nla.gfx.ViewPos.LEFT, nla.gfx.BrainColorMode.NONE); + onePlot(subplot('Position',[.73,0.055,.26,.45]), nla.gfx.ViewPos.RIGHT, nla.gfx.BrainColorMode.NONE); end if color_fc @@ -185,9 +189,9 @@ function onePlot(ax, pos, color_mode, color_mat) end if surface_parcels && ~islogical(net_atlas.parcels) - onePlot(ax, gfx.ViewPos.DORSAL, gfx.BrainColorMode.COLOR_ROIS, color_mat); + onePlot(ax, nla.gfx.ViewPos.DORSAL, nla.gfx.BrainColorMode.COLOR_ROIS, color_mat); else - onePlot(ax, gfx.ViewPos.DORSAL, gfx.BrainColorMode.NONE); + onePlot(ax, nla.gfx.ViewPos.DORSAL, nla.gfx.BrainColorMode.NONE); end light('Position',[0,100,100],'Style','local'); @@ -206,7 +210,7 @@ function onePlot(ax, pos, color_mode, color_mat) end end hold(ax, 'off'); - gfx.hideAxes(ax); + nla.gfx.hideAxes(ax); %% Display colormap if color_fc diff --git a/+nla/+gfx/drawChord.m b/+nla/+gfx/drawChord.m index 53bdbe1d..4586656d 100755 --- a/+nla/+gfx/drawChord.m +++ b/+nla/+gfx/drawChord.m @@ -14,10 +14,12 @@ function drawChord(ax, ax_width, net_atlas, sig_mat, color_map, sig_type, chord_ % coeff_max: Upper bound of values % representative: true to Z-order values randomly, false to display % more significant values over less significant ones - import nla.* % required due to matlab package system quirks - - if ~exist('sig_type', 'var'), sig_type = gfx.SigType.INCREASING; end - if ~exist('chord_type', 'var'), chord_type = nla.PlotType.CHORD; end + + import nla.TriMatrix nla.TriMatrixDiag nla.PlotType nla.gfx.SigType + import nla.gfx.genArcSegment + + if ~exist('sig_type', 'var'), sig_type = SigType.INCREASING; end + if ~exist('chord_type', 'var'), chord_type = PlotType.CHORD; end if ~exist('coeff_min', 'var'), coeff_min = 0; end if ~exist('coeff_max', 'var'), coeff_max = 1; end if ~exist('representative', 'var'), representative = false; end @@ -30,7 +32,7 @@ function drawChord(ax, ax_width, net_atlas, sig_mat, color_map, sig_type, chord_ text_radius = circle_radius + (text_width / 4); circle_thickness = 3; - if chord_type == nla.PlotType.CHORD + if chord_type == PlotType.CHORD space_between_nets_and_labels = 3; else space_between_nets_and_labels = 6; @@ -41,7 +43,7 @@ function drawChord(ax, ax_width, net_atlas, sig_mat, color_map, sig_type, chord_ circle_radius_inner = circle_radius - circle_thickness; chord_radius = circle_radius_inner - space_between_nets_and_labels; - if chord_type == nla.PlotType.CHORD + if chord_type == PlotType.CHORD net_size_rads = 2 * pi / net_atlas.numNets(); net_pair_size_rads = (net_size_rads - space_between_nets_rad) / (net_atlas.numNets() + 1); @@ -62,7 +64,7 @@ function drawChord(ax, ax_width, net_atlas, sig_mat, color_map, sig_type, chord_ end for n = 1:net_atlas.numNets() - if chord_type == nla.PlotType.CHORD + if chord_type == PlotType.CHORD n_start_rad = (n - 1) * net_size_rads + (space_between_nets_rad / 2); n_end_rad = n * net_size_rads - (space_between_nets_rad / 2); else @@ -72,8 +74,8 @@ function drawChord(ax, ax_width, net_atlas, sig_mat, color_map, sig_type, chord_ n_start_rad_arr(n) = n_start_rad; end n_center_rad = (n_end_rad + n_start_rad) / 2; - outer = gfx.genArcSegment([0, 0], [n_start_rad, n_end_rad], circle_radius, 50); - inner = gfx.genArcSegment([0, 0], [n_start_rad, n_end_rad], circle_radius_inner, 50); + outer = genArcSegment([0, 0], [n_start_rad, n_end_rad], circle_radius, 50); + inner = genArcSegment([0, 0], [n_start_rad, n_end_rad], circle_radius_inner, 50); poly_verts = [outer; flip(inner, 1)]; poly = polyshape(poly_verts(:, 1), poly_verts(:, 2)); pg = plot(ax, poly); @@ -83,7 +85,7 @@ function drawChord(ax, ax_width, net_atlas, sig_mat, color_map, sig_type, chord_ pg.EdgeColor = n_color; pg.EdgeAlpha = 1; - text_pos = gfx.genArcSegment([0, 0], [n_start_rad, n_end_rad], text_radius, 3); + text_pos = genArcSegment([0, 0], [n_start_rad, n_end_rad], text_radius, 3); text_pos = text_pos(2, :); text_pos(1) = text_pos(1); text_angle = n_center_rad + (pi / 2); @@ -92,25 +94,28 @@ function drawChord(ax, ax_width, net_atlas, sig_mat, color_map, sig_type, chord_ % display network label rotated 90 degrees if the associated % network is small and name is large - if chord_type == nla.PlotType.CHORD_EDGE && net_size_rads_arr(n) < 0.25 && strlength(name_disp) > 5 + if chord_type == PlotType.CHORD_EDGE && net_size_rads_arr(n) < 0.25 && strlength(name_disp) > 5 if strlength(name_disp) > 8 name_disp = sprintf("%.7s...", name_disp); end text_angle = text_angle - (pi / 2); if text_angle > pi/2 && text_angle < 3 * pi/2 text_angle = text_angle - pi; - text(text_pos(1), text_pos(2), name_disp, 'HorizontalAlignment', 'right', 'Rotation', rad2deg(text_angle)); + text(text_pos(1), text_pos(2), name_disp, 'HorizontalAlignment', 'right',... + 'Rotation', rad2deg(text_angle)); else - text(text_pos(1), text_pos(2), name_disp, 'HorizontalAlignment', 'left', 'Rotation', rad2deg(text_angle)); + text(text_pos(1), text_pos(2), name_disp, 'HorizontalAlignment', 'left',... + 'Rotation', rad2deg(text_angle)); end else if text_pos(2) > 0 text_angle = text_angle - pi; end - text(text_pos(1), text_pos(2), name_disp, 'HorizontalAlignment', 'center', 'Rotation', rad2deg(text_angle)); + text(text_pos(1), text_pos(2), name_disp, 'HorizontalAlignment', 'center',... + 'Rotation', rad2deg(text_angle)); end - if chord_type == nla.PlotType.CHORD + if chord_type == PlotType.CHORD for n2 = n:net_atlas.numNets() %% find which nets to connect to n_idx = find(nets_connected(n, :) == 0, 1, 'last'); @@ -131,26 +136,27 @@ function drawChord(ax, ax_width, net_atlas, sig_mat, color_map, sig_type, chord_ if representative idx = randperm(numel(sig_mat.v)); else - if sig_type == gfx.SigType.INCREASING + if sig_type == SigType.INCREASING [~, idx] = sort(sig_mat.v); - elseif sig_type == gfx.SigType.DECREASING + elseif sig_type == SigType.DECREASING [~, idx] = sort(sig_mat.v, 'descend'); else [~, idx] = sort(abs(sig_mat.v)); end end - if chord_type == nla.PlotType.CHORD_EDGE + if chord_type == PlotType.CHORD_EDGE row_mat = TriMatrix(repelem(1:net_atlas.numROIs(),net_atlas.numROIs(),1)'); col_mat = TriMatrix(repelem(1:net_atlas.numROIs(),net_atlas.numROIs(),1)); end % ROI locations for edge-level plot - if chord_type == nla.PlotType.CHORD_EDGE + if chord_type == PlotType.CHORD_EDGE for n = 1:net_atlas.numNets() for r = 1:net_atlas.nets(n).numROIs() ROI_center_rad = n_start_rad_arr(n) + (((r - 1) * ROI_size_rads)) + (ROI_size_rads / 2); - ROI_center = gfx.genArcSegment([0, 0], [ROI_center_rad, ROI_center_rad], (circle_radius_inner + chord_radius) / 2, 1); + ROI_center = genArcSegment([0, 0], [ROI_center_rad, ROI_center_rad],... + (circle_radius_inner + chord_radius) / 2, 1); ROI_centers_rad(net_atlas.nets(n).indexes(r)) = ROI_center_rad; ROI_centers(net_atlas.nets(n).indexes(r), :) = ROI_center; end @@ -159,10 +165,14 @@ function drawChord(ax, ax_width, net_atlas, sig_mat, color_map, sig_type, chord_ for idx_iter = 1:numel(sig_mat.v) i = idx(idx_iter); - if ~isnan(sig_mat.v(i)) && ((sig_type == gfx.SigType.INCREASING && sig_mat.v(i) > coeff_min) || (sig_type == gfx.SigType.DECREASING && sig_mat.v(i) < coeff_max) || (sig_type == gfx.SigType.ABS_INCREASING && abs(sig_mat.v(i)) > 0)) + if ~isnan(sig_mat.v(i)) && (... + (sig_type == SigType.INCREASING && sig_mat.v(i) > coeff_min) ||... + (sig_type == SigType.DECREASING && sig_mat.v(i) < coeff_max) ||... + (sig_type == SigType.ABS_INCREASING && abs(sig_mat.v(i)) > 0)... + ) %% color sig = sig_mat.v(i); - np_color = gfx.valToColor(sig, coeff_min, coeff_max, color_map); + np_color = nla.gfx.valToColor(sig, coeff_min, coeff_max, color_map); np_color = np_color(:); % flatten color matrix to vector if representative @@ -171,7 +181,7 @@ function drawChord(ax, ax_width, net_atlas, sig_mat, color_map, sig_type, chord_ np_alpha = 1; end - if chord_type == nla.PlotType.CHORD + if chord_type == PlotType.CHORD n = n_arr.v(i); n2 = n2_arr.v(i); n_idx = n_idx_arr.v(i); @@ -188,20 +198,24 @@ function drawChord(ax, ax_width, net_atlas, sig_mat, color_map, sig_type, chord_ %% start and end points of the chord, in cartesian coordinates % for the first net in the pair - np1_points = gfx.genArcSegment([0, 0], [np1_start_rad, np1_end_rad], chord_radius, 2); + np1_points = genArcSegment([0, 0], [np1_start_rad, np1_end_rad], chord_radius, 2); np1_start = np1_points(1,:); np1_end = np1_points(2,:); % for the second net in the pair - np2_points = gfx.genArcSegment([0, 0], [np2_start_rad, np2_end_rad], chord_radius, 2); + np2_points = genArcSegment([0, 0], [np2_start_rad, np2_end_rad], chord_radius, 2); np2_start = np2_points(1,:); np2_end = np2_points(2,:); %% generate connecting circles between inner/outer points - [inner_origin, inner_origin_rad, inner_radius] = nla.gfx.findCircleFromTwoTangents(np2_start, np1_end, np2_start_rad + pi, np1_end_rad); - inner = nla.gfx.genArcSegmentHandlePoorlyDefined(inner_origin, inner_origin_rad, inner_radius, np1_end, np2_start, 50); + [inner_origin, inner_origin_rad, inner_radius] =... + nla.gfx.findCircleFromTwoTangents(np2_start, np1_end, np2_start_rad + pi, np1_end_rad); + inner = nla.gfx.genArcSegmentHandlePoorlyDefined(inner_origin, inner_origin_rad, inner_radius,... + np1_end, np2_start, 50); - [outer_origin, outer_origin_rad, outer_radius] = gfx.findCircleFromTwoTangents(np2_end, np1_start, np2_end_rad + pi, np1_start_rad); - outer = nla.gfx.genArcSegmentHandlePoorlyDefined(outer_origin, outer_origin_rad, outer_radius, np1_start, np2_end, 50); + [outer_origin, outer_origin_rad, outer_radius] =... + nla.gfx.findCircleFromTwoTangents(np2_end, np1_start, np2_end_rad + pi, np1_start_rad); + outer = nla.gfx.genArcSegmentHandlePoorlyDefined(outer_origin, outer_origin_rad, outer_radius,... + np1_start, np2_end, 50); %% construct mesh poly_verts = [outer; flip(inner, 1)]; @@ -219,12 +233,14 @@ function drawChord(ax, ax_width, net_atlas, sig_mat, color_map, sig_type, chord_ r1_center_rad = ROI_centers_rad(r1); r2_center_rad = ROI_centers_rad(r2); - r1_center = gfx.genArcSegment([0, 0], [r1_center_rad, r1_center_rad], chord_radius + 1, 1); - r2_center = gfx.genArcSegment([0, 0], [r2_center_rad, r2_center_rad], chord_radius + 1, 1); - [arc_origin, arc_origin_rad, arc_radius] = gfx.findCircleFromTwoTangents(r2_center, r1_center, r2_center_rad + pi, r1_center_rad); + r1_center = genArcSegment([0, 0], [r1_center_rad, r1_center_rad], chord_radius + 1, 1); + r2_center = genArcSegment([0, 0], [r2_center_rad, r2_center_rad], chord_radius + 1, 1); + [arc_origin, arc_origin_rad, arc_radius] =... + nla.gfx.findCircleFromTwoTangents(r2_center, r1_center, r2_center_rad + pi, r1_center_rad); % Handle poorly-defined circles - arc = gfx.genArcSegmentHandlePoorlyDefined(arc_origin, arc_origin_rad, arc_radius, r1_center, r2_center, 50); + arc = nla.gfx.genArcSegmentHandlePoorlyDefined(arc_origin, arc_origin_rad, arc_radius,... + r1_center, r2_center, 50); pg = plot(ax, arc(:,1), arc(:,2), 'LineWidth', 2); pg.Color = [np_color; np_alpha]; @@ -232,10 +248,11 @@ function drawChord(ax, ax_width, net_atlas, sig_mat, color_map, sig_type, chord_ end end - viscircles(ax, [0, 0], circle_radius_inner - (space_between_nets_and_labels / 2), 'Color', 'w', 'LineWidth', space_between_nets_and_labels - 1); + viscircles(ax, [0, 0], circle_radius_inner - (space_between_nets_and_labels / 2), 'Color', 'w',... + 'LineWidth', space_between_nets_and_labels - 1); % tick marks for edge-level chord plot - if chord_type == nla.PlotType.CHORD_EDGE + if chord_type == PlotType.CHORD_EDGE for r = 1:net_atlas.numROIs() plot(ax, ROI_centers(r, 1), ROI_centers(r, 2), '.k', 'MarkerSize', 3); end diff --git a/+nla/+gfx/drawConvergenceMap.m b/+nla/+gfx/drawConvergenceMap.m index 9503965b..841d68fb 100755 --- a/+nla/+gfx/drawConvergenceMap.m +++ b/+nla/+gfx/drawConvergenceMap.m @@ -10,19 +10,20 @@ function drawConvergenceMap(edge_input_struct, input_struct, net_atlas, sig_coun % names: cell array of the names of each test % edge_result: edge-level result % color_map: color map of convergence map - import nla.* % required due to matlab package system quirks + import nla.TriMatrix nla.TriMatrixDiag + ax_width = 750; trimat_width = 500; bottom_text_height = 250; - fig = gfx.createFigure(ax_width + trimat_width, ax_width); + fig = nla.gfx.createFigure(ax_width + trimat_width, ax_width); fig.Renderer = 'painters'; %% Chord plot ax = axes(fig, 'Units', 'pixels', 'Position', [trimat_width, 0, ax_width, ax_width]); - gfx.hideAxes(ax); + nla.gfx.hideAxes(ax); sig_mat = TriMatrix(net_atlas.numNets(), 'double', TriMatrixDiag.KEEP_DIAGONAL); sig_mat.v = sig_count_mat.v ./ num_tests; @@ -32,18 +33,23 @@ function drawConvergenceMap(edge_input_struct, input_struct, net_atlas, sig_coun %% Trimatrix plot function brainFigsButtonClickedCallback(net1, net2) - f = waitbar(0.05, sprintf('Generating %s - %s net-pair brain plot', net_atlas.nets(net1).name, net_atlas.nets(net2).name)); - gfx.drawBrainVis(edge_input_struct, input_struct, net_atlas, gfx.MeshType.STD, 0.25, 3, true, edge_result, net1, net2, false); + f = waitbar(0.05, sprintf('Generating %s - %s net-pair brain plot', net_atlas.nets(net1).name,... + net_atlas.nets(net2).name)); + nla.gfx.drawBrainVis(edge_input_struct, input_struct, net_atlas, nla.gfx.MeshType.STD, 0.25, 3,... + true, edge_result, net1, net2, false); waitbar(0.95); close(f) end - matrix_plot = gfx.plots.MatrixPlot(fig, sprintf('Convergence map\nSignificant Tests Per Net-Pair'), sig_count_mat, net_atlas.nets, gfx.FigSize.SMALL,... - 'y_position', bottom_text_height, 'lower_limit', 0, 'upper_limit', num_tests, 'discrete_colorbar', true, 'network_clicked_callback', @brainFigsButtonClickedCallback,... - 'draw_legend', false, 'color_map', color_map); + matrix_plot = nla.gfx.plots.MatrixPlot(fig, sprintf('Convergence map\nSignificant Tests Per Net-Pair'),... + sig_count_mat, net_atlas.nets, nla.gfx.FigSize.SMALL,'y_position', bottom_text_height,... + 'lower_limit', 0, 'upper_limit', num_tests, 'discrete_colorbar', true,... + 'network_clicked_callback', @brainFigsButtonClickedCallback, 'draw_legend', false, 'color_map', color_map); matrix_plot.displayImage(); %% Plot names text_ax = axes(fig, 'Units', 'pixels', 'Position', [55, bottom_text_height + 15, 450, 75]); - gfx.hideAxes(text_ax); - text(text_ax, 0, 0, sprintf("Click any net-pair in the above plot to view its edge-level correlations.\n\nMethods/Tests used:") + newline + join(names, newline), 'HorizontalAlignment', 'left', 'VerticalAlignment', 'top'); + nla.gfx.hideAxes(text_ax); + text(text_ax, 0, 0,... + sprintf("Click any net-pair in the above plot to view its edge-level correlations.\n\nMethods/Tests used:") + newline + join(names, newline),... + 'HorizontalAlignment', 'left', 'VerticalAlignment', 'top'); end \ No newline at end of file diff --git a/+nla/+gfx/drawCortex.m b/+nla/+gfx/drawCortex.m index 442e3fc4..9cfc495d 100755 --- a/+nla/+gfx/drawCortex.m +++ b/+nla/+gfx/drawCortex.m @@ -6,7 +6,8 @@ function drawCortex(ax, anat, ctx, mesh_alpha, view_pos, color_l, color_r) % mesh_alpha: transparency of cortex mesh, 0-1 % view_pos: ViewPos enumeration value, which direction to view cortex - import nla.* % required due to matlab package system quirks + import nla.gfx.ViewPos + %% Default values if ~exist('color_l','var'), color_l = repmat(0.5, [size(anat.hemi_l.nodes, 1), 3]); end if ~exist('color_r','var'), color_r = repmat(0.5, [size(anat.hemi_r.nodes, 1), 3]); end @@ -16,43 +17,49 @@ function drawCortex(ax, anat, ctx, mesh_alpha, view_pos, color_l, color_r) %% Image hemispheres % Re-position meshes for standard transverse orientation etc. - [mesh_l, mesh_r] = gfx.anatToMesh(anat, ctx, view_pos); + [mesh_l, mesh_r] = nla.gfx.anatToMesh(anat, ctx, view_pos); % Set lighting and persepctive - if view_pos == gfx.ViewPos.LAT || view_pos == gfx.ViewPos.MED + if view_pos == ViewPos.LAT || view_pos == ViewPos.MED view(ax, [-90,0]); light(ax, 'Position', [-100,200,0], 'Style', 'local'); - light(ax, 'Position', [-50,-500,100], 'Style', 'infinite'); % These two lines create minimal lighting good luck. <-- what did he mean by this? + % These two lines create minimal lighting good luck. <-- what did he mean by this? + light(ax, 'Position', [-50,-500,100], 'Style', 'infinite'); light(ax, 'Position', [-50,0,0], 'Style', 'infinite'); else - if view_pos == gfx.ViewPos.POST + if view_pos == ViewPos.POST view(ax, [0 0]); - elseif view_pos == gfx.ViewPos.DORSAL + elseif view_pos == ViewPos.DORSAL view(ax, [0 90]); light(ax, 'Position', [100,300,100], 'Style', 'infinite'); - elseif view_pos == gfx.ViewPos.LEFT + elseif view_pos == ViewPos.LEFT view(ax, [-90,0]); light(ax, 'Position', [-100,0,0], 'Style', 'infinite'); - elseif view_pos == gfx.ViewPos.RIGHT + elseif view_pos == ViewPos.RIGHT view(ax, [90,0]); light(ax, 'Position', [100,0,0], 'Style', 'infinite'); - elseif view_pos == gfx.ViewPos.FRONT + elseif view_pos == ViewPos.FRONT view(ax, [180,0]); light(ax, 'Position', [100,300,100], 'Style', 'infinite'); - elseif view_pos == gfx.ViewPos.BACK + elseif view_pos == ViewPos.BACK view(ax, [0,0]); light(ax, 'Position', [0,-200,0], 'Style', 'infinite'); end - if view_pos == gfx.ViewPos.POST || view_pos == gfx.ViewPos.DORSAL || view_pos == gfx.ViewPos.LEFT || view_pos == gfx.ViewPos.RIGHT || view_pos == gfx.ViewPos.FRONT || view_pos == gfx.ViewPos.BACK + if view_pos == ViewPos.POST ||... + view_pos == ViewPos.DORSAL ||... + view_pos == ViewPos.LEFT ||... + view_pos == ViewPos.RIGHT ||... + view_pos == ViewPos.FRONT ||... + view_pos == ViewPos.BACK light(ax, 'Position', [-500,-20,0], 'Style', 'local'); light(ax, 'Position', [500,-20,0], 'Style', 'local'); light(ax, 'Position', [0,-200,50], 'Style', 'local'); end end - gfx.drawCortexHemi(ax, anat.hemi_l, mesh_l, color_l, mesh_alpha); - gfx.drawCortexHemi(ax, anat.hemi_r, mesh_r, color_r, mesh_alpha); + nla.gfx.drawCortexHemi(ax, anat.hemi_l, mesh_l, color_l, mesh_alpha); + nla.gfx.drawCortexHemi(ax, anat.hemi_r, mesh_r, color_r, mesh_alpha); axis(ax, 'image'); axis(ax, 'off'); diff --git a/+nla/+gfx/drawCortexHemi.m b/+nla/+gfx/drawCortexHemi.m index 33d623d7..b6fec47c 100755 --- a/+nla/+gfx/drawCortexHemi.m +++ b/+nla/+gfx/drawCortexHemi.m @@ -5,7 +5,7 @@ % mesh: vertices of anatomy % color: 3x1 vector, cortex mesh color % mesh_alpha: transparency of cortex mesh - import nla.* % required due to matlab package system quirks + obj = patch(ax, 'Faces',anat_hemi.elements(:,1:3),'Vertices', mesh,... 'EdgeColor','none','FaceColor','interp','FaceVertexCData', color,... 'FaceLighting','gouraud','FaceAlpha',mesh_alpha,... diff --git a/+nla/+gfx/drawDesignMtx.m b/+nla/+gfx/drawDesignMtx.m index 6eabde14..6fec868a 100755 --- a/+nla/+gfx/drawDesignMtx.m +++ b/+nla/+gfx/drawDesignMtx.m @@ -2,11 +2,11 @@ function drawDesignMtx(design_mtx, labels) %DRAWDESIGNMTX Display design matrix in new figure % design_mtx: NxN design matrix % labels: Nx1 cell array, name labels of each variable - import nla.* % required due to matlab package system quirks + % column-wise normalize the design matrix design_mtx_norm = (design_mtx - min(design_mtx)) ./ (max(design_mtx) - min(design_mtx)); - gfx.createFigure(900, 450); + nla.gfx.createFigure(900, 450); ax = subplot('Position', [9/48, 4/12, 7/24, 7/12]); [num_scans, num_covariates] = size(design_mtx); @@ -29,7 +29,7 @@ function drawDesignMtx(design_mtx, labels) ax = subplot('Position', [16/24, 4/12, 7/24, 7/12]); imagesc(ax, corr_mat); - gfx.setTitle(ax, "Colinearity (r-values)"); + nla.gfx.setTitle(ax, "Colinearity (r-values)"); xlabel(' '); set(ax, 'XTick', 1:num_covariates, 'XTickLabel', labels); set(ax, 'YTick', 1:num_covariates, 'YTickLabel', labels); @@ -40,7 +40,8 @@ function drawDesignMtx(design_mtx, labels) for x = 1:num_covariates for y = 1:num_covariates - text(ax, x,y, num2str(corr_mat(y, x), '%.2f'), 'FontSize', 8, 'FontName', 'FixedWidth', 'HorizontalAlignment', 'center', 'Color', 'r'); + text(ax, x,y, num2str(corr_mat(y, x), '%.2f'), 'FontSize', 8, 'FontName', 'FixedWidth',... + 'HorizontalAlignment', 'center', 'Color', 'r'); end end end \ No newline at end of file diff --git a/+nla/+gfx/drawNetworkROIs.m b/+nla/+gfx/drawNetworkROIs.m index b8cc5af8..a0ef18c1 100755 --- a/+nla/+gfx/drawNetworkROIs.m +++ b/+nla/+gfx/drawNetworkROIs.m @@ -6,19 +6,21 @@ function drawNetworkROIs(net_atlas, ctx, mesh_alpha, ROI_radius, surface_parcels % ROI_radius: radius of spheres to display ROI centroids as % surface_parcels: Boolean value, whether to display surface parcels % (if supported by network atlas) instead of ROI centroids - import nla.* % required due to matlab package system quirks + + import nla.gfx.drawROIsOnCortex nla.gfx.ViewPos nla.gfx.BrainColorMode + %% Display figures - fig = gfx.createFigure(1550, 750); + fig = nla.gfx.createFigure(1550, 750); fig.Name = net_atlas.name; ax = subplot('Position',[.45,0.455,.53,.45]); - gfx.drawROIsOnCortex(ax, net_atlas, ctx, 1, ROI_radius, gfx.ViewPos.LAT, surface_parcels, gfx.BrainColorMode.DEFAULT_NETS); + drawROIsOnCortex(ax, net_atlas, ctx, 1, ROI_radius, ViewPos.LAT, surface_parcels, BrainColorMode.DEFAULT_NETS); ax = subplot('Position',[.45,0.005,.53,.45]); - gfx.drawROIsOnCortex(ax, net_atlas, ctx, 1, ROI_radius, gfx.ViewPos.MED, surface_parcels, gfx.BrainColorMode.DEFAULT_NETS); + drawROIsOnCortex(ax, net_atlas, ctx, 1, ROI_radius, ViewPos.MED, surface_parcels, BrainColorMode.DEFAULT_NETS); ax = subplot('Position',[.075,0.025,.35,.9]); - gfx.drawROIsOnCortex(ax, net_atlas, ctx, mesh_alpha, ROI_radius, gfx.ViewPos.DORSAL, surface_parcels, gfx.BrainColorMode.DEFAULT_NETS); + drawROIsOnCortex(ax, net_atlas, ctx, mesh_alpha, ROI_radius, ViewPos.DORSAL, surface_parcels, BrainColorMode.DEFAULT_NETS); light('Position',[0,100,100],'Style','local'); @@ -31,5 +33,5 @@ function drawNetworkROIs(net_atlas, ctx, mesh_alpha, ROI_radius, surface_parcels end hold(ax, 'off'); legend(ax); - gfx.hideAxes(ax); + nla.gfx.hideAxes(ax); end \ No newline at end of file diff --git a/+nla/+gfx/drawROIsOnCortex.m b/+nla/+gfx/drawROIsOnCortex.m index 75c0915d..c3a51b42 100755 --- a/+nla/+gfx/drawROIsOnCortex.m +++ b/+nla/+gfx/drawROIsOnCortex.m @@ -12,11 +12,11 @@ % color_mat: Nx3 array of color values, where is is number of ROIs, % networks, etc. depending on color_mode % ROI_final_pos: Nx3 matrix of positions ROIs were displayed at + + import nla.gfx.BrainColorMode nla.gfx.drawCortex - import nla.* % required due to matlab package system quirks - %% Calculate ROI locations - [mesh_l, mesh_r] = gfx.anatToMesh(net_atlas.anat, ctx, view_pos); + [mesh_l, mesh_r] = nla.gfx.anatToMesh(net_atlas.anat, ctx, view_pos); ROI_pos = [net_atlas.ROIs.pos]'; % find which node each ROI is nearest to [idx_l, dist_l] = knnsearch(net_atlas.anat.hemi_l.nodes, ROI_pos); @@ -33,30 +33,36 @@ % offset each ROI equally with its nearest node ROI_final_pos(ROI_idx, :) = ROI_pos(ROI_idx, :) + offset; - if color_mode == gfx.BrainColorMode.DEFAULT_NETS + if color_mode == BrainColorMode.DEFAULT_NETS ROI_color(ROI_idx, :) = net_atlas.nets(n).color; - elseif color_mode == gfx.BrainColorMode.COLOR_NETS + elseif color_mode == BrainColorMode.COLOR_NETS ROI_color(ROI_idx, :) = color_mat(n, :); - elseif color_mode == gfx.BrainColorMode.COLOR_ROIS + elseif color_mode == BrainColorMode.COLOR_ROIS ROI_color(ROI_idx, :) = color_mat(ROI_idx, :); end end end %% Draw ROIs + cortex - if color_mode ~= gfx.BrainColorMode.NONE && surface_parcels && ~islogical(net_atlas.parcels) && size(net_atlas.parcels.ctx_l, 1) == size(net_atlas.anat.hemi_l.nodes, 1) && size(net_atlas.parcels.ctx_r, 1) == size(net_atlas.anat.hemi_r.nodes, 1) - %% Display cortex colored with each vertex's associated ROI color + if color_mode ~= BrainColorMode.NONE &&... + surface_parcels &&... + ~islogical(net_atlas.parcels) &&... + size(net_atlas.parcels.ctx_l, 1) == size(net_atlas.anat.hemi_l.nodes, 1) &&... + size(net_atlas.parcels.ctx_r, 1) == size(net_atlas.anat.hemi_r.nodes, 1) + + % % Display cortex colored with each vertex's associated ROI color % Prepend the ROI color array with a 'zeroth' color, increment the % parcellization indices by one so this 'zeroth' color is used by % all parcels with an ROI index of zero (unassigned to ROI). ROI_color_with_missing = [0.5 0.5 0.5; ROI_color]; - gfx.drawCortex(ax, net_atlas.anat, ctx, mesh_alpha, view_pos, ROI_color_with_missing(net_atlas.parcels.ctx_l + 1, :), ROI_color_with_missing(net_atlas.parcels.ctx_r + 1, :)); + drawCortex(ax, net_atlas.anat, ctx, mesh_alpha, view_pos, ROI_color_with_missing(net_atlas.parcels.ctx_l + 1, :),... + ROI_color_with_missing(net_atlas.parcels.ctx_r + 1, :)); else - gfx.drawCortex(ax, net_atlas.anat, ctx, mesh_alpha, view_pos); - if color_mode ~= gfx.BrainColorMode.NONE + drawCortex(ax, net_atlas.anat, ctx, mesh_alpha, view_pos); + if color_mode ~= BrainColorMode.NONE for i = 1:net_atlas.numROIs() % render a sphere at each ROI location - gfx.drawSphere(ax, ROI_final_pos(i, :), ROI_color(i, :), ROI_radius); + nla.gfx.drawSphere(ax, ROI_final_pos(i, :), ROI_color(i, :), ROI_radius); end end end diff --git a/+nla/+gfx/drawSphere.m b/+nla/+gfx/drawSphere.m index ecab5ec4..bd98b502 100755 --- a/+nla/+gfx/drawSphere.m +++ b/+nla/+gfx/drawSphere.m @@ -4,10 +4,11 @@ % pos: x-y-z position, center of sphere % color: r-g-b or r-g-b-a color % radius: radius of sphere - import nla.* % required due to matlab package system quirks [x, y, z] = sphere(10); - obj = patch(surf2patch(radius * x + pos(1), radius * y + pos(2), radius * z + pos(3)), 'EdgeColor', color, 'FaceColor', color, 'EdgeAlpha', 0, 'FaceLighting', 'gouraud', 'AmbientStrength', 0.02); + obj = patch(surf2patch(radius * x + pos(1), radius * y + pos(2), radius * z + pos(3)), 'EdgeColor', color,... + 'FaceColor', color, 'EdgeAlpha', 0, 'FaceLighting', 'gouraud', 'AmbientStrength', 0.02); + obj.Annotation.LegendInformation.IconDisplayStyle = 'off'; end diff --git a/+nla/+gfx/findCircleFromTwoTangents.m b/+nla/+gfx/findCircleFromTwoTangents.m index 7770c74e..8fb6f153 100755 --- a/+nla/+gfx/findCircleFromTwoTangents.m +++ b/+nla/+gfx/findCircleFromTwoTangents.m @@ -8,18 +8,16 @@ % rad_a: angle from circle origin to tangent point a % rad_b: angle from circle origin to tangent point b - import nla.* % required due to matlab package system quirks - - origin(1) = gfx.findOriginXFromTwoTangents(a, b, rad_a, rad_b); + origin(1) = nla.gfx.findOriginXFromTwoTangents(a, b, rad_a, rad_b); % transpose axes and do the same thing a_2 = [a(2), a(1)]; b_2 = [b(2), b(1)]; rad_a_2 = (pi/2) - rad_a; rad_b_2 = (pi/2) - rad_b; - origin(2) = gfx.findOriginXFromTwoTangents(a_2, b_2, rad_a_2, rad_b_2); + origin(2) = nla.gfx.findOriginXFromTwoTangents(a_2, b_2, rad_a_2, rad_b_2); - rad_origin = [gfx.angleFrom(origin, a), gfx.angleFrom(origin, b)]; - radius = gfx.pointDist(a, origin); + rad_origin = [nla.gfx.angleFrom(origin, a), nla.gfx.angleFrom(origin, b)]; + radius = nla.gfx.pointDist(a, origin); end diff --git a/+nla/+gfx/genArcSegmentHandlePoorlyDefined.m b/+nla/+gfx/genArcSegmentHandlePoorlyDefined.m index 2e9197c3..be89cec6 100755 --- a/+nla/+gfx/genArcSegmentHandlePoorlyDefined.m +++ b/+nla/+gfx/genArcSegmentHandlePoorlyDefined.m @@ -10,12 +10,12 @@ % r1_center: starting position of arc, x-y coordinate % r2_center: ending position of arc, x-y coordinate % n: number of points to generate (more = smoother) - import nla.* % required due to matlab package system quirks + if arc_radius < 1e-10 arc = arc_origin; elseif abs(arc_origin_rad(1) - arc_origin_rad(2)) < 1e-10 arc = [r1_center; r2_center]; else - arc = gfx.genArcSegment(arc_origin, arc_origin_rad, arc_radius, n); + arc = nla.gfx.genArcSegment(arc_origin, arc_origin_rad, arc_radius, n); end end \ No newline at end of file diff --git a/+nla/+gfx/hideAxes.m b/+nla/+gfx/hideAxes.m index ff9f4cb1..1ac03671 100755 --- a/+nla/+gfx/hideAxes.m +++ b/+nla/+gfx/hideAxes.m @@ -1,7 +1,7 @@ function hideAxes(ax) %HIDEAXES Hide axes borders and tick marks % ax: axes to modify - import nla.* % required due to matlab package system quirks + ax.Box = 'off'; ax.XTick = []; ax.YTick = []; diff --git a/+nla/+gfx/valToColor.m b/+nla/+gfx/valToColor.m index 2c307b7e..309f0e69 100755 --- a/+nla/+gfx/valToColor.m +++ b/+nla/+gfx/valToColor.m @@ -1,7 +1,7 @@ function col = valToColor(x, llimit, ulimit, color_map) %VALTOCOLOR map values to color map - import nla.* % required due to matlab package system quirks - x_indexed = int32(ceil(helpers.normClipped(x, llimit, ulimit) * (size(color_map, 1) - 1))); + + x_indexed = int32(ceil(nla.helpers.normClipped(x, llimit, ulimit) * (size(color_map, 1) - 1))); col = ind2rgb(x_indexed, color_map); end diff --git a/+nla/+helpers/+git/commitString.m b/+nla/+helpers/+git/commitString.m index 8bc2d282..cc02ec74 100755 --- a/+nla/+helpers/+git/commitString.m +++ b/+nla/+helpers/+git/commitString.m @@ -1,10 +1,9 @@ function str = commitString(full) %COMMITSTRING Output current git commit as a string - import nla.* % required due to matlab package system quirks if ~exist('full', 'var'), full = false; end - cmd_str = sprintf('cd %s\ngit rev-parse %%s HEAD', findRootPath()); + cmd_str = sprintf('cd %s\ngit rev-parse %%s HEAD', nla.findRootPath()); [cmd_status, branch_name] = system(sprintf(cmd_str, '--abbrev-ref')); if cmd_status ~= 0 str = 'Failed to locate git repository'; diff --git a/+nla/+helpers/classToStructRecursive.m b/+nla/+helpers/classToStructRecursive.m index ea464318..b129f381 100755 --- a/+nla/+helpers/classToStructRecursive.m +++ b/+nla/+helpers/classToStructRecursive.m @@ -1,11 +1,10 @@ function s = classToStructRecursive(c) %CLASSTOSTRUCTRECURSIVE Convert classes to structs recursively - import nla.* % required due to matlab package system quirks if isa(c, 'cell') s = cell(size(c)); for i = 1:numel(c) - s{i} = helpers.classToStructRecursive(c{i}); + s{i} = nla.helpers.classToStructRecursive(c{i}); end return end @@ -18,7 +17,7 @@ if numel(c) > 1 s = cell(size(c)); for i = 1:numel(c) - s{i} = helpers.classToStructRecursive(c(i)); + s{i} = nla.helpers.classToStructRecursive(c(i)); end return end @@ -29,7 +28,7 @@ s = struct(); p = properties(c); for i = 1:length(p) - s.(p{i}) = helpers.classToStructRecursive(c.(p{i})); + s.(p{i}) = nla.helpers.classToStructRecursive(c.(p{i})); end else s = struct(c); diff --git a/+nla/+helpers/euclidianDistanceROIs.m b/+nla/+helpers/euclidianDistanceROIs.m index 38aeaa82..cb2a078c 100755 --- a/+nla/+helpers/euclidianDistanceROIs.m +++ b/+nla/+helpers/euclidianDistanceROIs.m @@ -1,5 +1,4 @@ function distances = euclidianDistanceROIs(network_atlas) - import nla.* % required due to matlab package system quirks pos_vec = [network_atlas.ROIs(1:network_atlas.numROIs()).pos]'; dist_comp_sum = zeros(network_atlas.numROIs(), network_atlas.numROIs()); diff --git a/+nla/+helpers/firstInstanceOfClass.m b/+nla/+helpers/firstInstanceOfClass.m index b4921e7a..5467cf91 100755 --- a/+nla/+helpers/firstInstanceOfClass.m +++ b/+nla/+helpers/firstInstanceOfClass.m @@ -1,6 +1,5 @@ function handle = firstInstanceOfClass(arr, class_name) %FIRSTINSTANCEOFCLASS find the first instance of a class in a cell vector - import nla.* % required due to matlab package system quirks handle = false; for i = 1:size(arr, 2) if strcmp(class(arr{i}), class_name) diff --git a/+nla/+helpers/normClipped.m b/+nla/+helpers/normClipped.m index bb8f364b..fe9a09fb 100755 --- a/+nla/+helpers/normClipped.m +++ b/+nla/+helpers/normClipped.m @@ -1,6 +1,5 @@ function normalized = normClipped(x, llimit, ulimit) %NORMCLIPPED clip something between two limits and normalize to 0-1 - import nla.* % required due to matlab package system quirks clipped = min(max(x, llimit), ulimit); normalized = (clipped - llimit) / (ulimit - llimit); end diff --git a/+nla/+helpers/permuteVector.m b/+nla/+helpers/permuteVector.m index 6359d4bc..550c72c3 100755 --- a/+nla/+helpers/permuteVector.m +++ b/+nla/+helpers/permuteVector.m @@ -1,5 +1,4 @@ function returned = permuteVector(vec) - import nla.* % required due to matlab package system quirks returned = vec(randperm(numel(vec))); end diff --git a/+nla/+helpers/rotationMatrix.m b/+nla/+helpers/rotationMatrix.m index ff67908b..ac57cdd7 100755 --- a/+nla/+helpers/rotationMatrix.m +++ b/+nla/+helpers/rotationMatrix.m @@ -1,7 +1,6 @@ function mat = rotationMatrix(dir, theta) % Generate a rotation matrix for the direction given % an angle (in radians). - import nla.* % required due to matlab package system quirks mat = zeros(3); switch dir diff --git a/+nla/+inputField/Behavior.m b/+nla/+inputField/Behavior.m index 07984760..2f992659 100755 --- a/+nla/+inputField/Behavior.m +++ b/+nla/+inputField/Behavior.m @@ -29,7 +29,6 @@ methods function obj = Behavior() - import nla.* % required due to matlab package system quirks obj.covariates_enabled = nla.inputField.CovariatesEnabled.ALL; obj.resetSelectedCol(); end @@ -42,31 +41,31 @@ function resetSelectedCol(obj) end function [w, h] = draw(obj, x, y, parent, fig) - import nla.* % required due to matlab package system quirks - + import nla.inputField.LABEL_H + obj.fig = fig; - table_w = max(parent.Position(3) - (inputField.LABEL_GAP * 4), 500); + table_w = max(parent.Position(3) - (nla.inputField.LABEL_GAP * 4), 500); table_h = 300; - label_gap = inputField.LABEL_GAP; - h = inputField.LABEL_H + label_gap + table_h + label_gap + inputField.LABEL_H + label_gap + inputField.LABEL_H; + label_gap = LABEL_GAP; + h = LABEL_H + label_gap + table_h + label_gap + LABEL_H + label_gap + LABEL_H; %% Create label if ~isgraphics(obj.label) obj.label = uilabel(parent); end obj.label.Text = 'Behavior:'; - label_w = inputField.widthOfString(obj.label.Text, inputField.LABEL_H); + label_w = nla.inputField.widthOfString(obj.label.Text, LABEL_H); obj.label.HorizontalAlignment = 'left'; - obj.label.Position = [x, y - inputField.LABEL_H, label_w + label_gap, inputField.LABEL_H]; + obj.label.Position = [x, y - LABEL_H, label_w + label_gap, LABEL_H]; %% Create button if ~isgraphics(obj.button) obj.button = uibutton(parent, 'push', 'ButtonPushedFcn', @(h,e)obj.buttonClickedCallback()); end button_w = 100; - obj.button.Position = [x + label_w + label_gap, y - inputField.LABEL_H, button_w, inputField.LABEL_H]; + obj.button.Position = [x + label_w + label_gap, y - LABEL_H, button_w, LABEL_H]; w = label_w + label_gap + button_w; @@ -77,45 +76,52 @@ function resetSelectedCol(obj) obj.table.SelectionType = 'column'; obj.table.ColumnName = {'None'}; obj.table.RowName = {}; - obj.table.Position = [x, y - (table_h + label_gap + inputField.LABEL_H), table_w, table_h]; + obj.table.Position = [x, y - (table_h + label_gap + LABEL_H), table_w, table_h]; end w2 = table_w; %% 'Set Behavior' button - [obj.button_set_bx, w3] = obj.createButton(obj.button_set_bx, 'Set Behavior', parent, x, y - h + inputField.LABEL_H + label_gap + inputField.LABEL_H, @(h,e)obj.button_set_bxClickedCallback()); + [obj.button_set_bx, w3] = obj.createButton(obj.button_set_bx, 'Set Behavior', parent, x,... + y - h + LABEL_H + label_gap + LABEL_H, @(h,e)obj.button_set_bxClickedCallback()); obj.button_set_bx.BackgroundColor = '#E3FDD8'; %% 'Add Covariate' button - [obj.button_add_cov, w4] = obj.createButton(obj.button_add_cov, 'Add Covariate', parent, x + w3 + label_gap, y - h + inputField.LABEL_H + label_gap + inputField.LABEL_H, @(h,e)obj.button_add_covClickedCallback()); + [obj.button_add_cov, w4] = obj.createButton(obj.button_add_cov, 'Add Covariate', parent, x + w3 + label_gap,... + y - h + LABEL_H + label_gap + LABEL_H, @(h,e)obj.button_add_covClickedCallback()); obj.button_add_cov.BackgroundColor = '#FADADD'; %% 'Remove Covariate' button - [obj.button_sub_cov, w5] = obj.createButton(obj.button_sub_cov, 'Remove Covariate', parent, x + w3 + label_gap + w4 + label_gap, y - h + inputField.LABEL_H + label_gap + inputField.LABEL_H, @(h,e)obj.button_sub_covClickedCallback()); + [obj.button_sub_cov, w5] = obj.createButton(obj.button_sub_cov, 'Remove Covariate', parent,... + x + w3 + label_gap + w4 + label_gap, y - h + LABEL_H + label_gap + LABEL_H,... + @(h,e)obj.button_sub_covClickedCallback()); obj.button_sub_cov.BackgroundColor = '#FADADD'; %% 'View Design Matrix' button - [obj.button_view_design_mtx, w6] = obj.createButton(obj.button_view_design_mtx, 'View Design Matrix', parent, x + w3 + label_gap + w4 + label_gap + w5 + label_gap, y - h + inputField.LABEL_H + label_gap + inputField.LABEL_H, @(h,e)obj.button_view_design_mtxClickedCallback()); + [obj.button_view_design_mtx, w6] = obj.createButton(obj.button_view_design_mtx, 'View Design Matrix', parent,... + x + w3 + label_gap + w4 + label_gap + w5 + label_gap, y - h + LABEL_H + label_gap + LABEL_H,... + @(h,e)obj.button_view_design_mtxClickedCallback()); %% 'Partial Variance' options obj.select_partial_variance_label = uilabel(parent); obj.select_partial_variance_label.HorizontalAlignment = 'left'; obj.select_partial_variance_label.Text = 'Remove shared variance from covariates:'; - select_partial_variance_label_w = inputField.widthOfString(obj.select_partial_variance_label.Text, inputField.LABEL_H); - obj.select_partial_variance_label.Position = [x, y - h, select_partial_variance_label_w, inputField.LABEL_H]; + select_partial_variance_label_w = nla.inputField.widthOfString(obj.select_partial_variance_label.Text, LABEL_H); + obj.select_partial_variance_label.Position = [x, y - h, select_partial_variance_label_w, LABEL_H]; select_partial_variance_w = 100; obj.select_partial_variance = uidropdown(parent); obj.genPartialVarianceOpts(); - obj.select_partial_variance.Position = [x + select_partial_variance_label_w + label_gap, y - h, select_partial_variance_w, inputField.LABEL_H]; - obj.select_partial_variance.Value = PartialVarianceType.NONE; + obj.select_partial_variance.Position = [x + select_partial_variance_label_w + label_gap, y - h,... + select_partial_variance_w, LABEL_H]; + obj.select_partial_variance.Value = nla.PartialVarianceType.NONE; w7 = x + select_partial_variance_label_w + label_gap + select_partial_variance_w; w = max([w, w2, w3 + label_gap + w4 + label_gap + w5 + label_gap + w6, w7]); end function undraw(obj) - import nla.* % required due to matlab package system quirks + if isgraphics(obj.button) delete(obj.button) end @@ -146,7 +152,7 @@ function undraw(obj) end function read(obj, input_struct) - import nla.* % required due to matlab package system quirks + obj.loadField(input_struct, 'behavior_filename'); obj.loadField(input_struct, 'behavior_full'); obj.loadField(input_struct, 'behavior'); @@ -161,24 +167,24 @@ function read(obj, input_struct) end if isfield(input_struct, 'partial_variance') - if obj.covariates_enabled == inputField.CovariatesEnabled.ALL + if obj.covariates_enabled == nla.inputField.CovariatesEnabled.ALL obj.select_partial_variance.Value = input_struct.partial_variance; - elseif obj.covariates_enabled == inputField.CovariatesEnabled.ONLY_FC - if input_struct.partial_variance == PartialVarianceType.NONE - obj.select_partial_variance.Value = PartialVarianceType.NONE; + elseif obj.covariates_enabled == nla.inputField.CovariatesEnabled.ONLY_FC + if input_struct.partial_variance == nla.PartialVarianceType.NONE + obj.select_partial_variance.Value = nla.PartialVarianceType.NONE; else - obj.select_partial_variance.Value = PartialVarianceType.ONLY_FC; + obj.select_partial_variance.Value = nla.PartialVarianceType.ONLY_FC; end end else - obj.select_partial_variance.Value = PartialVarianceType.NONE; + obj.select_partial_variance.Value = nla.PartialVarianceType.NONE; end obj.update(); end function [input_struct, error] = store(obj, input_struct) - import nla.* % required due to matlab package system quirks + input_struct.behavior_filename = obj.behavior_filename; input_struct.behavior_full = obj.behavior_full; input_struct.behavior = obj.behavior; @@ -192,23 +198,23 @@ function read(obj, input_struct) methods (Access = protected) function [button, w] = createButton(obj, button, label, parent, x, y, callback) - import nla.* % required due to matlab package system quirks %% Create button if ~isgraphics(button) button = uibutton(parent, 'push', 'ButtonPushedFcn', callback); end button_w = 100; - button.Position = [x, y - inputField.LABEL_H, button_w, inputField.LABEL_H]; + button.Position = [x, y - nla.inputField.LABEL_H, button_w, nla.inputField.LABEL_H]; button.Text = label; - button.Position(3) = inputField.widthOfString(button.Text, inputField.LABEL_H) + inputField.widthOfString(' ', inputField.LABEL_H + inputField.LABEL_GAP); + button.Position(3) = nla.inputField.widthOfString(button.Text, nla.inputField.LABEL_H) +... + inputField.widthOfString(' ', nla.inputField.LABEL_H + nla.inputField.LABEL_GAP); w = button.Position(3); end function buttonClickedCallback(obj, ~) - import nla.* % required due to matlab package system quirks + [file, path, idx] = uigetfile( ... {'*.txt;*.dat;*.csv', 'Text (*.txt,*.dat,*.csv)'; ... '*.xls;*.xlsb;*.xlsm;*.xlsx;*.xltm;*.xltx;*.ods', 'Spreadsheet (*.xls,*.xlsb,*.xlsm,*.xlsx,*.xltm,*.xltx,*.ods)'; ... @@ -218,7 +224,8 @@ function buttonClickedCallback(obj, ~) '*.html;*.xhtml;*.htm', 'HTML (*.html,*.xhtml,*.htm)'}, 'Select Behavior File'); if idx ~= 0 try - prog = uiprogressdlg(obj.fig, 'Title', 'Loading behavior file', 'Message', sprintf('Loading %s', file), 'Indeterminate', true); + prog = uiprogressdlg(obj.fig, 'Title', 'Loading behavior file', 'Message', sprintf('Loading %s', file),... + 'Indeterminate', true); drawnow; if idx == 5 @@ -258,7 +265,8 @@ function buttonClickedCallback(obj, ~) end if numel(non_numerical_indexes) > 0 could_not_load_some_columns = true; - could_not_load_str = [could_not_load_str sprintf("Columns %s could not be loaded due to containing non-numerical values.", nla.helpers.humanReadableList(labels(non_numerical_indexes)))]; + could_not_load_str = [could_not_load_str sprintf("Columns %s could not be loaded due to containing non-numerical values.",... + nla.helpers.humanReadableList(labels(non_numerical_indexes)))]; obj.behavior_full(:, non_numerical_indexes) = []; end @@ -270,7 +278,8 @@ function buttonClickedCallback(obj, ~) containsRepeatedNines = sum(repeatedNines & unusualValues) > 0; if sum(containsNaN) > 0 could_not_load_some_columns = true; - could_not_load_str = [could_not_load_str sprintf("Columns %s could not be loaded due to containing NaN values.", nla.helpers.humanReadableList(labels(containsNaN)))]; + could_not_load_str = [could_not_load_str sprintf("Columns %s could not be loaded due to containing NaN values.",... + nla.helpers.humanReadableList(labels(containsNaN)))]; colindexes = [1:numel(labels)]; obj.behavior_full(:, colindexes(containsNaN)) = []; end @@ -280,7 +289,8 @@ function buttonClickedCallback(obj, ~) end if sum(containsRepeatedNines) > 0 - uialert(obj.fig, sprintf("Columns %s contain unusual values of repeating 9's (99, 9999, etc).\nIf you are using these to mark missing values for subjects, you should either avoid using the offending columns, or remove the offending subjects from your behavioral file and functional connectivity before loading them in.", nla.helpers.humanReadableList(labels(containsRepeatedNines))), 'Warning', 'Icon', 'warning'); + uialert(obj.fig, sprintf("Columns %s contain unusual values of repeating 9's (99, 9999, etc).\nIf you are using these to mark missing values for subjects, you should either avoid using the offending columns, or remove the offending subjects from your behavioral file and functional connectivity before loading them in.",... + nla.helpers.humanReadableList(labels(containsRepeatedNines))), 'Warning', 'Icon', 'warning'); end obj.update(); @@ -292,11 +302,12 @@ function buttonClickedCallback(obj, ~) end function genPartialVarianceOpts(obj) - import nla.* % required due to matlab package system quirks - if obj.covariates_enabled == inputField.CovariatesEnabled.ALL + import nla.PartialVarianceType + + if obj.covariates_enabled == nla.inputField.CovariatesEnabled.ALL obj.select_partial_variance.Items = {'None', 'FC + BX', 'Only BX', 'Only FC'}; obj.select_partial_variance.ItemsData = [PartialVarianceType.NONE, PartialVarianceType.FCBX, PartialVarianceType.ONLY_BX, PartialVarianceType.ONLY_FC]; - elseif obj.covariates_enabled == inputField.CovariatesEnabled.ONLY_FC + elseif obj.covariates_enabled == nla.inputField.CovariatesEnabled.ONLY_FC obj.select_partial_variance.Items = {'None', 'Only FC'}; obj.select_partial_variance.ItemsData = [PartialVarianceType.NONE, PartialVarianceType.ONLY_FC]; else @@ -346,22 +357,22 @@ function button_sub_covClickedCallback(obj, ~) end function button_view_design_mtxClickedCallback(obj) - import nla.* % required due to matlab package system quirks + if ~islogical(obj.covariates_idx) labels = {obj.table.ColumnName{obj.covariates_idx}}; - gfx.drawDesignMtx(obj.covariates, labels); + nla.gfx.drawDesignMtx(obj.covariates, labels); end end function update(obj) - import nla.* % required due to matlab package system quirks + import nla.inputField.widthOfString nla.inputField.LABEL_H if islogical(obj.behavior_filename) obj.button.Text = 'Select'; else obj.button.Text = obj.behavior_filename; end - obj.button.Position(3) = inputField.widthOfString(obj.button.Text, inputField.LABEL_H) + inputField.widthOfString(' ', inputField.LABEL_H + inputField.LABEL_GAP); + obj.button.Position(3) = widthOfString(obj.button.Text, LABEL_H) + widthOfString(' ', LABEL_H + inputField.LABEL_GAP); removeStyle(obj.table); if islogical(obj.behavior_full) @@ -395,7 +406,7 @@ function update(obj) obj.table.Enable = 'on'; obj.button_set_bx.Enable = true; - enable_cov = (obj.covariates_enabled ~= inputField.CovariatesEnabled.NONE); + enable_cov = (obj.covariates_enabled ~= nla.inputField.CovariatesEnabled.NONE); obj.button_add_cov.Enable = enable_cov; obj.button_sub_cov.Enable = enable_cov; obj.button_view_design_mtx.Enable = enable_cov; diff --git a/+nla/+inputField/EdgeLevelMatrix.m b/+nla/+inputField/EdgeLevelMatrix.m index 3d6503dd..11cca2f0 100755 --- a/+nla/+inputField/EdgeLevelMatrix.m +++ b/+nla/+inputField/EdgeLevelMatrix.m @@ -14,7 +14,6 @@ methods function obj = EdgeLevelMatrix(name, disp_name, dimensions) - import nla.* % required due to matlab package system quirks obj.name = name; obj.disp_name = disp_name; obj.dimensions = dimensions; @@ -22,19 +21,18 @@ end function [w, h] = draw(obj, x, y, parent, fig) - import nla.* % required due to matlab package system quirks obj.fig = fig; - h = inputField.LABEL_H; - label_gap = inputField.LABEL_GAP; + h = nla.inputField.LABEL_H; + label_gap = nla.inputField.LABEL_GAP; %% Create label if ~isgraphics(obj.label) obj.label = uilabel(parent); end obj.label.Text = obj.disp_name; - label_w = inputField.widthOfString(obj.label.Text, h); + label_w = nla.inputField.widthOfString(obj.label.Text, h); obj.label.HorizontalAlignment = 'left'; obj.label.Position = [x, y - h, label_w + label_gap, h]; @@ -49,7 +47,6 @@ end function undraw(obj) - import nla.* % required due to matlab package system quirks if isgraphics(obj.label) delete(obj.label) end @@ -59,7 +56,6 @@ function undraw(obj) end function read(obj, input_struct) - import nla.* % required due to matlab package system quirks if isfield(input_struct, [obj.name '_unordered']) obj.matrix = input_struct.([obj.name '_unordered']); else @@ -76,29 +72,34 @@ function read(obj, input_struct) end function [input_struct, error] = store(obj, input_struct) - import nla.* % required due to matlab package system quirks if ~islogical(obj.matrix) input_struct.([obj.name '_unordered']) = obj.matrix; end error = false; - if isfield(input_struct, 'net_atlas') && isfield(input_struct, 'perm_count') && ~islogical(input_struct.net_atlas) && ~islogical(obj.matrix) + if isfield(input_struct, 'net_atlas') &&... + isfield(input_struct, 'perm_count') &&... + ~islogical(input_struct.net_atlas) &&... + ~islogical(obj.matrix) + dims = size(obj.matrix); - desired_dims = obj.substituteDims(obj.dimensions, input_struct.net_atlas.numROIs, nla.helpers.triNum(input_struct.net_atlas.numROIs - 1), input_struct.perm_count); + desired_dims = obj.substituteDims(obj.dimensions, input_struct.net_atlas.numROIs,... + nla.helpers.triNum(input_struct.net_atlas.numROIs - 1), input_struct.perm_count); if numel(dims) == numel(desired_dims) && all(dims == desired_dims) - if obj.dimensions(1) == inputField.DimensionType.NROIPAIRS - obj.matrix_ordered = TriMatrix(input_struct.net_atlas.numROIs); + if obj.dimensions(1) == nla.inputField.DimensionType.NROIPAIRS + obj.matrix_ordered = nla.TriMatrix(input_struct.net_atlas.numROIs); obj.matrix_ordered.v = obj.matrix; else - obj.matrix_ordered = TriMatrix(input_struct.net_atlas.numROIs); + obj.matrix_ordered = nla.TriMatrix(input_struct.net_atlas.numROIs); obj.matrix_ordered.v = obj.matrix; end input_struct.(obj.name) = obj.matrix_ordered; else - error = sprintf('Matrix does not match network atlas/permutation dimensions (should be %s, is %s)!', join(string(desired_dims), "x"), join(string(dims), "x")); + error = sprintf('Matrix does not match network atlas/permutation dimensions (should be %s, is %s)!',... + join(string(desired_dims), "x"), join(string(dims), "x")); end else error = 'Something has gone badly wrong with inputField.EdgeLevelMatrix, please report this on the NLA Github or contact an author'; @@ -106,7 +107,7 @@ function read(obj, input_struct) end function selectFile(obj, ~) - import nla.* % required due to matlab package system quirks + [fname, path, idx] = uigetfile({'*.mat', sprintf('Matrix (%s) (*.mat)', obj.dimsAsString())}, 'Select Input Matrix'); if idx == 1 prog = uiprogressdlg(obj.fig, 'Title', sprintf('Loading %s', obj.disp_name), 'Message', sprintf('Loading %s', fname), 'Indeterminate', true); @@ -140,7 +141,7 @@ function selectFile(obj, ~) end function update(obj) - import nla.* % required due to matlab package system quirks + if islogical(obj.matrix) obj.select_file_button.Text = 'Select'; else @@ -149,18 +150,20 @@ function update(obj) nstr = join(string(size(obj.matrix)), 'x'); obj.select_file_button.Text = [sprintf('Matrix (%s)', nstr)]; end - obj.select_file_button.Position(3) = inputField.widthOfString(obj.select_file_button.Text, inputField.LABEL_H) + inputField.widthOfString(' ', inputField.LABEL_H + inputField.LABEL_GAP); + obj.select_file_button.Position(3) = nla.inputField.widthOfString(obj.select_file_button.Text, nla.inputField.LABEL_H) +... + nla.inputField.widthOfString(' ', nla.inputField.LABEL_H + nla.inputField.LABEL_GAP); end function dims = substituteDims(~, input_dims, nrois, nroipairs, nperms) - import nla.* % required due to matlab package system quirks + import nla.inputField.DimensionType + for i = [1:numel(input_dims)] dim = input_dims(i); - if dim == inputField.DimensionType.NROIS + if dim == DimensionType.NROIS dims(i) = nrois; - elseif dim == inputField.DimensionType.NROIPAIRS + elseif dim == DimensionType.NROIPAIRS dims(i) = nroipairs; - elseif dim == inputField.DimensionType.NPERMS + elseif dim == DimensionType.NPERMS dims(i) = nperms; else if isstring(nrois) diff --git a/+nla/+inputField/Integer.m b/+nla/+inputField/Integer.m index ce4a2aee..c03d6522 100755 --- a/+nla/+inputField/Integer.m +++ b/+nla/+inputField/Integer.m @@ -1,7 +1,6 @@ classdef Integer < nla.inputField.Number methods function [w, h] = draw(obj, x, y, parent, fig) - import nla.* % required due to matlab package system quirks [w, h] = draw@nla.inputField.Number(obj, x, y, parent, fig); obj.field.RoundFractionalValues = 'on'; end diff --git a/+nla/+inputField/NetworkAtlas.m b/+nla/+inputField/NetworkAtlas.m index aad9cec6..7aa59d97 100755 --- a/+nla/+inputField/NetworkAtlas.m +++ b/+nla/+inputField/NetworkAtlas.m @@ -20,33 +20,33 @@ methods function obj = NetworkAtlas() - import nla.* % required due to matlab package system quirks obj.satisfied = false; end function [w, h] = draw(obj, x, y, parent, fig) - import nla.* % required due to matlab package system quirks - + import nla.inputField.LABEL_GAP nla.inputField.LABEL_H nla.inputFieldwidthOfString + import nla.gfx.MeshType + obj.fig = fig; - label_gap = inputField.LABEL_GAP; - h = inputField.LABEL_H; + label_gap = LABEL_GAP; + h = LABEL_H; %% Create label if ~isgraphics(obj.label) obj.label = uilabel(parent); end obj.label.Text = 'Network atlas:'; - label_w = inputField.widthOfString(obj.label.Text, inputField.LABEL_H); + label_w = widthOfString(obj.label.Text, LABEL_H); obj.label.HorizontalAlignment = 'left'; - obj.label.Position = [x, y - inputField.LABEL_H, label_w + label_gap, inputField.LABEL_H]; + obj.label.Position = [x, y - LABEL_H, label_w + label_gap, LABEL_H]; %% Create button if ~isgraphics(obj.button) obj.button = uibutton(parent, 'push', 'ButtonPushedFcn', @(h,e)obj.buttonClickedCallback()); end button_w = 100; - obj.button.Position = [x + label_w + label_gap, y - inputField.LABEL_H, button_w, inputField.LABEL_H]; + obj.button.Position = [x + label_w + label_gap, y - LABEL_H, button_w, LABEL_H]; %% Mesh inflation selector if ~isgraphics(obj.inflation_label) @@ -54,16 +54,16 @@ obj.inflation_label.HorizontalAlignment = 'right'; obj.inflation_label.Text = 'Inflation: '; end - inflation_label_w = inputField.widthOfString(obj.inflation_label.Text, inputField.LABEL_H); - obj.inflation_label.Position = [0, y - inputField.LABEL_H, inflation_label_w, inputField.LABEL_H]; + inflation_label_w = widthOfString(obj.inflation_label.Text, LABEL_H); + obj.inflation_label.Position = [0, y - LABEL_H, inflation_label_w, LABEL_H]; inflation_dropdown_w = 55; if ~isgraphics(obj.inflation_dropdown) obj.inflation_dropdown = uidropdown(parent); obj.inflation_dropdown.Items = ["Std", "Inf", "VInf"]; - obj.inflation_dropdown.ItemsData = {gfx.MeshType.STD, gfx.MeshType.INF, gfx.MeshType.VINF}; + obj.inflation_dropdown.ItemsData = {MeshType.STD, MeshType.INF, MeshType.VINF}; end - obj.inflation_dropdown.Position = [0, y - inputField.LABEL_H, inflation_dropdown_w, inputField.LABEL_H]; + obj.inflation_dropdown.Position = [0, y - LABEL_H, inflation_dropdown_w, LABEL_H]; %% 'View as surface parcel' checkbox checkbox_surface_parcels_w = 108; @@ -71,21 +71,23 @@ obj.checkbox_surface_parcels = uicheckbox(parent); obj.checkbox_surface_parcels.Text = ' Surface parcels'; end - obj.checkbox_surface_parcels.Position = [0, y - inputField.LABEL_H, checkbox_surface_parcels_w, inputField.LABEL_H]; + obj.checkbox_surface_parcels.Position = [0, y - LABEL_H, checkbox_surface_parcels_w, LABEL_H]; %% Create view button if ~isgraphics(obj.button_view_net_atlas) - obj.button_view_net_atlas = uibutton(parent, 'push', 'ButtonPushedFcn', @(h,e)obj.buttonViewNetAtlasClickedCallback()); + obj.button_view_net_atlas = uibutton(parent, 'push', 'ButtonPushedFcn',... + @(h,e)obj.buttonViewNetAtlasClickedCallback()); end button_view_net_atlas_w = 45; obj.button_view_net_atlas.Text = 'View'; - obj.button_view_net_atlas.Position = [0, y - inputField.LABEL_H, button_view_net_atlas_w, inputField.LABEL_H]; + obj.button_view_net_atlas.Position = [0, y - LABEL_H, button_view_net_atlas_w, LABEL_H]; - w = label_w + label_gap + button_w + label_gap + checkbox_surface_parcels_w + label_gap + button_view_net_atlas_w; + w = label_w + label_gap + button_w + label_gap + checkbox_surface_parcels_w + label_gap +... + button_view_net_atlas_w; end function undraw(obj) - import nla.* % required due to matlab package system quirks + if isgraphics(obj.button) delete(obj.button) end @@ -107,7 +109,7 @@ function undraw(obj) end function read(obj, input_struct) - import nla.* % required due to matlab package system quirks + obj.loadField(input_struct, 'net_atlas'); if isfield(input_struct, 'surface_parcels') @@ -120,7 +122,6 @@ function read(obj, input_struct) end function [input_struct, error] = store(obj, input_struct) - import nla.* % required due to matlab package system quirks input_struct.net_atlas = obj.net_atlas; input_struct.surface_parcels = obj.checkbox_surface_parcels.Value; error = false; @@ -129,18 +130,18 @@ function read(obj, input_struct) methods (Access = protected) function buttonClickedCallback(obj, ~) - import nla.* % required due to matlab package system quirks [file, path, idx] = uigetfile({'*.mat', 'Network Atlas (*.mat)'}, 'Select Network Atlas'); if idx ~= 0 % Load file to net_atlas, depending on the filetype. Right now % it only supports .mat network atlases but if another file % type were added, it would be handled under idx == 2 and so on if idx == 1 - prog = uiprogressdlg(obj.fig, 'Title', 'Loading network atlas', 'Message', sprintf('Loading %s', file), 'Indeterminate', true); + prog = uiprogressdlg(obj.fig, 'Title', 'Loading network atlas', 'Message',... + sprintf('Loading %s', file), 'Indeterminate', true); drawnow; try - obj.net_atlas = NetworkAtlas([path file]); + obj.net_atlas = nla.NetworkAtlas([path file]); if ~islogical(obj.net_atlas.parcels) obj.checkbox_surface_parcels.Value = true; end @@ -156,17 +157,21 @@ function buttonClickedCallback(obj, ~) end function buttonViewNetAtlasClickedCallback(obj) - import nla.* % required due to matlab package system quirks - prog = uiprogressdlg(obj.fig, 'Title', 'Generating visualization', 'Message', 'Generating net atlas visualization', 'Indeterminate', true); + prog = uiprogressdlg(obj.fig, 'Title', 'Generating visualization', 'Message',... + 'Generating net atlas visualization', 'Indeterminate', true); drawnow; mesh_inf = obj.inflation_dropdown.Value; - if obj.checkbox_surface_parcels.Value && ~islogical(obj.net_atlas.parcels) && size(obj.net_atlas.parcels.ctx_l, 1) == size(obj.net_atlas.anat.hemi_l.nodes, 1) && size(obj.net_atlas.parcels.ctx_r, 1) == size(obj.net_atlas.anat.hemi_r.nodes, 1) - gfx.drawNetworkROIs(obj.net_atlas, mesh_inf, 1, 4, true); + if obj.checkbox_surface_parcels.Value &&... + ~islogical(obj.net_atlas.parcels) &&... + size(obj.net_atlas.parcels.ctx_l, 1) == size(obj.net_atlas.anat.hemi_l.nodes, 1) &&... + size(obj.net_atlas.parcels.ctx_r, 1) == size(obj.net_atlas.anat.hemi_r.nodes, 1) + + nla.gfx.drawNetworkROIs(obj.net_atlas, mesh_inf, 1, 4, true); else - gfx.drawNetworkROIs(obj.net_atlas, mesh_inf, 0.8, 4, false); + nla.gfx.drawNetworkROIs(obj.net_atlas, mesh_inf, 0.8, 4, false); end close(prog); @@ -174,8 +179,8 @@ function buttonViewNetAtlasClickedCallback(obj) end function update(obj) - import nla.* % required due to matlab package system quirks - + import nla.inputField.widthOfString nla.inputField.LABEL_GAP nla.inputField.LABEL_H + if islogical(obj.net_atlas) obj.satisfied = false; obj.button.Text = 'Select'; @@ -193,13 +198,17 @@ function update(obj) obj.checkbox_surface_parcels.Value = false; end end - obj.button.Position(3) = inputField.widthOfString(obj.button.Text, inputField.LABEL_H) + inputField.widthOfString(' ', inputField.LABEL_H + inputField.LABEL_GAP); + obj.button.Position(3) = widthOfString(obj.button.Text, LABEL_H) + widthOfString(' ', LABEL_H + LABEL_GAP); - obj.inflation_label.Position(1) = obj.button.Position(1) + obj.button.Position(3) + inputField.LABEL_GAP; - obj.inflation_dropdown.Position(1) = obj.button.Position(1) + obj.button.Position(3) + inputField.LABEL_GAP + obj.inflation_label.Position(3); + obj.inflation_label.Position(1) = obj.button.Position(1) + obj.button.Position(3) + LABEL_GAP; + obj.inflation_dropdown.Position(1) = obj.button.Position(1) + obj.button.Position(3) + LABEL_GAP +... + obj.inflation_label.Position(3); - obj.checkbox_surface_parcels.Position(1) = obj.button.Position(1) + obj.button.Position(3) + inputField.LABEL_GAP + obj.inflation_label.Position(3) + obj.inflation_dropdown.Position(3) + inputField.LABEL_GAP; - obj.button_view_net_atlas.Position(1) = obj.button.Position(1) + obj.button.Position(3) + inputField.LABEL_GAP + obj.inflation_label.Position(3) + obj.inflation_dropdown.Position(3) + inputField.LABEL_GAP + obj.checkbox_surface_parcels.Position(3) + inputField.LABEL_GAP; + obj.checkbox_surface_parcels.Position(1) = obj.button.Position(1) + obj.button.Position(3) + LABEL_GAP +... + obj.inflation_label.Position(3) + obj.inflation_dropdown.Position(3) + LABEL_GAP; + obj.button_view_net_atlas.Position(1) = obj.button.Position(1) + obj.button.Position(3) + LABEL_GAP +... + obj.inflation_label.Position(3) + obj.inflation_dropdown.Position(3) + LABEL_GAP +... + obj.checkbox_surface_parcels.Position(3) + LABEL_GAP; end end end diff --git a/+nla/+inputField/NetworkAtlasFuncConn.m b/+nla/+inputField/NetworkAtlasFuncConn.m index 487638af..583ea0a3 100755 --- a/+nla/+inputField/NetworkAtlasFuncConn.m +++ b/+nla/+inputField/NetworkAtlasFuncConn.m @@ -25,33 +25,33 @@ methods function obj = NetworkAtlasFuncConn() - import nla.* % required due to matlab package system quirks obj.satisfied = false; end function [w, h] = draw(obj, x, y, parent, fig) - import nla.* % required due to matlab package system quirks - + import nla.inputField.LABEL_GAP nla.inputField.LABEL_H + import nla.gfx.MeshType + obj.fig = fig; - label_gap = inputField.LABEL_GAP; - h = inputField.LABEL_H * 2 + label_gap; + label_gap = LABEL_GAP; + h = LABEL_H * 2 + label_gap; %% Create label if ~isgraphics(obj.label) obj.label = uilabel(parent); end obj.label.Text = 'Network atlas:'; - label_w = inputField.widthOfString(obj.label.Text, inputField.LABEL_H); + label_w = nla.inputField.widthOfString(obj.label.Text, LABEL_H); obj.label.HorizontalAlignment = 'left'; - obj.label.Position = [x, y - inputField.LABEL_H, label_w + label_gap, inputField.LABEL_H]; + obj.label.Position = [x, y - LABEL_H, label_w + label_gap, LABEL_H]; %% Create button if ~isgraphics(obj.button) obj.button = uibutton(parent, 'push', 'ButtonPushedFcn', @(h,e)obj.buttonClickedCallback()); end button_w = 100; - obj.button.Position = [x + label_w + label_gap, y - inputField.LABEL_H, button_w, inputField.LABEL_H]; + obj.button.Position = [x + label_w + label_gap, y - LABEL_H, button_w, LABEL_H]; %% Mesh inflation selector if ~isgraphics(obj.inflation_label) @@ -59,16 +59,16 @@ obj.inflation_label.HorizontalAlignment = 'right'; obj.inflation_label.Text = 'Inflation: '; end - inflation_label_w = inputField.widthOfString(obj.inflation_label.Text, inputField.LABEL_H); - obj.inflation_label.Position = [0, y - inputField.LABEL_H, inflation_label_w, inputField.LABEL_H]; + inflation_label_w = nla.inputField.widthOfString(obj.inflation_label.Text, LABEL_H); + obj.inflation_label.Position = [0, y - LABEL_H, inflation_label_w, LABEL_H]; inflation_dropdown_w = 55; if ~isgraphics(obj.inflation_dropdown) obj.inflation_dropdown = uidropdown(parent); obj.inflation_dropdown.Items = ["Std", "Inf", "VInf"]; - obj.inflation_dropdown.ItemsData = {gfx.MeshType.STD, gfx.MeshType.INF, gfx.MeshType.VINF}; + obj.inflation_dropdown.ItemsData = {MeshType.STD, MeshType.INF, MeshType.VINF}; end - obj.inflation_dropdown.Position = [0, y - inputField.LABEL_H, inflation_dropdown_w, inputField.LABEL_H]; + obj.inflation_dropdown.Position = [0, y - LABEL_H, inflation_dropdown_w, LABEL_H]; %% 'View as surface parcel' checkbox checkbox_surface_parcels_w = 108; @@ -76,15 +76,16 @@ obj.checkbox_surface_parcels = uicheckbox(parent); obj.checkbox_surface_parcels.Text = ' Surface parcels'; end - obj.checkbox_surface_parcels.Position = [0, y - inputField.LABEL_H, checkbox_surface_parcels_w, inputField.LABEL_H]; + obj.checkbox_surface_parcels.Position = [0, y - LABEL_H, checkbox_surface_parcels_w, LABEL_H]; %% Create view button if ~isgraphics(obj.button_view_net_atlas) - obj.button_view_net_atlas = uibutton(parent, 'push', 'ButtonPushedFcn', @(h,e)obj.buttonViewNetAtlasClickedCallback()); + obj.button_view_net_atlas = uibutton(parent, 'push', 'ButtonPushedFcn',... + @(h,e)obj.buttonViewNetAtlasClickedCallback()); end button_view_net_atlas_w = 45; obj.button_view_net_atlas.Text = 'View'; - obj.button_view_net_atlas.Position = [0, y - inputField.LABEL_H, button_view_net_atlas_w, inputField.LABEL_H]; + obj.button_view_net_atlas.Position = [0, y - LABEL_H, button_view_net_atlas_w, LABEL_H]; w = label_w + label_gap + button_w + label_gap + checkbox_surface_parcels_w + label_gap + button_view_net_atlas_w; @@ -93,16 +94,16 @@ obj.label2 = uilabel(parent); end obj.label2.Text = 'Functional connectivity:'; - label2_w = inputField.widthOfString(obj.label2.Text, inputField.LABEL_H); + label2_w = nla.inputField.widthOfString(obj.label2.Text, LABEL_H); obj.label2.HorizontalAlignment = 'left'; - obj.label2.Position = [x, y - h, label2_w + label_gap, inputField.LABEL_H]; + obj.label2.Position = [x, y - h, label2_w + label_gap, LABEL_H]; %% Create button2 if ~isgraphics(obj.button2) obj.button2 = uibutton(parent, 'push', 'ButtonPushedFcn', @(h,e)obj.button2ClickedCallback()); end button2_w = 100; - obj.button2.Position = [x + label2_w + label_gap, y - h, button2_w, inputField.LABEL_H]; + obj.button2.Position = [x + label2_w + label_gap, y - h, button2_w, LABEL_H]; %% Create view button if ~isgraphics(obj.button_view_fc_avg) @@ -110,14 +111,15 @@ end button_view_fc_avg_w = 45; obj.button_view_fc_avg.Text = 'View'; - obj.button_view_fc_avg.Position = [x + label2_w + label_gap + button2_w + label_gap, y - h, button_view_fc_avg_w, inputField.LABEL_H]; + obj.button_view_fc_avg.Position = [x + label2_w + label_gap + button2_w + label_gap, y - h,... + button_view_fc_avg_w, LABEL_H]; w2 = label2_w + label_gap + button2_w + label_gap + button_view_fc_avg_w; w = max(w, w2); end function undraw(obj) - import nla.* % required due to matlab package system quirks + if isgraphics(obj.button) delete(obj.button) end @@ -148,7 +150,7 @@ function undraw(obj) end function read(obj, input_struct) - import nla.* % required due to matlab package system quirks + obj.loadField(input_struct, 'net_atlas'); obj.loadField(input_struct, 'func_conn'); obj.loadField(input_struct, 'func_conn_unordered'); @@ -163,7 +165,7 @@ function read(obj, input_struct) end function [input_struct, error] = store(obj, input_struct) - import nla.* % required due to matlab package system quirks + input_struct.net_atlas = obj.net_atlas; input_struct.func_conn_unordered = obj.func_conn_unordered; input_struct.func_conn = obj.func_conn; @@ -174,18 +176,19 @@ function read(obj, input_struct) methods (Access = protected) function buttonClickedCallback(obj, ~) - import nla.* % required due to matlab package system quirks + [file, path, idx] = uigetfile({'*.mat', 'Network Atlas (*.mat)'}, 'Select Network Atlas'); if idx ~= 0 % Load file to net_atlas, depending on the filetype. Right now % it only supports .mat network atlases but if another file % type were added, it would be handled under idx == 2 and so on if idx == 1 - prog = uiprogressdlg(obj.fig, 'Title', 'Loading network atlas', 'Message', sprintf('Loading %s', file), 'Indeterminate', true); + prog = uiprogressdlg(obj.fig, 'Title', 'Loading network atlas', 'Message',... + sprintf('Loading %s', file), 'Indeterminate', true); drawnow; try - obj.net_atlas = NetworkAtlas([path file]); + obj.net_atlas = nla.NetworkAtlas([path file]); if ~islogical(obj.net_atlas.parcels) obj.checkbox_surface_parcels.Value = true; end @@ -201,10 +204,10 @@ function buttonClickedCallback(obj, ~) end function button2ClickedCallback(obj, ~) - import nla.* % required due to matlab package system quirks [file, path, idx] = uigetfile({'*.mat', 'Functional connectivity matrix (*.mat)'}, 'Select Functional Connectivity Matrix'); if idx == 1 - prog = uiprogressdlg(obj.fig, 'Title', 'Loading functional connectivity data', 'Message', sprintf('Loading %s', file), 'Indeterminate', true); + prog = uiprogressdlg(obj.fig, 'Title', 'Loading functional connectivity data', 'Message',... + sprintf('Loading %s', file), 'Indeterminate', true); drawnow; fc_data = load([path file]); @@ -239,7 +242,7 @@ function button2ClickedCallback(obj, ~) if all(abs(obj.func_conn_unordered(:)) <= 1) sel = uiconfirm(obj.fig, sprintf('Fisher Z transform functional connectivity data?\n(If you have provided R-values)'), 'Fisher Z transform?'); if strcmp(sel, 'Ok') - obj.func_conn_unordered = fisherR2Z(obj.func_conn_unordered); + obj.func_conn_unordered = nla.fisherR2Z(obj.func_conn_unordered); end end @@ -253,17 +256,20 @@ function button2ClickedCallback(obj, ~) end function buttonViewNetAtlasClickedCallback(obj) - import nla.* % required due to matlab package system quirks prog = uiprogressdlg(obj.fig, 'Title', 'Generating visualization', 'Message', 'Generating net atlas visualization', 'Indeterminate', true); drawnow; mesh_inf = obj.inflation_dropdown.Value; - if obj.checkbox_surface_parcels.Value && ~islogical(obj.net_atlas.parcels) && size(obj.net_atlas.parcels.ctx_l, 1) == size(obj.net_atlas.anat.hemi_l.nodes, 1) && size(obj.net_atlas.parcels.ctx_r, 1) == size(obj.net_atlas.anat.hemi_r.nodes, 1) - gfx.drawNetworkROIs(obj.net_atlas, mesh_inf, 1, 4, true); + if obj.checkbox_surface_parcels.Value &&... + ~islogical(obj.net_atlas.parcels) &&... + size(obj.net_atlas.parcels.ctx_l, 1) == size(obj.net_atlas.anat.hemi_l.nodes, 1) &&... + size(obj.net_atlas.parcels.ctx_r, 1) == size(obj.net_atlas.anat.hemi_r.nodes, 1) + + nla.gfx.drawNetworkROIs(obj.net_atlas, mesh_inf, 1, 4, true); else - gfx.drawNetworkROIs(obj.net_atlas, mesh_inf, 0.8, 4, false); + nla.gfx.drawNetworkROIs(obj.net_atlas, mesh_inf, 0.8, 4, false); end close(prog); @@ -271,16 +277,17 @@ function buttonViewNetAtlasClickedCallback(obj) end function buttonViewFCAvgClickedCallback(obj) - import nla.* % required due to matlab package system quirks - prog = uiprogressdlg(obj.fig, 'Title', 'Generating figure', 'Message', 'Generating FC average figure', 'Indeterminate', true); + prog = uiprogressdlg(obj.fig, 'Title', 'Generating figure', 'Message', 'Generating FC average figure',... + 'Indeterminate', true); drawnow; %% Visualize average functional connectivity values fc_avg = copy(obj.func_conn); fc_avg.v = mean(fc_avg.v, 2); fig_l = nla.gfx.createFigure(); - matrix_plot = nla.gfx.plots.MatrixPlot(fig_l, 'FC Average (Fisher Z(R))', fc_avg, obj.net_atlas.nets, gfx.FigSize.LARGE); + matrix_plot = nla.gfx.plots.MatrixPlot(fig_l, 'FC Average (Fisher Z(R))', fc_avg, obj.net_atlas.nets,... + nla.gfx.FigSize.LARGE); fig_l.Position(3) = matrix_plot.image_dimensions("image_width"); fig_l.Position(4) = matrix_plot.image_dimensions("image_height"); matrix_plot.displayImage(); @@ -290,24 +297,24 @@ function buttonViewFCAvgClickedCallback(obj) end function updateFuncConn(obj) - import nla.* % required due to matlab package system quirks obj.func_conn = false; obj.satisfied = false; if ~islogical(obj.net_atlas) && ~islogical(obj.func_conn_unordered) dims = size(obj.func_conn_unordered); if numel(dims) == 3 && dims(1) == dims(2) && dims(1) == obj.net_atlas.numROIs - obj.func_conn = TriMatrix(obj.func_conn_unordered(obj.net_atlas.ROI_order, obj.net_atlas.ROI_order, :)); + obj.func_conn = nla.TriMatrix(obj.func_conn_unordered(obj.net_atlas.ROI_order, obj.net_atlas.ROI_order, :)); obj.satisfied = true; else - uialert(obj.fig, 'Network atlas and functional connectivity matrix do not match!', 'Mismatched input files', 'Icon', 'warning'); + uialert(obj.fig, 'Network atlas and functional connectivity matrix do not match!',... + 'Mismatched input files', 'Icon', 'warning'); end end end function update(obj) - import nla.* % required due to matlab package system quirks - + import nla.inputField.widthOfString nla.inputField.LABEL_H nla.inputField.LABEL_GAP + obj.updateFuncConn(); if islogical(obj.net_atlas) @@ -325,14 +332,18 @@ function update(obj) obj.checkbox_surface_parcels.Value = false; end end - obj.button.Position(3) = inputField.widthOfString(obj.button.Text, inputField.LABEL_H) + inputField.widthOfString(' ', inputField.LABEL_H + inputField.LABEL_GAP); + obj.button.Position(3) = widthOfString(obj.button.Text, LABEL_H) + widthOfString(' ', LABEL_H + LABEL_GAP); - obj.inflation_label.Position(1) = obj.button.Position(1) + obj.button.Position(3) + inputField.LABEL_GAP; - obj.inflation_dropdown.Position(1) = obj.button.Position(1) + obj.button.Position(3) + inputField.LABEL_GAP + obj.inflation_label.Position(3); + obj.inflation_label.Position(1) = obj.button.Position(1) + obj.button.Position(3) + LABEL_GAP; + obj.inflation_dropdown.Position(1) = obj.button.Position(1) + obj.button.Position(3) + LABEL_GAP +... + obj.inflation_label.Position(3); - obj.checkbox_surface_parcels.Position(1) = obj.button.Position(1) + obj.button.Position(3) + inputField.LABEL_GAP + obj.inflation_label.Position(3) + obj.inflation_dropdown.Position(3) + inputField.LABEL_GAP; - obj.button_view_net_atlas.Position(1) = obj.button.Position(1) + obj.button.Position(3) + inputField.LABEL_GAP + obj.inflation_label.Position(3) + obj.inflation_dropdown.Position(3) + inputField.LABEL_GAP + obj.checkbox_surface_parcels.Position(3) + inputField.LABEL_GAP; + obj.checkbox_surface_parcels.Position(1) = obj.button.Position(1) + obj.button.Position(3) + LABEL_GAP +... + obj.inflation_label.Position(3) + obj.inflation_dropdown.Position(3) + LABEL_GAP; + obj.button_view_net_atlas.Position(1) = obj.button.Position(1) + obj.button.Position(3) + LABEL_GAP +... + obj.inflation_label.Position(3) + obj.inflation_dropdown.Position(3) + LABEL_GAP +... + obj.checkbox_surface_parcels.Position(3) + LABEL_GAP; if islogical(obj.func_conn_unordered) obj.button2.Text = 'Select'; @@ -340,14 +351,14 @@ function update(obj) nstr = join(string(size(obj.func_conn_unordered)), 'x'); obj.button2.Text = [sprintf('Matrix (%s)', nstr)]; end - obj.button2.Position(3) = inputField.widthOfString(obj.button2.Text, inputField.LABEL_H) + inputField.widthOfString(' ', inputField.LABEL_H + inputField.LABEL_GAP); + obj.button2.Position(3) = widthOfString(obj.button2.Text, LABEL_H) + widthOfString(' ', LABEL_H + LABEL_GAP); if ~islogical(obj.net_atlas) && ~islogical(obj.func_conn_unordered) obj.button_view_fc_avg.Enable = true; else obj.button_view_fc_avg.Enable = false; end - obj.button_view_fc_avg.Position(1) = obj.button2.Position(1) + inputField.LABEL_GAP + obj.button2.Position(3); + obj.button_view_fc_avg.Position(1) = obj.button2.Position(1) + LABEL_GAP + obj.button2.Position(3); end end end diff --git a/+nla/+inputField/Number.m b/+nla/+inputField/Number.m index 5242e440..2e496609 100755 --- a/+nla/+inputField/Number.m +++ b/+nla/+inputField/Number.m @@ -14,7 +14,6 @@ methods function obj = Number(name, disp_name, min, default, max) - import nla.* % required due to matlab package system quirks obj.name = name; obj.disp_name = disp_name; obj.min = min; @@ -24,19 +23,18 @@ end function [w, h] = draw(obj, x, y, parent, fig) - import nla.* % required due to matlab package system quirks obj.fig = fig; - h = inputField.LABEL_H; - label_gap = inputField.LABEL_GAP; + h = nla.inputField.LABEL_H; + label_gap = nla.inputField.LABEL_GAP; %% Create label if ~isgraphics(obj.label) obj.label = uilabel(parent); end obj.label.Text = obj.disp_name; - label_w = inputField.widthOfString(obj.label.Text, h); + label_w = nla.inputField.widthOfString(obj.label.Text, h); obj.label.HorizontalAlignment = 'left'; obj.label.Position = [x, y - h, label_w + label_gap, h]; @@ -52,7 +50,6 @@ end function undraw(obj) - import nla.* % required due to matlab package system quirks if isgraphics(obj.label) delete(obj.label) end @@ -62,7 +59,6 @@ function undraw(obj) end function read(obj, input_struct) - import nla.* % required due to matlab package system quirks if isfield(input_struct, obj.name) obj.field.Value = input_struct.(obj.name); else @@ -71,7 +67,6 @@ function read(obj, input_struct) end function [input_struct, error] = store(obj, input_struct) - import nla.* % required due to matlab package system quirks input_struct.(obj.name) = obj.field.Value; error = false; end diff --git a/+nla/+inputField/NumberWithoutDefault.m b/+nla/+inputField/NumberWithoutDefault.m index 71a6cedb..8b67e11a 100755 --- a/+nla/+inputField/NumberWithoutDefault.m +++ b/+nla/+inputField/NumberWithoutDefault.m @@ -13,7 +13,6 @@ methods function obj = NumberWithoutDefault(name, disp_name, min, max) - import nla.* % required due to matlab package system quirks obj.name = name; obj.disp_name = disp_name; obj.min = min; @@ -22,19 +21,18 @@ end function [w, h] = draw(obj, x, y, parent, fig) - import nla.* % required due to matlab package system quirks obj.fig = fig; - h = inputField.LABEL_H; - label_gap = inputField.LABEL_GAP; + h = nla.inputField.LABEL_H; + label_gap = nla.inputField.LABEL_GAP; %% Create label if ~isgraphics(obj.label) obj.label = uilabel(parent); end obj.label.Text = obj.disp_name; - label_w = inputField.widthOfString(obj.label.Text, h); + label_w = nla.inputField.widthOfString(obj.label.Text, h); obj.label.HorizontalAlignment = 'left'; obj.label.Position = [x, y - h, label_w + label_gap, h]; @@ -54,7 +52,6 @@ function numberSet(obj, ~) end function undraw(obj) - import nla.* % required due to matlab package system quirks if isgraphics(obj.label) delete(obj.label) end @@ -64,7 +61,6 @@ function undraw(obj) end function read(obj, input_struct) - import nla.* % required due to matlab package system quirks if isfield(input_struct, obj.name) obj.field.Value = input_struct.(obj.name); else @@ -74,7 +70,6 @@ function read(obj, input_struct) end function [input_struct, error] = store(obj, input_struct) - import nla.* % required due to matlab package system quirks input_struct.(obj.name) = obj.field.Value; error = false; end diff --git a/+nla/+inputField/String.m b/+nla/+inputField/String.m index 24c63afe..edb96014 100755 --- a/+nla/+inputField/String.m +++ b/+nla/+inputField/String.m @@ -12,7 +12,6 @@ methods function obj = String(name, disp_name, default) - import nla.* % required due to matlab package system quirks obj.name = name; obj.disp_name = disp_name; obj.default = default; @@ -20,19 +19,18 @@ end function [w, h] = draw(obj, x, y, parent, fig) - import nla.* % required due to matlab package system quirks obj.fig = fig; - h = inputField.LABEL_H; - label_gap = inputField.LABEL_GAP; + h = nla.inputField.LABEL_H; + label_gap = nla.inputField.LABEL_GAP; %% Create label if ~isgraphics(obj.label) obj.label = uilabel(parent); end obj.label.Text = obj.disp_name; - label_w = inputField.widthOfString(obj.label.Text, h); + label_w = nla.inputField.widthOfString(obj.label.Text, h); obj.label.HorizontalAlignment = 'left'; obj.label.Position = [x, y - h, label_w + label_gap, h]; @@ -47,7 +45,6 @@ end function undraw(obj) - import nla.* % required due to matlab package system quirks if isgraphics(obj.label) delete(obj.label) end @@ -57,7 +54,6 @@ function undraw(obj) end function read(obj, input_struct) - import nla.* % required due to matlab package system quirks if isfield(input_struct, obj.name) obj.field.Value = input_struct.(obj.name); else @@ -66,7 +62,6 @@ function read(obj, input_struct) end function [input_struct, error] = store(obj, input_struct) - import nla.* % required due to matlab package system quirks input_struct.(obj.name) = obj.field.Value; error = false; end diff --git a/+nla/+mex/run.m b/+nla/+mex/run.m index 72353f4f..ccba8147 100755 --- a/+nla/+mex/run.m +++ b/+nla/+mex/run.m @@ -1,7 +1,7 @@ function varargout = run(func_name, varargin) %RUN Run mex function, compiling if necessary - import nla.* % required due to matlab package system quirks - + import nla.findRootPath + if isstring(func_name) func_name = char(func_name); end @@ -10,7 +10,7 @@ % hash the source file to check if we have an up-to-date binary % already compiled or not func_src_path = [findRootPath() '+nla/+mex/+src/' char(func_name) '.c']; - func_src_hash = char(helpers.file.hash(func_src_path)); + func_src_hash = char(nla.helpers.file.hash(func_src_path)); func_name_hashed = [func_name '_' func_src_hash]; bin_path = [findRootPath() '+nla/+mex/+bin/']; @@ -31,7 +31,7 @@ delete(build_path); % delete outdated binaries of the same function - matching = helpers.file.findMatching([bin_path func_name '_*']); + matching = nla.helpers.file.findMatching([bin_path func_name '_*']); if size(matching, 1) > 0 for i = [1:size(matching, 1)] outdated_bin_path = matching(i); diff --git a/+nla/+net/+mcc/BenjaminiHochberg.m b/+nla/+net/+mcc/BenjaminiHochberg.m index a38be96b..f3786937 100755 --- a/+nla/+net/+mcc/BenjaminiHochberg.m +++ b/+nla/+net/+mcc/BenjaminiHochberg.m @@ -5,16 +5,15 @@ methods function p_max = correct(obj, net_atlas, input_struct, prob) - import nla.* % required due to matlab package system quirks - [~, p_max] = lib.fdr_bh(prob.v, input_struct.prob_max, 'pdep'); + [~, p_max] = nla.lib.fdr_bh(prob.v, input_struct.prob_max, 'pdep'); end function correction_label = createLabel(obj, net_atlas, input_struct, prob) - import nla.* % required due to matlab package system quirks p_max = obj.correct(net_atlas, input_struct, prob); if p_max == 0 correction_label = sprintf('FDR_{BH} produced no significant nets'); else - correction_label = sprintf('FDR_{BH}(%g/%d tests)', input_struct.prob_max * input_struct.behavior_count, input_struct.behavior_count); + correction_label = sprintf('FDR_{BH}(%g/%d tests)', input_struct.prob_max * input_struct.behavior_count,... + input_struct.behavior_count); end end end diff --git a/+nla/+net/+mcc/BenjaminiYekutieli.m b/+nla/+net/+mcc/BenjaminiYekutieli.m index 6e211e5c..0c53e1f1 100755 --- a/+nla/+net/+mcc/BenjaminiYekutieli.m +++ b/+nla/+net/+mcc/BenjaminiYekutieli.m @@ -5,16 +5,15 @@ methods function p_max = correct(obj, net_atlas, input_struct, prob) - import nla.* % required due to matlab package system quirks - [~, p_max] = lib.fdr_bh(prob.v, input_struct.prob_max, 'dep'); + [~, p_max] = nla.lib.fdr_bh(prob.v, input_struct.prob_max, 'dep'); end function correction_label = createLabel(obj, net_atlas, input_struct, prob) - import nla.* % required due to matlab package system quirks p_max = obj.correct(net_atlas, input_struct, prob); if p_max == 0 correction_label = sprintf('FDR_{BY} produced no significant nets'); else - correction_label = sprintf('FDR_{BY}(%g/%d tests)', input_struct.prob_max * input_struct.behavior_count, input_struct.behavior_count); + correction_label = sprintf('FDR_{BY}(%g/%d tests)', input_struct.prob_max * input_struct.behavior_count,... + input_struct.behavior_count); end end end diff --git a/+nla/+net/+mcc/Bonferroni.m b/+nla/+net/+mcc/Bonferroni.m index 6bbba964..98cad3f6 100755 --- a/+nla/+net/+mcc/Bonferroni.m +++ b/+nla/+net/+mcc/Bonferroni.m @@ -5,12 +5,11 @@ methods function p_max = correct(obj, net_atlas, input_struct, prob) - import nla.* % required due to matlab package system quirks p_max = input_struct.prob_max / net_atlas.numNetPairs(); end function correction_label = createLabel(obj, net_atlas, input_struct, prob) - import nla.* % required due to matlab package system quirks - correction_label = sprintf('%g/%d net-pairs/%d tests', input_struct.prob_max * input_struct.behavior_count, net_atlas.numNetPairs(), input_struct.behavior_count); + correction_label = sprintf('%g/%d net-pairs/%d tests', input_struct.prob_max * input_struct.behavior_count,... + net_atlas.numNetPairs(), input_struct.behavior_count); end end end \ No newline at end of file diff --git a/+nla/+net/+mcc/None.m b/+nla/+net/+mcc/None.m index 26c524ef..59721829 100755 --- a/+nla/+net/+mcc/None.m +++ b/+nla/+net/+mcc/None.m @@ -5,12 +5,11 @@ methods function p_max = correct(obj, net_atlas, input_struct, prob) - import nla.* % required due to matlab package system quirks p_max = input_struct.prob_max; end function correction_label = createLabel(obj, net_atlas, input_struct, prob) - import nla.* % required due to matlab package system quirks - correction_label = sprintf('%g/%d tests', input_struct.prob_max * input_struct.behavior_count, input_struct.behavior_count); + correction_label = sprintf('%g/%d tests', input_struct.prob_max * input_struct.behavior_count,... + input_struct.behavior_count); end end end \ No newline at end of file diff --git a/+nla/+net/+result/ChiSquared.m b/+nla/+net/+result/ChiSquared.m index b4de22d1..994d0201 100755 --- a/+nla/+net/+result/ChiSquared.m +++ b/+nla/+net/+result/ChiSquared.m @@ -12,20 +12,17 @@ methods function obj = ChiSquared(size) - import nla.* % required due to matlab package system quirks % Superclass constructor obj@nla.net.BaseSigResult(size); - obj.chi2 = TriMatrix(size, TriMatrixDiag.KEEP_DIAGONAL); + obj.chi2 = nla.TriMatrix(size, nla.TriMatrixDiag.KEEP_DIAGONAL); end function merge(obj, input_struct, edge_result_nonperm, edge_result, net_atlas, results) - import nla.* % required due to matlab package system quirks merge@nla.net.BaseResult(obj, input_struct, edge_result_nonperm, edge_result, net_atlas, results); end function table_new = genSummaryTable(obj, table_old) - import nla.* % required due to matlab package system quirks table_new = [genSummaryTable@nla.net.BasePermResult(obj, table_old), table(obj.chi2.v, 'VariableNames', [obj.name])]; end end diff --git a/+nla/+net/+result/CohenD.m b/+nla/+net/+result/CohenD.m index ab1a0fec..13e0c5a6 100755 --- a/+nla/+net/+result/CohenD.m +++ b/+nla/+net/+result/CohenD.m @@ -14,83 +14,88 @@ methods function obj = CohenD(size) - import nla.* % required due to matlab package system quirks obj@nla.net.BasePermResult(size); % non-permuted stats - obj.d = TriMatrix(size, TriMatrixDiag.KEEP_DIAGONAL); + obj.d = nla.TriMatrix(size, nla.TriMatrixDiag.KEEP_DIAGONAL); %% Within Net-Pair statistics (withinNP) - obj.within_np_d = TriMatrix(size, TriMatrixDiag.KEEP_DIAGONAL); + obj.within_np_d = nla.TriMatrix(size, nla.TriMatrixDiag.KEEP_DIAGONAL); end function merge(obj, input_struct, edge_result_nonperm, edge_result, net_atlas, results) - import nla.* % required due to matlab package system quirks % Summations merge@nla.net.BasePermResult(obj, input_struct, edge_result_nonperm, edge_result, net_atlas, results); end function output(obj, edge_input_struct, input_struct, net_atlas, edge_result, flags) - import nla.* % required due to matlab package system quirks %% callback function function brainFigsButtonClickedCallback(net1, net2) - f = waitbar(0.05, sprintf('Generating %s - %s net-pair brain plot', net_atlas.nets(net1).name, net_atlas.nets(net2).name)); - gfx.drawBrainVis(edge_input_struct, input_struct, net_atlas, gfx.MeshType.STD, 0.25, 3, true, edge_result, net1, net2, isa(obj, 'nla.net.BaseSigResult')); + f = waitbar(0.05, sprintf('Generating %s - %s net-pair brain plot', net_atlas.nets(net1).name,... + net_atlas.nets(net2).name)); + nla.gfx.drawBrainVis(edge_input_struct, input_struct, net_atlas, nla.gfx.MeshType.STD, 0.25, 3, true,... + edge_result, net1, net2, isa(obj, 'nla.net.BaseSigResult')); waitbar(0.95); close(f) end if obj.perm_count > 0 if isfield(flags, 'show_full_conn') && flags.show_full_conn - d_sig = TriMatrix(net_atlas.numNets(), 'logical', TriMatrixDiag.KEEP_DIAGONAL); + d_sig = nla.TriMatrix(net_atlas.numNets(), 'logical', nla.TriMatrixDiag.KEEP_DIAGONAL); d_sig.v = obj.d.v >= input_struct.d_max; - name_label = sprintf("Observed %s Full Connectome Significance\nD > %g", obj.name_formatted, input_struct.d_max); + name_label = sprintf("Observed %s Full Connectome Significance\nD > %g", obj.name_formatted,... + input_struct.d_max); if flags.plot_type == nla.PlotType.FIGURE %% Permuted probability (fullConn) - fig = gfx.createFigure(500, 1000); + fig = nla.gfx.createFigure(500, 1000); %% Check that network-pair size is not a confound %obj.plotPermProbVsNetSize(net_atlas, subplot(2,1,2)); - obj.plotValsVsNetSize(net_atlas, subplot(2,1,2), obj.d, "Full Connectome Observed Cohen's D vs. Net-Pair Size", "Cohen's D", "Cohen's D effect sizes"); + obj.plotValsVsNetSize(net_atlas, subplot(2,1,2), obj.d, "Full Connectome Observed Cohen's D vs. Net-Pair Size",... + "Cohen's D", "Cohen's D effect sizes"); %% Matrix plot - matrix_plot = gfx.plots.MatrixPlot(fig, name_label, obj.d, net_atlas.nets, gfx.FigSize.SMALL,... - 'network_clicked_callback', @brainFigsButtonClickedCallback, 'marked_networks', d_sig,... - 'draw_legend', false, 'color_map', [1,1,1;parula(256)], 'lower_limit', input_struct.d_max,... - 'upper_limit', 1, 'x_position', 0, 'y_position', 525); + matrix_plot = nla.gfx.plots.MatrixPlot(fig, name_label, obj.d, net_atlas.nets, nla.gfx.FigSize.SMALL,... + 'network_clicked_callback', @brainFigsButtonClickedCallback, 'marked_networks', d_sig,... + 'draw_legend', false, 'color_map', [1,1,1;parula(256)], 'lower_limit', input_struct.d_max,... + 'upper_limit', 1, 'x_position', 0, 'y_position', 525); matrix_plot.displayImage(); + elseif flags.plot_type == nla.PlotType.CHORD || flags.plot_type == nla.PlotType.CHORD_EDGE - obj.genChordPlotFig(edge_input_struct, input_struct, net_atlas, edge_result, d_sig, obj.d, input_struct.d_max, [1,1,1;parula(256)], name_label, true, flags.plot_type); + obj.genChordPlotFig(edge_input_struct, input_struct, net_atlas, edge_result, d_sig, obj.d,... + input_struct.d_max, [1,1,1;parula(256)], name_label, true, flags.plot_type); end end if isfield(flags, 'show_within_net_pair') && flags.show_within_net_pair - within_np_d_sig = TriMatrix(net_atlas.numNets(), 'logical', TriMatrixDiag.KEEP_DIAGONAL); + within_np_d_sig = nla.TriMatrix(net_atlas.numNets(), 'logical', nla.TriMatrixDiag.KEEP_DIAGONAL); within_np_d_sig.v = obj.within_np_d.v >= input_struct.d_max; name_label = sprintf("%s Within Net-Pair Significance\nD > %g", obj.name_formatted, input_struct.d_max); if flags.plot_type == nla.PlotType.FIGURE %% Within Net-Pair statistics (withinNP) - fig = gfx.createFigure(); - matrix_plot2 = gfx.plots.MatrixPlot(fig, name_label, obj.within_np_d, net_atlas.nets, gfx.FigSize.SMALL,... - 'network_clicked_callback', @brainFigsButtonClickedCallback, 'marked_networks', within_np_d_sig,... - 'draw_legend', false, 'color_map', [1,1,1;parula(256)], 'upper_limit', input_struct.d_max, 'lower_limit', 1); + fig = nla.gfx.createFigure(); + matrix_plot2 = nla.gfx.plots.MatrixPlot(fig, name_label, obj.within_np_d, net_atlas.nets,... + nla.gfx.FigSize.SMALL, 'network_clicked_callback', @brainFigsButtonClickedCallback,... + 'marked_networks', within_np_d_sig, 'draw_legend', false, 'color_map', [1,1,1;parula(256)],... + 'upper_limit', input_struct.d_max, 'lower_limit', 1); fig.Position(3) = matrix_plot2.image_dimensions("image_width"); fig.Position(4) = matrix_plot2.image_dimensions("image_height"); matrix_plot2.displayImage(); + elseif flags.plot_type == nla.PlotType.CHORD || flags.plot_type == nla.PlotType.CHORD_EDGE - obj.genChordPlotFig(edge_input_struct, input_struct, net_atlas, edge_result, within_np_d_sig, obj.within_np_d, input_struct.d_max, [1,1,1;parula(256)], name_label, true, flags.plot_type); + obj.genChordPlotFig(edge_input_struct, input_struct, net_atlas, edge_result, within_np_d_sig,... + obj.within_np_d, input_struct.d_max, [1,1,1;parula(256)], name_label, true, flags.plot_type); end end end end function [num_tests, sig_count_mat, names] = getSigMat(obj, input_struct, net_atlas, flags) - import nla.* % required due to matlab package system quirks num_tests = 0; - sig_count_mat = TriMatrix(net_atlas.numNets(), 'double', TriMatrixDiag.KEEP_DIAGONAL); + sig_count_mat = nla.TriMatrix(net_atlas.numNets(), 'double', nla.TriMatrixDiag.KEEP_DIAGONAL); names = []; if obj.perm_count > 0 @@ -108,8 +113,8 @@ function brainFigsButtonClickedCallback(net1, net2) end function table_new = genSummaryTable(obj, table_old) - import nla.* % required due to matlab package system quirks - table_new = [genSummaryTable@nla.net.BasePermResult(obj, table_old), table(obj.d.v, 'VariableNames', [obj.name])]; + table_new = [genSummaryTable@nla.net.BasePermResult(obj, table_old), table(obj.d.v,... + 'VariableNames', [obj.name])]; end end end \ No newline at end of file diff --git a/+nla/+net/+result/HyperGeo.m b/+nla/+net/+result/HyperGeo.m index 5d285d09..a51fa05b 100755 --- a/+nla/+net/+result/HyperGeo.m +++ b/+nla/+net/+result/HyperGeo.m @@ -8,18 +8,15 @@ methods function obj = HyperGeo(size) - import nla.* % required due to matlab package system quirks % Superclass constructor obj@nla.net.BaseSigResult(size); end function merge(obj, input_struct, edge_result_nonperm, edge_result, net_atlas, results) - import nla.* % required due to matlab package system quirks merge@nla.net.BaseResult(obj, input_struct, edge_result_nonperm, edge_result, net_atlas, results); end function table_new = genSummaryTable(obj, table_old) - import nla.* % required due to matlab package system quirks table_new = genSummaryTable@nla.net.BasePermResult(obj, table_old); end end diff --git a/+nla/+net/+result/KolmogorovSmirnov.m b/+nla/+net/+result/KolmogorovSmirnov.m index e3c8447a..c9ff8c67 100755 --- a/+nla/+net/+result/KolmogorovSmirnov.m +++ b/+nla/+net/+result/KolmogorovSmirnov.m @@ -13,11 +13,10 @@ methods function obj = KolmogorovSmirnov(size) - import nla.* % required due to matlab package system quirks % Superclass constructor obj@nla.net.BaseCorrResult(size); - obj.ks = TriMatrix(size, TriMatrixDiag.KEEP_DIAGONAL); + obj.ks = nla.TriMatrix(size, nla.TriMatrixDiag.KEEP_DIAGONAL); end function prob = withinNetPairOneNet(obj, coeff_net, coeff_net_perm) @@ -25,7 +24,6 @@ end function table_new = genSummaryTable(obj, table_old) - import nla.* % required due to matlab package system quirks table_new = [genSummaryTable@nla.net.BasePermResult(obj, table_old), table(obj.ks.v, 'VariableNames', [obj.name])]; end end diff --git a/+nla/+net/+result/StudentT.m b/+nla/+net/+result/StudentT.m index 0be033e2..468ca3fc 100755 --- a/+nla/+net/+result/StudentT.m +++ b/+nla/+net/+result/StudentT.m @@ -13,11 +13,10 @@ methods function obj = StudentT(size) - import nla.* % required due to matlab package system quirks % Superclass constructor obj@nla.net.BaseCorrResult(size); - obj.t = TriMatrix(size, TriMatrixDiag.KEEP_DIAGONAL); + obj.t = nla.TriMatrix(size, nla.TriMatrixDiag.KEEP_DIAGONAL); end function prob = withinNetPairOneNet(obj, coeff_net, coeff_net_perm) @@ -25,7 +24,6 @@ end function table_new = genSummaryTable(obj, table_old) - import nla.* % required due to matlab package system quirks table_new = [genSummaryTable@nla.net.BasePermResult(obj, table_old), table(obj.t.v, 'VariableNames', [obj.name])]; end end diff --git a/+nla/+net/+result/WelchT.m b/+nla/+net/+result/WelchT.m index a4fd5cd3..2e1dadf8 100755 --- a/+nla/+net/+result/WelchT.m +++ b/+nla/+net/+result/WelchT.m @@ -13,11 +13,10 @@ methods function obj = WelchT(size) - import nla.* % required due to matlab package system quirks % Superclass constructor obj@nla.net.BaseCorrResult(size); - obj.t = TriMatrix(size, TriMatrixDiag.KEEP_DIAGONAL); + obj.t = nla.TriMatrix(size, nla.TriMatrixDiag.KEEP_DIAGONAL); end function prob = withinNetPairOneNet(obj, coeff_net, coeff_net_perm) @@ -25,7 +24,6 @@ end function table_new = genSummaryTable(obj, table_old) - import nla.* % required due to matlab package system quirks table_new = [genSummaryTable@nla.net.BasePermResult(obj, table_old), table(obj.t.v, 'VariableNames', [obj.name])]; end end diff --git a/+nla/+net/+result/Wilcoxon.m b/+nla/+net/+result/Wilcoxon.m index 91c6bb04..c3ab237e 100755 --- a/+nla/+net/+result/Wilcoxon.m +++ b/+nla/+net/+result/Wilcoxon.m @@ -14,11 +14,10 @@ methods function obj = Wilcoxon(size) - import nla.* % required due to matlab package system quirks % Superclass constructor obj@nla.net.BaseCorrResult(size); - obj.w = TriMatrix(size, TriMatrixDiag.KEEP_DIAGONAL); + obj.w = nla.TriMatrix(size, nla.TriMatrixDiag.KEEP_DIAGONAL); end function prob = withinNetPairOneNet(obj, coeff_net, coeff_net_perm) @@ -26,8 +25,8 @@ end function table_new = genSummaryTable(obj, table_old) - import nla.* % required due to matlab package system quirks - table_new = [genSummaryTable@nla.net.BasePermResult(obj, table_old), table(obj.w.v, 'VariableNames', [obj.name]), table(obj.z.v, 'VariableNames', [obj.name + " Z-score"])]; + table_new = [genSummaryTable@nla.net.BasePermResult(obj, table_old), table(obj.w.v, 'VariableNames', [obj.name]),... + table(obj.z.v, 'VariableNames', [obj.name + " Z-score"])]; end end end diff --git a/+nla/+net/+test/ChiSquared.m b/+nla/+net/+test/ChiSquared.m index 54b116a7..ec866f7b 100755 --- a/+nla/+net/+test/ChiSquared.m +++ b/+nla/+net/+test/ChiSquared.m @@ -6,12 +6,10 @@ methods function obj = ChiSquared() - import nla.* % required due to matlab package system quirks obj@nla.net.BaseSigTest(); end function result = run(obj, input_struct, edge_result, net_atlas, previous_result) - import nla.* % required due to matlab package system quirks %RUN Run the test % edge_result: Result of edge-level statistics % net_atlas: Network atlas @@ -20,6 +18,8 @@ % non-permuted ChiSquaredResult, indicating that this is a % permuted run, which is dependant on the non-permuted result + import nla.TriMatrix nla.TriMatrixDiag + num_nets = net_atlas.numNets(); chi2 = TriMatrix(num_nets, TriMatrixDiag.KEEP_DIAGONAL); @@ -51,9 +51,10 @@ % If a previous non-permuted result is passed in, add on to it if previous_result ~= false - result = obj.rank(net_atlas, previous_result, input_struct, @ge, previous_result.chi2, previous_result.prob, chi2, prob, previous_result.chi2, previous_result.prob, chi2, prob); + result = obj.rank(net_atlas, previous_result, input_struct, @ge, previous_result.chi2,... + previous_result.prob, chi2, prob, previous_result.chi2, previous_result.prob, chi2, prob); else - result = net.result.ChiSquared(num_nets); + result = nla.net.result.ChiSquared(num_nets); result.chi2 = chi2; result.observed_gt_expected = observed_gt_expected; result.prob = prob; diff --git a/+nla/+net/+test/CohenD.m b/+nla/+net/+test/CohenD.m index 3bf7e3d9..3f27635e 100755 --- a/+nla/+net/+test/CohenD.m +++ b/+nla/+net/+test/CohenD.m @@ -6,17 +6,16 @@ methods (Static) function [d, within_np_d] = effectSizes(edge_result, net_atlas) - import nla.* % required due to matlab package system quirks num_nets = net_atlas.numNets(); - d = TriMatrix(num_nets, TriMatrixDiag.KEEP_DIAGONAL); - within_np_d = TriMatrix(num_nets, TriMatrixDiag.KEEP_DIAGONAL); + d = nla.TriMatrix(num_nets, nla.TriMatrixDiag.KEEP_DIAGONAL); + within_np_d = nla.TriMatrix(num_nets, nla.TriMatrixDiag.KEEP_DIAGONAL); for row = 1:num_nets for col = 1:row coeff_net = edge_result.coeff.get(net_atlas.nets(row).indexes, net_atlas.nets(col).indexes); d_val = abs((mean(coeff_net) - mean(edge_result.coeff.v)) / sqrt(((std(coeff_net) .^ 2) + (std(edge_result.coeff.v) .^ 2)) / 2)); d.set(row, col, d_val); - within_np_d_val = net.ssCohenD(coeff_net, edge_result.coeff.v); + within_np_d_val = nla.net.ssCohenD(coeff_net, edge_result.coeff.v); within_np_d.set(row, col, within_np_d_val); end end @@ -25,21 +24,20 @@ methods function obj = CohenD() - import nla.* % required due to matlab package system quirks obj@nla.net.BaseCorrTest(); end function result = run(obj, input_struct, edge_result, net_atlas, previous_result) - import nla.* % required due to matlab package system quirks num_nets = net_atlas.numNets(); - [d, within_np_d] = net.test.CohenD.effectSizes(edge_result, net_atlas); + [d, within_np_d] = nla.net.test.CohenD.effectSizes(edge_result, net_atlas); % if a previous result is passed in, add on to it if previous_result ~= false - result = obj.rank(net_atlas, previous_result, input_struct, @ge, previous_result.d, false, d, false, false, false, false, false); + result = obj.rank(net_atlas, previous_result, input_struct, @ge, previous_result.d, false, d, false,... + false, false, false, false); else - result = net.result.CohenD(num_nets); + result = nla.net.result.CohenD(num_nets); result.d = d; result.within_np_d = within_np_d; end diff --git a/+nla/+net/+test/HyperGeo.m b/+nla/+net/+test/HyperGeo.m index d04e44af..cba41143 100755 --- a/+nla/+net/+test/HyperGeo.m +++ b/+nla/+net/+test/HyperGeo.m @@ -6,12 +6,10 @@ methods function obj = HyperGeo() - import nla.* % required due to matlab package system quirks obj@nla.net.BaseSigTest(); end function result = run(obj, input_struct, edge_result, net_atlas, previous_result) - import nla.* % required due to matlab package system quirks %RUN Run the test % edge_result: Result of edge-level statistics % net_atlas: Network atlas @@ -22,8 +20,8 @@ num_nets = net_atlas.numNets(); - observed_gt_expected = TriMatrix(num_nets, 'logical', TriMatrixDiag.KEEP_DIAGONAL); - prob = TriMatrix(num_nets, TriMatrixDiag.KEEP_DIAGONAL); + observed_gt_expected = nla.TriMatrix(num_nets, 'logical', nla.TriMatrixDiag.KEEP_DIAGONAL); + prob = nla.TriMatrix(num_nets, nla.TriMatrixDiag.KEEP_DIAGONAL); for row = 1:num_nets for col = 1:row @@ -32,7 +30,8 @@ observed_sig = sum(net_pair_ROI_sig); expected_sig = edge_result.avg_prob_sig * net_ROI_count; observed_gt_expected.set(row, col, observed_sig > expected_sig); - prob.set(row, col, hygecdf(observed_sig, numel(edge_result.prob_sig.v), sum(edge_result.prob_sig.v), net_ROI_count, 'upper')); + prob.set(row, col, hygecdf(observed_sig, numel(edge_result.prob_sig.v), sum(edge_result.prob_sig.v),... + net_ROI_count, 'upper')); end end @@ -40,9 +39,10 @@ % if a previous result is passed in, add on to it if previous_result ~= false - result = obj.rank(net_atlas, previous_result, input_struct, @le, previous_result.prob, previous_result.prob, prob, prob, previous_result.prob, previous_result.prob, prob, prob); + result = obj.rank(net_atlas, previous_result, input_struct, @le, previous_result.prob,... + previous_result.prob, prob, prob, previous_result.prob, previous_result.prob, prob, prob); else - result = net.result.HyperGeo(num_nets); + result = nla.net.result.HyperGeo(num_nets); result.observed_gt_expected = observed_gt_expected; result.prob = prob; end diff --git a/+nla/+net/+test/KolmogorovSmirnov.m b/+nla/+net/+test/KolmogorovSmirnov.m index 5679039d..51ebcef5 100755 --- a/+nla/+net/+test/KolmogorovSmirnov.m +++ b/+nla/+net/+test/KolmogorovSmirnov.m @@ -6,12 +6,11 @@ methods function obj = KolmogorovSmirnov() - import nla.* % required due to matlab package system quirks obj@nla.net.BaseCorrTest(); end function result = run(obj, input_struct, edge_result, net_atlas, previous_result) - import nla.* % required due to matlab package system quirks + import nla.TriMatrix nla.TriMatrixDiag num_nets = net_atlas.numNets(); @@ -37,9 +36,10 @@ % if a previous result is passed in, add on to it if previous_result ~= false - result = obj.rank(net_atlas, previous_result, input_struct, @ge, previous_result.ks, previous_result.prob, ks, prob, previous_result.ss_ks, previous_result.ss_prob, ss_ks, ss_prob); + result = obj.rank(net_atlas, previous_result, input_struct, @ge, previous_result.ks,... + previous_result.prob, ks, prob, previous_result.ss_ks, previous_result.ss_prob, ss_ks, ss_prob); else - result = net.result.KolmogorovSmirnov(num_nets); + result = nla.net.result.KolmogorovSmirnov(num_nets); result.prob = prob; result.ks = ks; result.ss_prob = ss_prob; diff --git a/+nla/+net/+test/StudentT.m b/+nla/+net/+test/StudentT.m index eefb8265..17a012fc 100755 --- a/+nla/+net/+test/StudentT.m +++ b/+nla/+net/+test/StudentT.m @@ -6,12 +6,11 @@ methods function obj = StudentT() - import nla.* % required due to matlab package system quirks obj@nla.net.BaseCorrTest(); end function result = run(obj, input_struct, edge_result, net_atlas, previous_result) - import nla.* % required due to matlab package system quirks + import nla.TriMatrix nla.TriMatrixDiag num_nets = net_atlas.numNets(); @@ -39,9 +38,10 @@ % if a previous result is passed in, add on to it if previous_result ~= false - result = obj.rank(net_atlas, previous_result, input_struct, @helpers.abs_ge, previous_result.t, previous_result.prob, t, prob, previous_result.ss_t, previous_result.ss_prob, ss_t, ss_prob); + result = obj.rank(net_atlas, previous_result, input_struct, @helpers.abs_ge, previous_result.t,... + previous_result.prob, t, prob, previous_result.ss_t, previous_result.ss_prob, ss_t, ss_prob); else - result = net.result.StudentT(num_nets); + result = nla.net.result.StudentT(num_nets); result.prob = prob; result.t = t; result.ss_prob = ss_prob; diff --git a/+nla/+net/+test/WelchT.m b/+nla/+net/+test/WelchT.m index 8fa41346..a551441b 100755 --- a/+nla/+net/+test/WelchT.m +++ b/+nla/+net/+test/WelchT.m @@ -6,12 +6,11 @@ methods function obj = WelchT() - import nla.* % required due to matlab package system quirks obj@nla.net.BaseCorrTest(); end function result = run(obj, input_struct, edge_result, net_atlas, previous_result) - import nla.* % required due to matlab package system quirks + import nla.TriMatrix nla.TriMatrixDiag num_nets = net_atlas.numNets(); @@ -39,9 +38,10 @@ % if a previous result is passed in, add on to it if previous_result ~= false - result = obj.rank(net_atlas, previous_result, input_struct, @helpers.abs_ge, previous_result.t, previous_result.prob, t, prob, previous_result.ss_t, previous_result.ss_prob, ss_t, ss_prob); + result = obj.rank(net_atlas, previous_result, input_struct, @helpers.abs_ge, previous_result.t,... + previous_result.prob, t, prob, previous_result.ss_t, previous_result.ss_prob, ss_t, ss_prob); else - result = net.result.WelchT(num_nets); + result = nla.net.result.WelchT(num_nets); result.prob = prob; result.t = t; result.ss_prob = ss_prob; diff --git a/+nla/+net/+test/Wilcoxon.m b/+nla/+net/+test/Wilcoxon.m index 83f00cb8..5e69bc3b 100755 --- a/+nla/+net/+test/Wilcoxon.m +++ b/+nla/+net/+test/Wilcoxon.m @@ -6,12 +6,11 @@ methods function obj = Wilcoxon() - import nla.* % required due to matlab package system quirks obj@nla.net.BaseCorrTest(); end function result = run(obj, input_struct, edge_result, net_atlas, previous_result) - import nla.* % required due to matlab package system quirks + import nla.TriMatrix nla.TriMatrixDiag num_nets = net_atlas.numNets(); @@ -42,9 +41,10 @@ % if a previous result is passed in, add on to it if previous_result ~= false - result = obj.rank(net_atlas, previous_result, input_struct, @helpers.abs_ge, previous_result.z, previous_result.prob, z, prob, previous_result.ss_w, previous_result.ss_prob, ss_w, ss_prob); + result = obj.rank(net_atlas, previous_result, input_struct, @helpers.abs_ge, previous_result.z,... + previous_result.prob, z, prob, previous_result.ss_w, previous_result.ss_prob, ss_w, ss_prob); else - result = net.result.Wilcoxon(num_nets); + result = nla.net.result.Wilcoxon(num_nets); result.prob = prob; result.w = w; result.z = z; diff --git a/+nla/+net/BaseCorrResult.m b/+nla/+net/BaseCorrResult.m index ddc91a12..a33f45ba 100755 --- a/+nla/+net/BaseCorrResult.m +++ b/+nla/+net/BaseCorrResult.m @@ -13,15 +13,15 @@ % Inputs that can be tweaked post-run (ie: are simple % thresholds etc. for summary statistics, or generally can be % modified without requiring re-permutation) - import nla.* % required due to matlab package system quirks inputs = tweakableInputs@nla.net.BasePermResult(); - inputs{end + 1} = inputField.Number('d_max', "Net-level Cohen's D threshold >", 0, 0.5, 1); + inputs{end + 1} = nla.inputField.Number('d_max', "Net-level Cohen's D threshold >", 0, 0.5, 1); end end methods function obj = BaseCorrResult(size) - import nla.* % required due to matlab package system quirks + import nla.TriMatrix nla.TriMatrixDiag + obj@nla.net.BaseResult(size); % Cohen's D-values (used for thresholding in visualizations) @@ -30,15 +30,15 @@ end function merge(obj, input_struct, edge_result_nonperm, edge_result, net_atlas, results) - import nla.* % required due to matlab package system quirks merge@nla.net.BaseResult(obj, input_struct, edge_result_nonperm, edge_result, net_atlas, results); % Cohen's D-values (used for thresholding in visualizations) - [obj.d, obj.within_np_d] = net.test.CohenD.effectSizes(edge_result_nonperm, net_atlas); + [obj.d, obj.within_np_d] = nla.net.test.CohenD.effectSizes(edge_result_nonperm, net_atlas); end function output(obj, edge_input_struct, input_struct, net_atlas, edge_result, flags) - import nla.* % required due to matlab package system quirks + import nla.TriMatrix nla.TriMatrixDiag + output@nla.net.BaseResult(obj, edge_input_struct, input_struct, net_atlas, edge_result, flags); if obj.perm_count > 0 @@ -49,7 +49,7 @@ function output(obj, edge_input_struct, input_struct, net_atlas, edge_result, fl name_label = sprintf('Full Connectome Method\nNetwork vs. Connectome Significance'); name_label_thresh = sprintf('%s (D > %g)', name_label, input_struct.d_max); if flags.plot_type == nla.PlotType.FIGURE - fig = gfx.createFigure(1200, 900); + fig = nla.gfx.createFigure(1200, 900); %% Histogram of probabilities, with thresholds markedx obj.plotProbHist(subplot(2,3,4), input_struct.prob_max); @@ -59,8 +59,10 @@ function output(obj, edge_input_struct, input_struct, net_atlas, edge_result, fl obj.plotPermProbVsNetSize(net_atlas, subplot(2,3,6)); %% Matrix with significant networks marked - [w, ~] = obj.plotProb(edge_input_struct, input_struct, net_atlas, fig, 75, 425, obj.perm_prob_ew, false, name_label, net.mcc.None(), nla.Method.FULL_CONN, edge_result); - obj.plotProb(edge_input_struct, input_struct, net_atlas, fig, w + 50, 425, obj.perm_prob_ew, d_sig, name_label_thresh, net.mcc.None(), nla.Method.FULL_CONN, edge_result); + [w, ~] = obj.plotProb(edge_input_struct, input_struct, net_atlas, fig, 75, 425,... + obj.perm_prob_ew, false, name_label, nla.net.mcc.None(), nla.Method.FULL_CONN, edge_result); + obj.plotProb(edge_input_struct, input_struct, net_atlas, fig, w + 50, 425, obj.perm_prob_ew,... + d_sig, name_label_thresh, nla.net.mcc.None(), nla.Method.FULL_CONN, edge_result); elseif flags.plot_type == nla.PlotType.CHORD || flags.plot_type == nla.PlotType.CHORD_EDGE d_thresh = false; chord_label = name_label; @@ -68,7 +70,8 @@ function output(obj, edge_input_struct, input_struct, net_atlas, edge_result, fl d_thresh = d_sig; chord_label = name_label_thresh; end - obj.plotChord(edge_input_struct, input_struct, net_atlas, obj.perm_prob_ew, d_thresh, chord_label, net.mcc.None(), nla.Method.FULL_CONN, edge_result, flags.plot_type); + obj.plotChord(edge_input_struct, input_struct, net_atlas, obj.perm_prob_ew, d_thresh,... + chord_label, nla.net.mcc.None(), nla.Method.FULL_CONN, edge_result, flags.plot_type); end end if isfield(flags, 'show_within_net_pair') && flags.show_within_net_pair @@ -78,13 +81,19 @@ function output(obj, edge_input_struct, input_struct, net_atlas, edge_result, fl if flags.plot_type == nla.PlotType.FIGURE %% Within Net-Pair statistics (withinNP) - fig = gfx.createFigure(1000, 900); + fig = nla.gfx.createFigure(1000, 900); obj.plotWithinNetPairProbVsNetSize(net_atlas, subplot(2,2,3)); - [w, ~] = obj.plotProb(edge_input_struct, input_struct, net_atlas, fig, 25, 425, obj.within_np_prob, false, sprintf('Within Network Pair Method\nNetwork Pair vs. Permuted Network Pair'), input_struct.fdr_correction, nla.Method.WITHIN_NET_PAIR, edge_result); - obj.plotProb(edge_input_struct, input_struct, net_atlas, fig, w - 50, 425, obj.within_np_prob, within_np_d_sig, name_label, input_struct.fdr_correction, nla.Method.WITHIN_NET_PAIR, edge_result); + [w, ~] = obj.plotProb(edge_input_struct, input_struct, net_atlas, fig, 25, 425,... + obj.within_np_prob, false, sprintf('Within Network Pair Method\nNetwork Pair vs. Permuted Network Pair'),... + input_struct.fdr_correction, nla.Method.WITHIN_NET_PAIR, edge_result); + obj.plotProb(edge_input_struct, input_struct, net_atlas, fig, w - 50, 425, obj.within_np_prob,... + within_np_d_sig, name_label, input_struct.fdr_correction, nla.Method.WITHIN_NET_PAIR, edge_result); + elseif flags.plot_type == nla.PlotType.CHORD || flags.plot_type == nla.PlotType.CHORD_EDGE - obj.plotChord(edge_input_struct, input_struct, net_atlas, obj.within_np_prob, within_np_d_sig, name_label, input_struct.fdr_correction, nla.Method.WITHIN_NET_PAIR, edge_result, flags.plot_type); + + obj.plotChord(edge_input_struct, input_struct, net_atlas, obj.within_np_prob, within_np_d_sig,... + name_label, input_struct.fdr_correction, nla.Method.WITHIN_NET_PAIR, edge_result, flags.plot_type); end end end diff --git a/+nla/+net/BaseCorrTest.m b/+nla/+net/BaseCorrTest.m index f9c709e1..71faeae5 100755 --- a/+nla/+net/BaseCorrTest.m +++ b/+nla/+net/BaseCorrTest.m @@ -1,16 +1,14 @@ classdef BaseCorrTest < nla.net.BaseTest methods function obj = BaseCorrTest() - import nla.* % required due to matlab package system quirks obj@nla.net.BaseTest(); end end methods (Static) function inputs = requiredInputs() % Inputs that must be provided to run the test - import nla.* % required due to matlab package system quirks inputs = requiredInputs@nla.net.BaseTest(); - inputs{end + 1} = inputField.Number('d_max', "Net-level Cohen's D threshold >", 0, 0.5, 1); + inputs{end + 1} = nla.inputField.Number('d_max', "Net-level Cohen's D threshold >", 0, 0.5, 1); end end end diff --git a/+nla/+net/BasePermResult.m b/+nla/+net/BasePermResult.m index ff835712..6c9b5a40 100755 --- a/+nla/+net/BasePermResult.m +++ b/+nla/+net/BasePermResult.m @@ -18,7 +18,8 @@ methods function obj = BasePermResult(size) - import nla.* % required due to matlab package system quirks + import nla.TriMatrix nla.TriMatrixDiag + % permuted stats obj.perm_rank = TriMatrix(size, 'uint64', TriMatrixDiag.KEEP_DIAGONAL); obj.perm_rank_ew = TriMatrix(size, 'uint64', TriMatrixDiag.KEEP_DIAGONAL); @@ -32,7 +33,6 @@ % merged is a function which merges 2 results from the same test function merge(obj, ~, ~, ~, ~, results) - import nla.* % required due to matlab package system quirks % Summations num_pairs = numel(obj.perm_rank.v); for j = 1:numel(results) @@ -49,7 +49,6 @@ function merge(obj, ~, ~, ~, ~, results) end function table_new = genSummaryTable(obj, table_old) - import nla.* % required due to matlab package system quirks table_new = [table_old, table(obj.perm_prob_ew.v, 'VariableNames', [obj.name + " P-value"])]; end end @@ -59,14 +58,16 @@ function merge(obj, ~, ~, ~, ~, results) % Inputs that can be tweaked post-run (ie: are simple % thresholds etc. for summary statistics, or generally can be % modified without requiring re-permutation) - import nla.* % required due to matlab package system quirks - inputs = {inputField.Integer('behavior_count', 'Test count:', 1, 1, Inf), inputField.Number('prob_max', 'Net-level P threshold <', 0, 0.05, 1)}; + inputs = {nla.inputField.Integer('behavior_count', 'Test count:', 1, 1, Inf),... + nla.inputField.Number('prob_max', 'Net-level P threshold <', 0, 0.05, 1)}; end end methods (Access = protected) - function [cm, plot_mat, plot_max, name_label, sig_increasing, plot_sig] = genProbPlotParams(obj, input_struct, net_atlas, plot_prob, plot_sig_filter, name_formatted, plot_name, fdr_correction, method) - import nla.* % required due to matlab package system quirks + function [cm, plot_mat, plot_max, name_label, sig_increasing, plot_sig] = genProbPlotParams(... + obj, input_struct, net_atlas, plot_prob, plot_sig_filter, name_formatted, plot_name, fdr_correction, method... + ) + import nla.TriMatrix nla.TriMatrixDiag nla.gfx.ProbPlotMethod % if no filter is provided on which net-pairs should be % significant, create a mask of all true values @@ -75,7 +76,7 @@ function merge(obj, ~, ~, ~, ~, results) plot_sig_filter.v = true(numel(plot_sig_filter.v), 1); end - if input_struct.prob_plot_method == gfx.ProbPlotMethod.NEG_LOG_10 + if input_struct.prob_plot_method == ProbPlotMethod.NEG_LOG_10 plot_name = sprintf('%s (-log_1_0(P))', plot_name); end @@ -95,7 +96,7 @@ function merge(obj, ~, ~, ~, ~, results) plot_prob_sc = TriMatrix(net_atlas.numNets(), 'double', TriMatrixDiag.KEEP_DIAGONAL); plot_prob_sc.v = plot_prob.v .* (discrete_colors_count / (discrete_colors_count + 1)); - if input_struct.prob_plot_method == gfx.ProbPlotMethod.LOG + if input_struct.prob_plot_method == ProbPlotMethod.LOG min_log = log10(min(nonzeros(plot_prob.v))); if min_log < -40 min_log = -40; @@ -111,9 +112,9 @@ function merge(obj, ~, ~, ~, ~, results) plot_mat = plot_prob_sc; plot_max = p_max; sig_increasing = false; - elseif input_struct.prob_plot_method == gfx.ProbPlotMethod.NEG_LOG_10 + elseif input_struct.prob_plot_method == ProbPlotMethod.NEG_LOG_10 cm = parula(discrete_colors_count); - plot_mat = nla.TriMatrix(net_atlas.numNets(), 'double', nla.TriMatrixDiag.KEEP_DIAGONAL); + plot_mat = TriMatrix(net_atlas.numNets(), 'double', TriMatrixDiag.KEEP_DIAGONAL); plot_mat.v = -1 * log10(plot_prob.v); if method == nla.Method.FULL_CONN || method == nla.Method.WITHIN_NET_PAIR plot_max = 2; @@ -135,20 +136,23 @@ function merge(obj, ~, ~, ~, ~, results) end end - function [w, h] = plotProb(obj, edge_input_struct, input_struct, net_atlas, fig, x, y, plot_prob, plot_sig_filter, plot_name, fdr_correction, method, edge_result, ax) - import nla.* % required due to matlab package system quirks + function [w, h] = plotProb(obj, edge_input_struct, input_struct, net_atlas, fig, x, y, plot_prob,... + plot_sig_filter, plot_name, fdr_correction, method, edge_result, ax) %% callback function function brainFigsButtonClickedCallback(net1, net2) - f = waitbar(0.05, sprintf('Generating %s - %s net-pair brain plot', net_atlas.nets(net1).name, net_atlas.nets(net2).name)); - gfx.drawBrainVis(edge_input_struct, input_struct, net_atlas, gfx.MeshType.STD, 0.25, 3, true, edge_result, net1, net2, isa(obj, 'nla.net.BaseSigResult')); + f = waitbar(0.05, sprintf('Generating %s - %s net-pair brain plot', net_atlas.nets(net1).name,... + net_atlas.nets(net2).name)); + gfx.drawBrainVis(edge_input_struct, input_struct, net_atlas, nla.gfx.MeshType.STD, 0.25, 3, true,... + edge_result, net1, net2, isa(obj, 'nla.net.BaseSigResult')); waitbar(0.95); close(f) end %% trimatrix plot - [cm, plot_mat, plot_max, name_label, ~, plot_sig] = genProbPlotParams(obj, input_struct, net_atlas, plot_prob, plot_sig_filter, obj.name_formatted, plot_name, fdr_correction, method); - matrix_plot = gfx.plots.MatrixPlot(fig, name_label, plot_mat, net_atlas.nets, gfx.FigSize.SMALL,... + [cm, plot_mat, plot_max, name_label, ~, plot_sig] = genProbPlotParams(obj, input_struct, net_atlas,... + plot_prob, plot_sig_filter, obj.name_formatted, plot_name, fdr_correction, method); + matrix_plot = nla.gfx.plots.MatrixPlot(fig, name_label, plot_mat, net_atlas.nets, nla.gfx.FigSize.SMALL,... 'network_clicked_callback', @brainFigsButtonClickedCallback, 'marked_networks', plot_sig, 'draw_legend', false,... 'color_map', cm, 'lower_limit', 0, 'upper_limit', plot_max, 'x_position', x, 'y_position', y); matrix_plot.displayImage(); @@ -156,9 +160,11 @@ function brainFigsButtonClickedCallback(net1, net2) h = matrix_plot.image_dimensions("image_height"); end - function genChordPlotFig(obj, edge_input_struct, input_struct, net_atlas, edge_result, plot_sig, plot_mat, plot_max, cm, name_label, sig_increasing, chord_type) - import nla.* % required due to matlab package system quirks - + function genChordPlotFig(obj, edge_input_struct, input_struct, net_atlas, edge_result, plot_sig, plot_mat,... + plot_max, cm, name_label, sig_increasing, chord_type) + import nla.gfx.SigType nla.gfx.EdgeChordPlotMethod + import nla.TriMatrix nla.TriMatrixDiag + ax_width = 750; trimat_width = 500; bottom_text_height = 250; @@ -171,16 +177,16 @@ function genChordPlotFig(obj, edge_input_struct, input_struct, net_atlas, edge_r %% Chord plot if chord_type == nla.PlotType.CHORD - fig = gfx.createFigure(ax_width + trimat_width, ax_width); + fig = nla.gfx.createFigure(ax_width + trimat_width, ax_width); ax = axes(fig, 'Units', 'pixels', 'Position', [trimat_width, 0, ax_width, ax_width]); - gfx.hideAxes(ax); + nla.gfx.hideAxes(ax); if sig_increasing - sig_type = gfx.SigType.INCREASING; + sig_type = SigType.INCREASING; insignificant = coeff_bounds(1); else - sig_type = gfx.SigType.DECREASING; + sig_type = SigType.DECREASING; insignificant = coeff_bounds(2); end @@ -196,63 +202,75 @@ function genChordPlotFig(obj, edge_input_struct, input_struct, net_atlas, edge_r if isfield(input_struct, 'edge_chord_plot_method') edge_plot_type = input_struct.edge_chord_plot_method; else - edge_plot_type = gfx.EdgeChordPlotMethod.PROB; + edge_plot_type = EdgeChordPlotMethod.PROB; end - split_plot = (edge_plot_type == gfx.EdgeChordPlotMethod.COEFF_SPLIT || edge_plot_type == gfx.EdgeChordPlotMethod.COEFF_BASE_SPLIT); + split_plot = (edge_plot_type == EdgeChordPlotMethod.COEFF_SPLIT ||... + edge_plot_type == EdgeChordPlotMethod.COEFF_BASE_SPLIT); range_limit = std(edge_result.coeff.v) * 5; coeff_min = -range_limit; coeff_max = range_limit; vals_clipped = TriMatrix(net_atlas.numROIs(), TriMatrixDiag.REMOVE_DIAGONAL); - if edge_plot_type == gfx.EdgeChordPlotMethod.COEFF + if edge_plot_type == EdgeChordPlotMethod.COEFF cm_edge = turbo(1000); vals_clipped.v = edge_result.coeff.v; - sig_type = gfx.SigType.ABS_INCREASING; + sig_type = SigType.ABS_INCREASING; insig = 0; - title_main = sprintf("Edge-level correlation (P < %g) (Within Significant Net-Pair)", edge_result.prob_max); - elseif edge_plot_type == gfx.EdgeChordPlotMethod.COEFF_SPLIT + title_main = sprintf("Edge-level correlation (P < %g) (Within Significant Net-Pair)",... + edge_result.prob_max); + + elseif edge_plot_type == EdgeChordPlotMethod.COEFF_SPLIT cm_edge = turbo(1000); vals_clipped_pos = TriMatrix(net_atlas.numROIs(), TriMatrixDiag.REMOVE_DIAGONAL); vals_clipped_pos.v = edge_result.coeff.v; vals_clipped_pos.v(edge_result.coeff.v < 0) = 0; vals_clipped.v = edge_result.coeff.v; vals_clipped.v(edge_result.coeff.v > 0) = 0; - sig_type = gfx.SigType.ABS_INCREASING; + sig_type = SigType.ABS_INCREASING; insig = 0; - title_main = sprintf("Negative edge-level correlation (P < %g) (Within Significant Net-Pair)", edge_result.prob_max); - title_pos_main = sprintf("Positive edge-level correlation (P < %g) (Within Significant Net-Pair)", edge_result.prob_max); - elseif edge_plot_type == gfx.EdgeChordPlotMethod.COEFF_BASE_SPLIT + title_main = sprintf("Negative edge-level correlation (P < %g) (Within Significant Net-Pair)",... + edge_result.prob_max); + title_pos_main = sprintf("Positive edge-level correlation (P < %g) (Within Significant Net-Pair)",... + edge_result.prob_max); + + elseif edge_plot_type == EdgeChordPlotMethod.COEFF_BASE_SPLIT cm_edge = turbo(1000); vals_clipped_pos = TriMatrix(net_atlas.numROIs(), TriMatrixDiag.REMOVE_DIAGONAL); vals_clipped_pos.v = edge_result.coeff.v; vals_clipped_pos.v(edge_result.coeff.v < 0) = 0; vals_clipped.v = edge_result.coeff.v; vals_clipped.v(edge_result.coeff.v > 0) = 0; - sig_type = gfx.SigType.ABS_INCREASING; + sig_type = SigType.ABS_INCREASING; coeff_min = edge_result.coeff_range(1); coeff_max = edge_result.coeff_range(2); insig = 0; - title_main = sprintf("Negative edge-level correlation (P < %g) (Within Significant Net-Pair)", edge_result.prob_max); - title_pos_main = sprintf("Positive edge-level correlation (P < %g) (Within Significant Net-Pair)", edge_result.prob_max); - elseif edge_plot_type == gfx.EdgeChordPlotMethod.COEFF_BASE + title_main = sprintf("Negative edge-level correlation (P < %g) (Within Significant Net-Pair)",... + edge_result.prob_max); + title_pos_main = sprintf("Positive edge-level correlation (P < %g) (Within Significant Net-Pair)",... + edge_result.prob_max); + + elseif edge_plot_type == EdgeChordPlotMethod.COEFF_BASE cm_edge = turbo(1000); vals_clipped.v = edge_result.coeff.v; - sig_type = gfx.SigType.ABS_INCREASING; + sig_type = SigType.ABS_INCREASING; coeff_min = edge_result.coeff_range(1); coeff_max = edge_result.coeff_range(2); insig = 0; - title_main = sprintf("Edge-level correlation coefficient (P < %g) (Within Significant Net-Pair)", edge_result.prob_max); + title_main = sprintf("Edge-level correlation coefficient (P < %g) (Within Significant Net-Pair)",... + edge_result.prob_max); + else cm_edge_base = parula(1000); cm_edge = flip(cm_edge_base(ceil(logspace(-3, 0, 1000) .* 1000), :)); vals_clipped.v = edge_result.prob.v; - sig_type = gfx.SigType.DECREASING; + sig_type = SigType.DECREASING; coeff_min = 0; coeff_max = edge_result.prob_max; insig = 1; - title_main = sprintf("Edge-level P-values (P < %g) (Within Significant Net-Pair)", edge_result.prob_max); + title_main = sprintf("Edge-level P-values (P < %g) (Within Significant Net-Pair)",... + edge_result.prob_max); end % threshold out insignificant networks @@ -268,31 +286,33 @@ function genChordPlotFig(obj, edge_input_struct, input_struct, net_atlas, edge_r end if split_plot - fig = gfx.createFigure((ax_width * 2) + trimat_width - 100, ax_width); + fig = nla.gfx.createFigure((ax_width * 2) + trimat_width - 100, ax_width); else - fig = gfx.createFigure(ax_width + trimat_width, ax_width); + fig = nla.gfx.createFigure(ax_width + trimat_width, ax_width); end ax = axes(fig, 'Units', 'pixels', 'Position', [trimat_width, 0, ax_width - 50, ax_width - 50]); - gfx.hideAxes(ax); + nla.gfx.hideAxes(ax); ax.Visible = true; % to show title if split_plot % plot positive chord positive_chord_plotter = nla.gfx.chord.ChordPlot(net_atlas, ax, 450, vals_clipped_pos,... - 'direction', sig_type, 'color_map', cm_edge, 'chord_type', chord_type, 'upper_limit', coeff_max, 'lower_limit', coeff_min); + 'direction', sig_type, 'color_map', cm_edge, 'chord_type', chord_type, 'upper_limit', coeff_max,... + 'lower_limit', coeff_min); positive_chord_plotter.drawChords(); - gfx.setTitle(ax, title_pos_main); + nla.gfx.setTitle(ax, title_pos_main); % make new axes for other chord plot, shifted right ax = axes(fig, 'Units', 'pixels', 'Position', [trimat_width + ax_width - 100, 0, ax_width - 50, ax_width - 50]); - gfx.hideAxes(ax); + nla.gfx.hideAxes(ax); ax.Visible = true; % to show title end - chord_plotter = nla.gfx.chord.ChordPlot(net_atlas, ax, 450, vals_clipped, 'direction', sig_type, 'color_map', cm_edge, 'upper_limit', coeff_max, 'lower_limit', coeff_min, 'chord_type', chord_type); + chord_plotter = nla.gfx.chord.ChordPlot(net_atlas, ax, 450, vals_clipped, 'direction', sig_type,... + 'color_map', cm_edge, 'upper_limit', coeff_max, 'lower_limit', coeff_min, 'chord_type', chord_type); chord_plotter.drawChords(); - gfx.setTitle(ax, title_main); + nla.gfx.setTitle(ax, title_main); colormap(ax, cm_edge); cb = colorbar(ax); @@ -317,7 +337,8 @@ function genChordPlotFig(obj, edge_input_struct, input_struct, net_atlas, edge_r %% Trimatrix plot function brainFigsButtonClickedCallback(net1, net2) f = waitbar(0.05, sprintf('Generating %s - %s net-pair brain plot', net_atlas.nets(net1).name, net_atlas.nets(net2).name)); - gfx.drawBrainVis(edge_input_struct, input_struct, net_atlas, gfx.MeshType.STD, 0.25, 3, true, edge_result, net1, net2, isa(obj, 'nla.net.BaseSigResult')); + nla.gfx.drawBrainVis(edge_input_struct, input_struct, net_atlas, gfx.MeshType.STD, 0.25, 3, true, edge_result,... + net1, net2, isa(obj, 'nla.net.BaseSigResult')); waitbar(0.95); close(f) end @@ -328,7 +349,7 @@ function brainFigsButtonClickedCallback(net1, net2) %% Plot names text_ax = axes(fig, 'Units', 'pixels', 'Position', [55, bottom_text_height + 15, 450, 75]); - gfx.hideAxes(text_ax); + nla.gfx.hideAxes(text_ax); info_text = "Click any net-pair in the above plot to view its edge-level correlations."; if chord_type == nla.PlotType.CHORD_EDGE info_text = sprintf("%s\n\nChord plot:\nEach ROI is marked by a dot next to its corresponding network.\nROIs are placed in increasing order counter-clockwise, the first ROI in\na network being the most clockwise, the last being the most counter-\nclockwise.", info_text); @@ -336,14 +357,18 @@ function brainFigsButtonClickedCallback(net1, net2) text(text_ax, 0, 0, info_text, 'HorizontalAlignment', 'left', 'VerticalAlignment', 'top'); end - function plotChord(obj, edge_input_struct, input_struct, net_atlas, plot_prob, plot_sig_filter, plot_name, fdr_correction, method, edge_result, chord_type) - import nla.* % required due to matlab package system quirks - [cm, plot_mat, plot_max, name_label, sig_increasing, plot_sig] = genProbPlotParams(obj, input_struct, net_atlas, plot_prob, plot_sig_filter, obj.name_formatted, plot_name, fdr_correction, method); - genChordPlotFig(obj, edge_input_struct, input_struct, net_atlas, edge_result, plot_sig, plot_mat, plot_max, cm, name_label, sig_increasing, chord_type); + function plotChord(obj, edge_input_struct, input_struct, net_atlas, plot_prob, plot_sig_filter, plot_name,... + fdr_correction, method, edge_result, chord_type) + + [cm, plot_mat, plot_max, name_label, sig_increasing, plot_sig] = genProbPlotParams(obj, input_struct,... + net_atlas, plot_prob, plot_sig_filter, obj.name_formatted, plot_name, fdr_correction, method); + genChordPlotFig(obj, edge_input_struct, input_struct, net_atlas, edge_result, plot_sig, plot_mat, plot_max,... + cm, name_label, sig_increasing, chord_type); end function net_size = getNetSizes(obj, net_atlas) - import nla.* % required due to matlab package system quirks + import nla.TriMatrix nla.TriMatrixDiag + ROI_pairs = TriMatrix(net_atlas.numROIs(), 'logical'); net_size = TriMatrix(net_atlas.numNets(), TriMatrixDiag.KEEP_DIAGONAL); for row = 1:net_atlas.numNets() @@ -358,7 +383,6 @@ function plotPermProbVsNetSize(obj, net_atlas, ax) end function plotValsVsNetSize(obj, net_atlas, ax, prob, title_label, y_label, val_name) - import nla.* % required due to matlab package system quirks if ~exist('val_name', 'var'), val_name = 'P-values'; end @@ -378,8 +402,8 @@ function plotValsVsNetSize(obj, net_atlas, ax, prob, title_label, y_label, val_n xlabel(ax, 'Number of ROI pairs within network pair') ylabel(ax, y_label) [r, p] = corr(net_size.v, p_val); - gfx.setTitle(ax, title_label); - gfx.setTitle(ax, sprintf('Check if %s correlate with net-pair size\n(corr: p = %.2f, r = %.2f)', val_name, p, r), true); + nla.gfx.setTitle(ax, title_label); + nla.gfx.setTitle(ax, sprintf('Check if %s correlate with net-pair size\n(corr: p = %.2f, r = %.2f)', val_name, p, r), true); lims = ylim(ax); ylim(ax, [0 lims(2)]); end diff --git a/+nla/+net/BaseResult.m b/+nla/+net/BaseResult.m index e508a559..a0987ce2 100755 --- a/+nla/+net/BaseResult.m +++ b/+nla/+net/BaseResult.m @@ -13,18 +13,16 @@ methods function obj = BaseResult(size) - import nla.* % required due to matlab package system quirks obj@nla.net.BasePermResult(size); % non-permuted stats - obj.prob = TriMatrix(size, TriMatrixDiag.KEEP_DIAGONAL); + obj.prob = nla.TriMatrix(size, nla.TriMatrixDiag.KEEP_DIAGONAL); % permuted stats - obj.perm_prob_hist = zeros(HistBin.SIZE, 'uint32'); + obj.perm_prob_hist = zeros(nla.HistBin.SIZE, 'uint32'); end function output(obj, edge_input_struct, input_struct, net_atlas, edge_result, flags) - import nla.* % required due to matlab package system quirks if obj.perm_count == 0 if isfield(flags, 'show_nonpermuted') && flags.show_nonpermuted if flags.plot_type == nla.PlotType.FIGURE @@ -35,33 +33,39 @@ function output(obj, edge_input_struct, input_struct, net_atlas, edge_result, fl obj.plotProbVsNetSize(net_atlas, subplot(2,1,2)); %% Matrix with significant networks marked - obj.plotProb(edge_input_struct, input_struct, net_atlas, fig, 0, 425, obj.prob, false, sprintf('Non-permuted Method\nNon-permuted Significance'), input_struct.fdr_correction, nla.Method.NONPERMUTED, edge_result); + obj.plotProb(edge_input_struct, input_struct, net_atlas, fig, 0, 425, obj.prob, false,... + sprintf('Non-permuted Method\nNon-permuted Significance'), input_struct.fdr_correction,... + nla.Method.NONPERMUTED, edge_result); elseif flags.plot_type == nla.PlotType.CHORD || flags.plot_type == nla.PlotType.CHORD_EDGE - obj.plotChord(edge_input_struct, input_struct, net_atlas, obj.prob, false, sprintf('Non-permuted Method\nNon-permuted Significance'), input_struct.fdr_correction, nla.Method.NONPERMUTED, edge_result, flags.plot_type); + obj.plotChord(edge_input_struct, input_struct, net_atlas, obj.prob, false,... + sprintf('Non-permuted Method\nNon-permuted Significance'), input_struct.fdr_correction,... + nla.Method.NONPERMUTED, edge_result, flags.plot_type); end end end end function [num_tests, sig_count_mat, names] = getSigMat(obj, input_struct, net_atlas, flags) - import nla.* % required due to matlab package system quirks num_tests = 0; - sig_count_mat = TriMatrix(net_atlas.numNets(), 'double', TriMatrixDiag.KEEP_DIAGONAL); + sig_count_mat = nla.TriMatrix(net_atlas.numNets(), 'double', nla.TriMatrixDiag.KEEP_DIAGONAL); names = []; if obj.perm_count == 0 if isfield(flags, 'show_nonpermuted') && flags.show_nonpermuted - [sig, name] = obj.singleSigMat(net_atlas, input_struct, obj.prob, input_struct.fdr_correction, "Non-Permuted"); + [sig, name] = obj.singleSigMat(net_atlas, input_struct, obj.prob, input_struct.fdr_correction,... + "Non-Permuted"); [num_tests, sig_count_mat, names] = obj.appendSigMat(num_tests, sig_count_mat, names, sig, name); end else if isfield(flags, 'show_full_conn') && flags.show_full_conn - [sig, name] = obj.singleSigMat(net_atlas, input_struct, obj.perm_prob_ew, net.mcc.None, "Full Connectome"); + [sig, name] = obj.singleSigMat(net_atlas, input_struct, obj.perm_prob_ew, net.mcc.None,... + "Full Connectome"); [num_tests, sig_count_mat, names] = obj.appendSigMat(num_tests, sig_count_mat, names, sig, name); end if isfield(flags, 'show_within_net_pair') && flags.show_within_net_pair - [sig, name] = obj.singleSigMat(net_atlas, input_struct, obj.within_np_prob, input_struct.fdr_correction, "Within Net-Pair"); + [sig, name] = obj.singleSigMat(net_atlas, input_struct, obj.within_np_prob, input_struct.fdr_correction,... + "Within Net-Pair"); [num_tests, sig_count_mat, names] = obj.appendSigMat(num_tests, sig_count_mat, names, sig, name); end end @@ -69,7 +73,6 @@ function output(obj, edge_input_struct, input_struct, net_atlas, edge_result, fl % merged is a function which merges 2 results from the same test function merge(obj, input_struct, edge_result_nonperm, edge_result, net_atlas, results) - import nla.* % required due to matlab package system quirks merge@nla.net.BasePermResult(obj, input_struct, edge_result_nonperm, edge_result, net_atlas, results); % Histogram @@ -87,18 +90,18 @@ function merge(obj, input_struct, edge_result_nonperm, edge_result, net_atlas, r end function [sig, name] = singleSigMat(obj, net_atlas, input_struct, prob, mcc_method, title_prepend) - import nla.* % required due to matlab package system quirks p_max = mcc_method.correct(net_atlas, input_struct, prob); p_breakdown_label = mcc_method.createLabel(net_atlas, input_struct, prob); - sig = TriMatrix(net_atlas.numNets(), 'double', TriMatrixDiag.KEEP_DIAGONAL); + sig = nla.TriMatrix(net_atlas.numNets(), 'double', nla.TriMatrixDiag.KEEP_DIAGONAL); sig.v = (prob.v < p_max); name = sprintf("%s %s P < %.2g (%s)", title_prepend, obj.name, p_max, p_breakdown_label); end function plotProbHist(obj, ax, prob_max) - import nla.* % required due to matlab package system quirks + import nla.HistBin + empirical_fdr = zeros(HistBin.SIZE); empirical_fdr = cumsum(double(obj.perm_prob_hist) ./ sum(obj.perm_prob_hist)); [~, min_idx]= min(abs(prob_max - empirical_fdr)); @@ -115,13 +118,12 @@ function plotProbHist(obj, ax, prob_max) loglog(ax, [prob_max_ew, prob_max_ew], ax.YLim, 'r'); name_label = sprintf("%s P-values", obj.name_formatted); - gfx.setTitle(ax, name_label); + nla.gfx.setTitle(ax, name_label); xlabel(ax, 'Asymptotic'); ylabel(ax, 'Permutation-based P-value'); end function plotProbVsNetSize(obj, net_atlas, ax) - import nla.* % required due to matlab package system quirks net_size = obj.getNetSizes(net_atlas); p_val = -log10(obj.prob.v); @@ -139,14 +141,16 @@ function plotProbVsNetSize(obj, net_atlas, ax) xlabel(ax, 'Number of ROI pairs within network pair') ylabel(ax, '-log_1_0(Asymptotic P-value)') [r, p] = corr(net_size.v, p_val); - gfx.setTitle(ax, 'Non-permuted P-values vs. Net-Pair Size'); - gfx.setTitle(ax, sprintf('Check if P-values correlate with net-pair size\n(corr: p = %.2f, r = %.2f)', p, r), true); + nla.gfx.setTitle(ax, 'Non-permuted P-values vs. Net-Pair Size'); + nla.gfx.setTitle(ax, sprintf('Check if P-values correlate with net-pair size\n(corr: p = %.2f, r = %.2f)',... + p, r), true); lims = ylim(ax); ylim(ax, [0 lims(2)]); end function plotWithinNetPairProbVsNetSize(obj, net_atlas, ax) - plotValsVsNetSize(obj, net_atlas, ax, obj.within_np_prob, 'Within Net-Pair P-values vs. Net-Pair Size', '-log_1_0(Within Net-Pair P-value)'); + plotValsVsNetSize(obj, net_atlas, ax, obj.within_np_prob, 'Within Net-Pair P-values vs. Net-Pair Size',... + '-log_1_0(Within Net-Pair P-value)'); end end end diff --git a/+nla/+net/BaseSigResult.m b/+nla/+net/BaseSigResult.m index 72b0cf3a..731a8755 100755 --- a/+nla/+net/BaseSigResult.m +++ b/+nla/+net/BaseSigResult.m @@ -9,20 +9,18 @@ methods function obj = BaseSigResult(size) - import nla.* % required due to matlab package system quirks obj@nla.net.BaseResult(size); - obj.observed_gt_expected = TriMatrix(size, 'logical', TriMatrixDiag.KEEP_DIAGONAL); + obj.observed_gt_expected = nla.TriMatrix(size, 'logical', nla.TriMatrixDiag.KEEP_DIAGONAL); end function output(obj, edge_input_struct, input_struct, net_atlas, edge_result, flags) - import nla.* % required due to matlab package system quirks output@nla.net.BaseResult(obj, edge_input_struct, input_struct, net_atlas, edge_result, flags); if obj.perm_count > 0 if isfield(flags, 'show_full_conn') && flags.show_full_conn if flags.plot_type == nla.PlotType.FIGURE - fig = gfx.createFigure(1000, 900); + fig = nla.gfx.createFigure(1000, 900); %% Histogram of probabilities, with thresholds marked obj.plotProbHist(subplot(2,2,2), input_struct.prob_max); @@ -32,19 +30,27 @@ function output(obj, edge_input_struct, input_struct, net_atlas, edge_result, fl obj.plotPermProbVsNetSize(net_atlas, subplot(2,2,4)); %% Matrix with significant networks marked - obj.plotProb(edge_input_struct, input_struct, net_atlas, fig, 25, 425, obj.perm_prob_ew, false, sprintf('Full Connectome Method\nNetwork vs. Connectome Significance'), net.mcc.None(), nla.Method.FULL_CONN, edge_result); + obj.plotProb(edge_input_struct, input_struct, net_atlas, fig, 25, 425, obj.perm_prob_ew, false,... + sprintf('Full Connectome Method\nNetwork vs. Connectome Significance'), nla.net.mcc.None(),... + nla.Method.FULL_CONN, edge_result); elseif flags.plot_type == nla.PlotType.CHORD || flags.plot_type == nla.PlotType.CHORD_EDGE - obj.plotChord(edge_input_struct, input_struct, net_atlas, obj.perm_prob_ew, false, sprintf('Full Connectome Method\nNetwork vs. Connectome Significance'), net.mcc.None(), nla.Method.FULL_CONN, edge_result, flags.plot_type); + obj.plotChord(edge_input_struct, input_struct, net_atlas, obj.perm_prob_ew, false,... + sprintf('Full Connectome Method\nNetwork vs. Connectome Significance'), nla.net.mcc.None(),... + nla.Method.FULL_CONN, edge_result, flags.plot_type); end end if isfield(flags, 'show_within_net_pair') && flags.show_within_net_pair if flags.plot_type == nla.PlotType.FIGURE %% Within Net-Pair statistics (withinNP) - fig = gfx.createFigure(500, 900); + fig = nla.gfx.createFigure(500, 900); obj.plotWithinNetPairProbVsNetSize(net_atlas, subplot(2,1,2)); - obj.plotProb(edge_input_struct, input_struct, net_atlas, fig, 0, 425, obj.within_np_prob, false, sprintf('Within Network Pair Method\nNetwork Pair vs. Permuted Network Pair'), input_struct.fdr_correction, nla.Method.WITHIN_NET_PAIR, edge_result); + obj.plotProb(edge_input_struct, input_struct, net_atlas, fig, 0, 425, obj.within_np_prob, false,... + sprintf('Within Network Pair Method\nNetwork Pair vs. Permuted Network Pair'),... + input_struct.fdr_correction, nla.Method.WITHIN_NET_PAIR, edge_result); elseif flags.plot_type == nla.PlotType.CHORD || flags.plot_type == nla.PlotType.CHORD_EDGE - obj.plotChord(edge_input_struct, input_struct, net_atlas, obj.within_np_prob, false, sprintf('Within Network Pair Method\nNetwork Pair vs. Permuted Network Pair'), input_struct.fdr_correction, nla.Method.WITHIN_NET_PAIR, edge_result, flags.plot_type); + obj.plotChord(edge_input_struct, input_struct, net_atlas, obj.within_np_prob, false,... + sprintf('Within Network Pair Method\nNetwork Pair vs. Permuted Network Pair'),... + input_struct.fdr_correction, nla.Method.WITHIN_NET_PAIR, edge_result, flags.plot_type); end end end @@ -52,10 +58,13 @@ function output(obj, edge_input_struct, input_struct, net_atlas, edge_result, fl end methods (Access = protected) - function genChordPlotFig(obj, edge_input_struct, input_struct, net_atlas, edge_result, plot_sig, plot_mat, plot_max, cm, name_label, sig_increasing, chord_type) + function genChordPlotFig(obj, edge_input_struct, input_struct, net_atlas, edge_result, plot_sig, plot_mat,... + plot_max, cm, name_label, sig_increasing, chord_type) + edge_result_thresh = copy(edge_result); edge_result_thresh.coeff.v(edge_result_thresh.prob_sig.v == 0) = 0; - genChordPlotFig@nla.net.BaseResult(obj, edge_input_struct, input_struct, net_atlas, edge_result_thresh, plot_sig, plot_mat, plot_max, cm, name_label, sig_increasing, chord_type) + genChordPlotFig@nla.net.BaseResult(obj, edge_input_struct, input_struct, net_atlas, edge_result_thresh,... + plot_sig, plot_mat, plot_max, cm, name_label, sig_increasing, chord_type) end end end \ No newline at end of file diff --git a/+nla/+net/BaseSigTest.m b/+nla/+net/BaseSigTest.m index 35a0a312..db13d6f3 100755 --- a/+nla/+net/BaseSigTest.m +++ b/+nla/+net/BaseSigTest.m @@ -1,7 +1,6 @@ classdef BaseSigTest < nla.net.BaseTest methods function obj = BaseSigTest() - import nla.* % required due to matlab package system quirks obj@nla.net.BaseTest(); end end diff --git a/+nla/+net/BaseTest.m b/+nla/+net/BaseTest.m index 4a65ace2..5d5be31b 100755 --- a/+nla/+net/BaseTest.m +++ b/+nla/+net/BaseTest.m @@ -7,7 +7,6 @@ methods function obj = BaseTest() - import nla.* % required due to matlab package system quirks end end @@ -18,18 +17,19 @@ methods (Static) function inputs = requiredInputs() % Inputs that must be provided to run the test - import nla.* % required due to matlab package system quirks - inputs = {inputField.Integer('behavior_count', 'Test count:', 1, 1, Inf), inputField.Number('prob_max', 'Net-level P threshold <', 0, 0.05, 1)}; + inputs = {nla.inputField.Integer('behavior_count', 'Test count:', 1, 1, Inf),... + nla.inputField.Number('prob_max', 'Net-level P threshold <', 0, 0.05, 1)}; end - function result = rank(net_atlas, result, input_struct, sig_func, stat, stat_prob, stat_perm, stat_prob_perm, stat_ss, stat_ss_prob, stat_ss_perm, stat_ss_prob_perm) + function result = rank(net_atlas, result, input_struct, sig_func, stat, stat_prob, stat_perm, stat_prob_perm,... + stat_ss, stat_ss_prob, stat_ss_perm, stat_ss_prob_perm) %RANK Rank test statistics against non-permuted equivelents and % add on to the relevant ranking fields (later used to % calculate p-values, in the result merge() step) - import nla.* % required due to matlab package system quirks + import nla.ACCURACY_MARGIN stat_ranking = false; - if ~isfield(input_struct, 'ranking_method') || input_struct.ranking_method == RankingMethod.TEST_STATISTIC + if ~isfield(input_struct, 'ranking_method') || input_struct.ranking_method == nla.RankingMethod.TEST_STATISTIC stat_ranking = true; end @@ -73,7 +73,7 @@ % update histogram if ~islogical(stat_prob_perm) - result.perm_prob_hist = result.perm_prob_hist + uint32(histcounts(stat_prob_perm.v, HistBin.EDGES)'); + result.perm_prob_hist = result.perm_prob_hist + uint32(histcounts(stat_prob_perm.v, nla.HistBin.EDGES)'); end result.perm_count = result.perm_count + 1; diff --git a/+nla/+net/genBaseInputs.m b/+nla/+net/genBaseInputs.m index c2a4a2fe..a3ddafed 100755 --- a/+nla/+net/genBaseInputs.m +++ b/+nla/+net/genBaseInputs.m @@ -1,7 +1,9 @@ function inputs = genBaseInputs() %GENBASEINPUTS Generate struct of required network-level inputs with % reasonable default values - import nla.* - inputs = struct('nonpermuted', true, 'full_conn', true, 'within_net_pair', true, 'prob_plot_method', gfx.ProbPlotMethod.DEFAULT, 'ranking_method', RankingMethod.P_VALUE, 'edge_chord_plot_method', gfx.EdgeChordPlotMethod.PROB, 'fdr_correction', net.mcc.Bonferroni(), 'd_thresh_chord_plot', true); + + inputs = struct('nonpermuted', true, 'full_conn', true, 'within_net_pair', true, 'prob_plot_method',... + nla.gfx.ProbPlotMethod.DEFAULT, 'ranking_method', nla.RankingMethod.P_VALUE, 'edge_chord_plot_method',... + nla.gfx.EdgeChordPlotMethod.PROB, 'fdr_correction', nla.net.mcc.Bonferroni(), 'd_thresh_chord_plot', true); end diff --git a/+nla/+qualityControl/checkHeadMotion.m b/+nla/+qualityControl/checkHeadMotion.m index cede0feb..a09d25c1 100755 --- a/+nla/+qualityControl/checkHeadMotion.m +++ b/+nla/+qualityControl/checkHeadMotion.m @@ -1,9 +1,8 @@ function checkHeadMotion(fig, input_struct, motion) - import nla.* % required due to matlab package system quirks prog = uiprogressdlg(fig, 'Title', 'Generating figures', 'Message', 'Generating head motion figures'); prog.Value = 0.02; - distances = helpers.euclidianDistanceROIs(input_struct.net_atlas); + distances = nla.helpers.euclidianDistanceROIs(input_struct.net_atlas); prog.Value = 0.75; [r_vec, p_vec] = corr(motion, input_struct.func_conn.v', 'type', 'Pearson'); @@ -12,7 +11,7 @@ function checkHeadMotion(fig, input_struct, motion) h = nla.TriMatrix(input_struct.net_atlas.numROIs(), 'logical'); prob.v = p_vec'; r.v = r_vec'; - h.v = lib.fdr_bh(prob.v); + h.v = nla.lib.fdr_bh(prob.v); prog.Value = 0.98; @@ -21,11 +20,11 @@ function checkHeadMotion(fig, input_struct, motion) color_map = turbo(color_scale); mesh_alpha = 0.5; ROI_radius = 4; - ctx = gfx.MeshType.STD; + ctx = nla.gfx.MeshType.STD; llimit = -0.3; ulimit = 0.3; - fig = gfx.createFigure(1800, 900); + fig = nla.gfx.createFigure(1800, 900); matrix_plot = nla.gfx.plots.MatrixPlot(fig, "FC-motion correlation (Pearson's r)", r, input_struct.net_atlas.nets,... nla.gfx.FigSize.LARGE, 'lower_limit', llimit, 'upper_limit', ulimit); matrix_plot.displayImage(); @@ -35,8 +34,9 @@ function checkHeadMotion(fig, input_struct, motion) fig.Position(4) = height; ax = subplot('Position', [0.780, 0.540, 0.20, 0.40]); - gfx.setTitle(ax, sprintf("FC-motion correlation (Pearson's r) (q < 0.05)\n")); - gfx.drawROIsOnCortex(ax, input_struct.net_atlas, ctx, mesh_alpha, ROI_radius, gfx.ViewPos.DORSAL, false, gfx.BrainColorMode.NONE); + nla.gfx.setTitle(ax, sprintf("FC-motion correlation (Pearson's r) (q < 0.05)\n")); + nla.gfx.drawROIsOnCortex(ax, input_struct.net_atlas, ctx, mesh_alpha, ROI_radius, nla.gfx.ViewPos.DORSAL, false,... + nla.gfx.BrainColorMode.NONE); for col = 1:input_struct.net_atlas.numROIs() for row = (col + 1):input_struct.net_atlas.numROIs() @@ -44,7 +44,7 @@ function checkHeadMotion(fig, input_struct, motion) pos1 = input_struct.net_atlas.ROIs(row).pos; pos2 = input_struct.net_atlas.ROIs(col).pos; - edge_color = gfx.valToColor(r.get(row, col), llimit, ulimit, color_map); + edge_color = nla.gfx.valToColor(r.get(row, col), llimit, ulimit, color_map); p = plot3([pos1(1), pos2(1)], [pos1(2), pos2(2)], [pos1(3), pos2(3)], 'Color', edge_color, 'LineWidth', 2); p.Annotation.LegendInformation.IconDisplayStyle = 'off'; @@ -71,13 +71,13 @@ function checkHeadMotion(fig, input_struct, motion) %% Distribution of corr ax = subplot('Position', [0.525, 0.075, 0.1875, 0.425]); - gfx.setTitle(ax, "FC-Motion Correlation Histogram"); + nla.gfx.setTitle(ax, "FC-Motion Correlation Histogram"); histogram(ax, r_vec, 'EdgeColor', 'black', 'FaceColor', 'black'); xlabel(ax, 'FC-Motion Correlation (Pearson r)'); %% Heatmap of corr/distance ax = subplot('Position', [0.755, 0.075, 0.225, 0.425]); - gfx.setTitle(ax, "FC-Motion Correlation vs. ROI Distance"); + nla.gfx.setTitle(ax, "FC-Motion Correlation vs. ROI Distance"); [values, centers] = hist3([distances.v, r_vec'], [50, 50]); imagesc(ax, centers{:}, values'); xlabel(ax, 'Euclidian Distance'); @@ -98,8 +98,9 @@ function checkHeadMotion(fig, input_struct, motion) fc_motion_distance_corr = corr(r.v, distances.v); ax = subplot('Position', [0.525, 0.95, 0.1875, 0.40]); - gfx.hideAxes(ax); - text(ax, 0, 0, sprintf("Percent of significant edges: %0.2f%%\nMedian absolute correlation: %0.2f\nFC-motion-distance correlation: %0.2f", percent_sig, med_abs_corr, fc_motion_distance_corr), 'HorizontalAlignment', 'left', 'VerticalAlignment', 'top'); + nla.gfx.hideAxes(ax); + text(ax, 0, 0, sprintf("Percent of significant edges: %0.2f%%\nMedian absolute correlation: %0.2f\nFC-motion-distance correlation: %0.2f",... + percent_sig, med_abs_corr, fc_motion_distance_corr), 'HorizontalAlignment', 'left', 'VerticalAlignment', 'top'); close(prog); end diff --git a/+nla/+qualityControl/viewSilhouetteCoeff.m b/+nla/+qualityControl/viewSilhouetteCoeff.m index 35b79ec3..87ef1689 100755 --- a/+nla/+qualityControl/viewSilhouetteCoeff.m +++ b/+nla/+qualityControl/viewSilhouetteCoeff.m @@ -1,5 +1,4 @@ function viewSilhouetteCoeff(fig, input_struct, remove_index) - import nla.* % required due to matlab package system quirks prog = uiprogressdlg(fig, 'Title', 'Generating figures', 'Message', 'Calculating silhouette coefficient'); prog.Value = 0.02; @@ -20,13 +19,13 @@ function viewSilhouetteCoeff(fig, input_struct, remove_index) prog.Value = 0.25; %% Calculate silhouette coefficients - si_vals = silhouetteCoeff(fc_avg, nets); + si_vals = nla.silhouetteCoeff(fc_avg, nets); prog.Value = 0.98; %% Display FC average plot with average silhouette value in label plot_label = [plot_label sprintf('\nMean silhouette value = %2.3f', mean(si_vals))]; - fig = gfx.createFigure(); + fig = nla.gfx.createFigure(); matrix_plot = nla.gfx.plots.MatrixPlot(fig, plot_label, fc_avg, nets, nla.gfx.FigSize.LARGE); matrix_plot.displayImage(); w = matrix_plot.image_dimensions("image_width"); diff --git a/+nla/DeepCopyable.m b/+nla/DeepCopyable.m index 13344a69..43ce7779 100755 --- a/+nla/DeepCopyable.m +++ b/+nla/DeepCopyable.m @@ -1,7 +1,6 @@ classdef DeepCopyable < handle methods function new = copy(obj) - import nla.* % required due to matlab package system quirks %COPY Deep copy of an object objByteArray = getByteStreamFromArray(obj); new = getArrayFromByteStream(objByteArray); diff --git a/+nla/Network.m b/+nla/Network.m index fc4a9344..6fee4f06 100755 --- a/+nla/Network.m +++ b/+nla/Network.m @@ -9,7 +9,6 @@ methods function obj = Network(name, color, indexes) - import nla.* % required due to matlab package system quirks % Matlab doesn't support multiple constructors if nargin ~= 0 obj.name = name; @@ -19,7 +18,6 @@ end function addROI(obj, new_ROI) - import nla.* % required due to matlab package system quirks obj.indexes = [obj.indexes; new_ROI]; end diff --git a/+nla/NetworkAtlas.m b/+nla/NetworkAtlas.m index e51d30a2..471a8a7e 100755 --- a/+nla/NetworkAtlas.m +++ b/+nla/NetworkAtlas.m @@ -14,7 +14,6 @@ methods function obj = NetworkAtlas(fname) - import nla.* % required due to matlab package system quirks %% IM structure if ischar(fname) || isstring(fname) net_struct = load(fname); @@ -63,9 +62,9 @@ obj.ROI_order = uint32(net_struct.ROI_order); %% Networks - obj.nets = Network.empty(); + obj.nets = nla.Network.empty(); for i = 1:net_count - obj.nets(i) = Network(net_names{i}, net_colors(i,:), []); + obj.nets(i) = nla.Network(net_names{i}, net_colors(i,:), []); end % ensure column vector form obj.nets = obj.nets(:); @@ -78,7 +77,7 @@ %% Cortex anatomy try - obj.anat = CortexAnatomy(sprintf('%ssupport_files/meshes/%s.mat', findRootPath(), obj.space)); + obj.anat = nla.CortexAnatomy(sprintf('%ssupport_files/meshes/%s.mat', nla.findRootPath(), obj.space)); catch error("Could not load cortex anatomy - you may have forgotten to set the 'space' field in your Network Atlas") end @@ -103,23 +102,19 @@ end function val = numNets(obj) - import nla.* % required due to matlab package system quirks val = numel(obj.nets); end function val = numNetPairs(obj) - import nla.* % required due to matlab package system quirks - val = helpers.triNum(numel(obj.nets)); + val = nla.helpers.triNum(numel(obj.nets)); end function val = numROIs(obj) - import nla.* % required due to matlab package system quirks val = numel(obj.ROIs); end function val = numROIPairs(obj) - import nla.* % required due to matlab package system quirks - val = helpers.triNum(numel(obj.ROIs) - 1); + val = nla.helpers.triNum(numel(obj.ROIs) - 1); end end end diff --git a/+nla/ROI.m b/+nla/ROI.m index 99b4b668..1eeea526 100755 --- a/+nla/ROI.m +++ b/+nla/ROI.m @@ -10,7 +10,6 @@ methods function obj = ROI(pos) - import nla.* % required due to matlab package system quirks obj.pos = pos; end end diff --git a/+nla/ResultPool.m b/+nla/ResultPool.m index 6557adfb..5068e720 100755 --- a/+nla/ResultPool.m +++ b/+nla/ResultPool.m @@ -16,7 +16,6 @@ methods function obj = ResultPool(input_struct, net_input_struct, net_atlas, edge_result, net_results, perm_edge_result, perm_net_results) - import nla.* % required due to matlab package system quirks obj.input_struct = input_struct; obj.net_input_struct = net_input_struct; obj.net_atlas = net_atlas; @@ -24,13 +23,12 @@ obj.perm_edge_result = perm_edge_result; obj.net_results = net_results; obj.perm_net_results = perm_net_results; - obj.version = VERSION; - obj.commit = helpers.git.commitString(true); - obj.commit_short = helpers.git.commitString(); + obj.version = nla.VERSION; + obj.commit = nla.helpers.git.commitString(true); + obj.commit_short = nla.helpers.git.commitString(); end function output(obj) - import nla.* % required due to matlab package system quirks flags = struct(); flags.display_sig = obj.containsSigBasedNetworkResult(); obj.edge_result.output(obj.net_atlas, flags); @@ -52,11 +50,10 @@ function output(obj) end function val = containsSigBasedNetworkResult(obj) - import nla.* % required due to matlab package system quirks val = false; if ~islogical(obj.perm_net_results) for i = 1:size(obj.perm_net_results, 1) - if isa(obj.perm_net_results{i}, 'net.BaseSigResult') + if isa(obj.perm_net_results{i}, 'nla.net.BaseSigResult') val = true; end end @@ -64,15 +61,14 @@ function output(obj) end function to_file(obj, filename) - import nla.* % required due to matlab package system quirks results = obj; % also create a struct version of the results for compatibility - results_as_struct = helpers.classToStructRecursive(obj); + results_as_struct = nla.helpers.classToStructRecursive(obj); save(filename, 'results', 'results_as_struct', '-nocompression','-v7.3'); end function saveSummaryTable(obj, filename) - import nla.* % required due to matlab package system quirks + import nla.TriMatrix nla.TriMatrixDiag for n = 1:obj.net_atlas.numNets() net_name = obj.net_atlas.nets(n).name; @@ -101,7 +97,6 @@ function saveSummaryTable(obj, filename) methods (Static) function obj = from_file(filename) - import nla.* % required due to matlab package system quirks file_struct = load(filename); obj = file_struct.results; end diff --git a/+nla/TestPool.m b/+nla/TestPool.m index bb9bacc3..48b86766 100755 --- a/+nla/TestPool.m +++ b/+nla/TestPool.m @@ -10,7 +10,6 @@ methods function obj = TestPool() - import nla.* % required due to matlab package system quirks % this MUST be instantiated here it cannot be done in the % properties field because NLA cannot be imported when setting % things in the properties field, hence, NLA specific values diff --git a/+nla/TriMatrix.m b/+nla/TriMatrix.m index 46b5874c..4115dfae 100755 --- a/+nla/TriMatrix.m +++ b/+nla/TriMatrix.m @@ -18,7 +18,6 @@ methods (Access = private) function dims = elementDims(obj) - import nla.* % required due to matlab package system quirks full_dims = size(obj.v); dims = full_dims(2:end); end @@ -56,21 +55,18 @@ % end function calcIndexMatrix(obj) - import nla.* % required due to matlab package system quirks obj.index_matrix = zeros(obj.size, obj.size, 'uint32'); % we convert obj.size from uint32 to int32 here because matlab % doesn't understand integer promotion - obj.index_matrix(tril(true(obj.size, obj.size), obj.diag_offset)) = [1:helpers.triNum(int32(obj.size) + obj.diag_offset)]; + obj.index_matrix(tril(true(obj.size, obj.size), obj.diag_offset)) = [1:nla.helpers.triNum(int32(obj.size) + obj.diag_offset)]; end function ind = index(obj, row, col) - import nla.* % required due to matlab package system quirks ind = nonzeros(obj.index_matrix(row, col)); end end methods function obj = TriMatrix(varargin) - import nla.* % required due to matlab package system quirks %% Matlab argument parsing because of no default values for functions % Construct Trimatrix from first argument if it's a matrix, or % create an empty matrix if not @@ -88,7 +84,7 @@ function calcIndexMatrix(obj) typename = varargin{2}; end - obj.v = zeros(helpers.triNum(int32(obj.size) + obj.diag_offset), 1, typename); + obj.v = zeros(nla.helpers.triNum(int32(obj.size) + obj.diag_offset), 1, typename); else data = varargin{1}; @@ -128,21 +124,18 @@ function calcIndexMatrix(obj) function newTriMatrix = makeCopyFromSubset(obj, colsToCopy) %Make properly sized triMatrix with empty values - import nla.* % required due to matlab package system quirks newTriMatrix = nla.TriMatrix(obj.size, obj.diag_offset); newTriMatrix.v = obj.v(:,colsToCopy); end function returned = get(obj, row, col) % Return the elements at the given indices. The vector of - import nla.* % required due to matlab package system quirks indexes = obj.index(row, col); returned = obj.v(indexes, :); returned = squeeze(reshape(returned, [size(indexes, 1), obj.elementDims()])); end function set(obj, row, col, value) - import nla.* % required due to matlab package system quirks % Set the element at the index to the given value. % N-dimensional indexing is relatively slow so we handle common % cases specially @@ -161,7 +154,6 @@ function set(obj, row, col, value) end function returned = asMatrix(obj) - import nla.* % required due to matlab package system quirks %ASMATRIX Return the TriMatrixes contents in matrix form. Slow. % If the object is a numeric data type(or matrix thereof), preallocate % This is hideous but MATLAB(tm) does not allow array creation @@ -180,7 +172,6 @@ function set(obj, row, col, value) end function num = numElements(obj) - import nla.* % required due to matlab package system quirks num = size(obj.v, 1); end diff --git a/+nla/findRootPath.m b/+nla/findRootPath.m index 4bbd61c3..4ffa1797 100755 --- a/+nla/findRootPath.m +++ b/+nla/findRootPath.m @@ -1,6 +1,5 @@ function root_path = findRootPath() %FINDROOTPATH Find the root path of the NLA toolbox - import nla.* % required due to matlab package system quirks path_split = split(string(which('nla.VERSION')), "/"); path_joined = join(path_split(1:end-2), "/"); root_path = char(path_joined + "/"); diff --git a/+nla/genTests.m b/+nla/genTests.m index 3d1240b6..aaa7867d 100755 --- a/+nla/genTests.m +++ b/+nla/genTests.m @@ -2,8 +2,7 @@ %GENTESTS Generate cell array containing all tests in given subpackage % subpackage: dot-seperated subpackage name within NLA namespace, eg. % 'net.test' for net-level tests - import nla.* % required due to matlab package system quirks - root_path = findRootPath(); + root_path = nla.findRootPath(); rel_path = strrep(subpackage, '.', '/+'); path_to = [root_path '+nla/+' rel_path]; net_test_struct = dir(path_to); diff --git a/+nla/partialVariance.m b/+nla/partialVariance.m index 26034ea5..7a9ca2bb 100755 --- a/+nla/partialVariance.m +++ b/+nla/partialVariance.m @@ -10,10 +10,11 @@ % factoring covariates from it % behavior_residual: residual of behavioral scores, if factoring % covariates from them - import nla.* % required due to matlab package system quirks %% Control for Covariates %% % covariates are cov1, cov2... covN assumed to be column vectors %MW 1-3-2020 + import nla.PartialVarianceType + num_roi = func_conn.size; num_subs = size(func_conn.v, 2); num_covariates = size(covariates, 2); @@ -40,7 +41,7 @@ fcr = func_conn.v; end - func_conn_residual = TriMatrix(num_roi); + func_conn_residual = nla.TriMatrix(num_roi); func_conn_residual.v = fcr; if type == PartialVarianceType.FCBX || type == PartialVarianceType.ONLY_BX diff --git a/+nla/silhouetteCoeff.m b/+nla/silhouetteCoeff.m index a30ce48b..6cb20a54 100755 --- a/+nla/silhouetteCoeff.m +++ b/+nla/silhouetteCoeff.m @@ -5,7 +5,6 @@ % have a name, color, and a vector of indices corresponding to % data in the input matrix % si_vals: 1xNrois vector of silhouette values - import nla.* % required due to matlab package system quirks % tweak fc to fit the input format demanded by lib.calc_correlationdist fc_mat = fc_avg.asMatrix(); diff --git a/+nla/validateInputStruct.m b/+nla/validateInputStruct.m index b376bddb..3559c4a7 100755 --- a/+nla/validateInputStruct.m +++ b/+nla/validateInputStruct.m @@ -1,5 +1,4 @@ function [str, valid] = validateInputStruct(inp, str, valid) - import nla.* % required due to matlab package system quirks for i = 1:numel(inp) if ~inp{i}.satisfied valid = false; diff --git a/+nla/welchT.m b/+nla/welchT.m index 7ef7e661..dcc6c4da 100755 --- a/+nla/welchT.m +++ b/+nla/welchT.m @@ -1,6 +1,5 @@ function [p_vec, t_vec, dof_vec] = welchT(x1, x2) %WELCHT 2-sample Welch T-test - import nla.* % required due to matlab package system quirks %% Prepare data x1_size = size(x1); if x1_size(end) == 1, x1_size(end) = []; end x2_size = size(x2); if x2_size(end) == 1, x2_size(end) = []; end diff --git a/NLAResult_exported.m b/NLAResult_exported.m index 454ae403..947fc5ce 100644 --- a/NLAResult_exported.m +++ b/NLAResult_exported.m @@ -522,7 +522,8 @@ function DisplayConvergenceButtonPushed(app, event) 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_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]; @@ -543,7 +544,8 @@ function DisplayConvergenceButtonPushed(app, event) 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); + nla.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); diff --git a/main_pipeline.m b/main_pipeline.m index 51b05a33..942bc6cf 100755 --- a/main_pipeline.m +++ b/main_pipeline.m @@ -1,18 +1,17 @@ -import nla.* %% Get path to NLA -root_path = findRootPath(); +root_path = nla.findRootPath(); %% Create a pool of tests -tests = TestPool(); -tests.net_tests = genTests('net.test'); +tests = nla.TestPool(); +tests.net_tests = nla.genTests('net.test'); % Example: Changing the edge-level test -% tests.edge_test = edge.test.Spearman(); -% tests.edge_test = edge.test.SpearmanEstimator(); -% tests.edge_test = edge.test.Pearson(); -% tests.edge_test = edge.test.KendallB(); -% tests.edge_test = edge.test.WelchT(); % requires boolean 'in/outgroup' vector to be passed in as behavior +% tests.edge_test = nla.edge.test.Spearman(); +% tests.edge_test = nla.edge.test.SpearmanEstimator(); +% tests.edge_test = nla.edge.test.Pearson(); +% tests.edge_test = nla.edge.test.KendallB(); +% tests.edge_test = nla.edge.test.WelchT(); % requires boolean 'in/outgroup' vector to be passed in as behavior % Example: Appending another net-level test % tests.net_tests{end + 1} = net.test.ChiSquared(); @@ -33,23 +32,23 @@ net_atlas_path = [root_path 'support_files/Wheelock_2020_CerebralCortex_17nets_300ROI_on_MNI.mat']; % path to network atlas prev_net_atlas = load(net_atlas_path); nets_to_remove = ["US"]; % remove the unspecified/none network -[new_net_atlas] = removeNetworks(prev_net_atlas, nets_to_remove, 'Wheelock_2020_CerebralCortex_16nets_288ROI_on_MNI'); -net_atlas = NetworkAtlas(new_net_atlas); +[new_net_atlas] = nla.removeNetworks(prev_net_atlas, nets_to_remove, 'Wheelock_2020_CerebralCortex_16nets_288ROI_on_MNI'); +net_atlas = nla.NetworkAtlas(new_net_atlas); %% OR load network atlas without removing networks % This should be done if your parcellation lacks an "unspecified" network, % or, if the atlas you are using has already removed it. %net_atlas_path = [root_path 'support_files/Wheelock_2020_CerebralCortex_16nets_288ROI_on_MNI.mat']; % path to network atlas -%net_atlas = NetworkAtlas(net_atlas_path); +%net_atlas = nla.NetworkAtlas(net_atlas_path); %% Transform R-values to Z-scores % If this condition isn't true, it cannot be R values % If it is true, it is almost certainly R values but might not be if all(abs(func_conn_unordered(:)) <= 1) - func_conn_unordered = fisherR2Z(func_conn_unordered); + func_conn_unordered = nla.fisherR2Z(func_conn_unordered); end %% Arrange network according to the network atlas -input_struct.func_conn = TriMatrix(func_conn_unordered(net_atlas.ROI_order, net_atlas.ROI_order, :)); +input_struct.func_conn = nla.TriMatrix(func_conn_unordered(net_atlas.ROI_order, net_atlas.ROI_order, :)); %% Load behavior %load your behavioral vector here @@ -73,12 +72,12 @@ net_input_struct.prob_max = 0.05; net_input_struct.behavior_count = 1; net_input_struct.d_max = 0.5; -net_input_struct.prob_plot_method = gfx.ProbPlotMethod.DEFAULT; +net_input_struct.prob_plot_method = nla.gfx.ProbPlotMethod.DEFAULT; %% Partial variance % covariates = NxM matrix of covariates to factor from behavioral scores/fc % where N is the number of subjects and M is the # of covariate columns -%[input_struct.func_conn, input_struct.behavior] = partialVariance(input_struct.func_conn, input_struct.behavior, covariates, PartialVarianceType.FCBX); +%[input_struct.func_conn, input_struct.behavior] = nla.partialVariance(input_struct.func_conn, input_struct.behavior, covariates, PartialVarianceType.FCBX); %% Clean up unnecessary variables clear fc_unordered fc_struct bx @@ -86,14 +85,14 @@ %% Visualize average functional connectivity values fc_avg = copy(input_struct.func_conn); fc_avg.v = mean(fc_avg.v, 2); -fig_l = gfx.createFigure(800, 800); -obj = nla.gfx.plots.MatrixPlot(fig_l, "FC Average", fc_avg, net_atlas.nets, gfx.FigSize.LARGE); +fig_l = nla.gfx.createFigure(800, 800); +obj = nla.gfx.plots.MatrixPlot(fig_l, "FC Average", fc_avg, net_atlas.nets, nla.gfx.FigSize.LARGE); obj.displayImage() drawnow(); %% Visualize network/ROI locations -gfx.drawNetworkROIs(net_atlas, gfx.MeshType.STD, 0.8, 4, false); -gfx.drawNetworkROIs(net_atlas, gfx.MeshType.STD, 1, 4, true); +nla.gfx.drawNetworkROIs(net_atlas, nla.gfx.MeshType.STD, 0.8, 4, false); +nla.gfx.drawNetworkROIs(net_atlas, nla.gfx.MeshType.STD, 1, 4, true); drawnow(); %% Run tests diff --git a/precalculated_pipeline.m b/precalculated_pipeline.m index 272d095b..6ce22cf2 100755 --- a/precalculated_pipeline.m +++ b/precalculated_pipeline.m @@ -1,22 +1,21 @@ -import nla.* %% Get path to NLA -root_path = findRootPath(); +root_path = nla.findRootPath(); %% Create a pool of tests -tests = TestPool(); -tests.net_tests = genTests('net.test'); -tests.edge_test = edge.test.Precalculated(); +tests = nla.TestPool(); +tests.net_tests = nla.genTests('net.test'); +tests.edge_test = nla.edge.test.Precalculated(); % Example: Appending another net-level test -% tests.net_tests{end + 1} = net.test.ChiSquared(); +% tests.net_tests{end + 1} = nla.net.test.ChiSquared(); % Example: Using a certain pool of net-level tests -% tests.net_tests = {net.test.ChiSquared() net.test.HyperGeo()}; +% tests.net_tests = {nla.net.test.ChiSquared() nla.net.test.HyperGeo()}; %% Load network atlas net_atlas_path = [root_path 'support_files/Wheelock_2020_CerebralCortex_15nets_288ROI_on_MNI.mat']; % path to network atlas -net_atlas = NetworkAtlas(net_atlas_path); +net_atlas = nla.NetworkAtlas(net_atlas_path); %% Load precalculated data % !!WARNING!! precalc_obs_p and precalc_perm_p should be thresholded and @@ -32,19 +31,19 @@ % load files obs_p_file = load('examples/precalculated/SIM_obs_p.mat'); -input_struct.precalc_obs_p = TriMatrix(net_atlas.numROIs); +input_struct.precalc_obs_p = nla.TriMatrix(net_atlas.numROIs); input_struct.precalc_obs_p.v = obs_p_file.SIM_obs_p; obs_coeff_file = load('examples/precalculated/SIM_obs_coeff.mat'); -input_struct.precalc_obs_coeff = TriMatrix(net_atlas.numROIs); +input_struct.precalc_obs_coeff = nla.TriMatrix(net_atlas.numROIs); input_struct.precalc_obs_coeff.v = obs_coeff_file.SIM_obs_coeff; perm_p_file = load('examples/precalculated/SIM_perm_p.mat'); -input_struct.precalc_perm_p = TriMatrix(net_atlas.numROIs); +input_struct.precalc_perm_p = nla.TriMatrix(net_atlas.numROIs); input_struct.precalc_perm_p.v = perm_p_file.SIM_perm_p; perm_coeff_file = load('examples/precalculated/SIM_perm_coeff.mat'); -input_struct.precalc_perm_coeff = TriMatrix(net_atlas.numROIs); +input_struct.precalc_perm_coeff = nla.TriMatrix(net_atlas.numROIs); input_struct.precalc_perm_coeff.v = perm_coeff_file.SIM_perm_coeff; num_perms = size(input_struct.precalc_perm_p.v, 2); @@ -54,11 +53,11 @@ input_struct.prob_max = 0.05; input_struct.permute_method = nla.edge.permutationMethods.None(); -net_input_struct = net.genBaseInputs(); +net_input_struct = nla.net.genBaseInputs(); net_input_struct.prob_max = 0.05; net_input_struct.behavior_count = 1; net_input_struct.d_max = 0.5; -net_input_struct.prob_plot_method = gfx.ProbPlotMethod.DEFAULT; +net_input_struct.prob_plot_method = nla.gfx.ProbPlotMethod.DEFAULT; %% Run tests edge_result = tests.runEdgeTest(input_struct); From 12ff59fd61887cbbb465a0fd109b87bc6b5f7ad9 Mon Sep 17 00:00:00 2001 From: Github Action Date: Mon, 22 Apr 2024 19:05:45 +0000 Subject: [PATCH 2/4] Exported mlapp files --- NLAResult_exported.m | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/NLAResult_exported.m b/NLAResult_exported.m index 947fc5ce..454ae403 100644 --- a/NLAResult_exported.m +++ b/NLAResult_exported.m @@ -522,8 +522,7 @@ function DisplayConvergenceButtonPushed(app, event) 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_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]; @@ -544,8 +543,7 @@ function DisplayConvergenceButtonPushed(app, event) color_map = [[1,1,1]; flip(copper())]; end - nla.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); + 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); From e7f31bb4e619e06dcb53f1cc7e4bdc07cfaf5c4c Mon Sep 17 00:00:00 2001 From: Jim Pollaro Date: Mon, 22 Apr 2024 14:24:42 -0500 Subject: [PATCH 3/4] found a few places for nla.helpers --- +nla/+net/+test/StudentT.m | 2 +- +nla/+net/+test/WelchT.m | 2 +- +nla/+net/+test/Wilcoxon.m | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/+nla/+net/+test/StudentT.m b/+nla/+net/+test/StudentT.m index 17a012fc..d00683f3 100755 --- a/+nla/+net/+test/StudentT.m +++ b/+nla/+net/+test/StudentT.m @@ -38,7 +38,7 @@ % if a previous result is passed in, add on to it if previous_result ~= false - result = obj.rank(net_atlas, previous_result, input_struct, @helpers.abs_ge, previous_result.t,... + result = obj.rank(net_atlas, previous_result, input_struct, @nla.helpers.abs_ge, previous_result.t,... previous_result.prob, t, prob, previous_result.ss_t, previous_result.ss_prob, ss_t, ss_prob); else result = nla.net.result.StudentT(num_nets); diff --git a/+nla/+net/+test/WelchT.m b/+nla/+net/+test/WelchT.m index a551441b..4a96ceac 100755 --- a/+nla/+net/+test/WelchT.m +++ b/+nla/+net/+test/WelchT.m @@ -38,7 +38,7 @@ % if a previous result is passed in, add on to it if previous_result ~= false - result = obj.rank(net_atlas, previous_result, input_struct, @helpers.abs_ge, previous_result.t,... + result = obj.rank(net_atlas, previous_result, input_struct, @nla.helpers.abs_ge, previous_result.t,... previous_result.prob, t, prob, previous_result.ss_t, previous_result.ss_prob, ss_t, ss_prob); else result = nla.net.result.WelchT(num_nets); diff --git a/+nla/+net/+test/Wilcoxon.m b/+nla/+net/+test/Wilcoxon.m index 5e69bc3b..0dea500e 100755 --- a/+nla/+net/+test/Wilcoxon.m +++ b/+nla/+net/+test/Wilcoxon.m @@ -41,7 +41,7 @@ % if a previous result is passed in, add on to it if previous_result ~= false - result = obj.rank(net_atlas, previous_result, input_struct, @helpers.abs_ge, previous_result.z,... + result = obj.rank(net_atlas, previous_result, input_struct, @nla.helpers.abs_ge, previous_result.z,... previous_result.prob, z, prob, previous_result.ss_w, previous_result.ss_prob, ss_w, ss_prob); else result = nla.net.result.Wilcoxon(num_nets); From 481cbbc40c44a56d7cf88fc4b57f8b3b3076cee5 Mon Sep 17 00:00:00 2001 From: Jim Pollaro Date: Tue, 23 Apr 2024 11:14:21 -0500 Subject: [PATCH 4/4] fixed some missed imports --- +nla/+edge/+test/KendallB.m | 2 +- +nla/+edge/+test/Precalculated.m | 2 +- +nla/+inputField/Behavior.m | 6 +++--- +nla/+mex/run.m | 2 +- +nla/+net/+test/WelchT.m | 2 +- +nla/+net/BaseResult.m | 4 ++-- +nla/NetworkAtlas.m | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/+nla/+edge/+test/KendallB.m b/+nla/+edge/+test/KendallB.m index 256ca822..7f3deb55 100755 --- a/+nla/+edge/+test/KendallB.m +++ b/+nla/+edge/+test/KendallB.m @@ -11,7 +11,7 @@ end function result = run(obj, input_struct) - [tau_vec, p_vec] = mex.run('kendallTauB', input_struct.behavior, input_struct.func_conn.v'); + [tau_vec, p_vec] = nla.mex.run('kendallTauB', input_struct.behavior, input_struct.func_conn.v'); result = obj.composeResult(input_struct.net_atlas, tau_vec', p_vec', input_struct.prob_max); end end diff --git a/+nla/+edge/+test/Precalculated.m b/+nla/+edge/+test/Precalculated.m index 4b833a09..562fd9a5 100755 --- a/+nla/+edge/+test/Precalculated.m +++ b/+nla/+edge/+test/Precalculated.m @@ -30,7 +30,7 @@ methods (Static) function inputs = requiredInputs() - import nla.inputField.DimensionType nla.inputFieldNumberWithoutDefault nla.inputFieldEdgeLevelMatrix + import nla.inputField.DimensionType nla.inputField.NumberWithoutDefault nla.inputField.EdgeLevelMatrix npairs_x_nperms = [DimensionType.NROIPAIRS,DimensionType.NPERMS]; npairs_x_1 = [DimensionType.NROIPAIRS, 1]; diff --git a/+nla/+inputField/Behavior.m b/+nla/+inputField/Behavior.m index 2f992659..ccce97a5 100755 --- a/+nla/+inputField/Behavior.m +++ b/+nla/+inputField/Behavior.m @@ -48,7 +48,7 @@ function resetSelectedCol(obj) table_w = max(parent.Position(3) - (nla.inputField.LABEL_GAP * 4), 500); table_h = 300; - label_gap = LABEL_GAP; + label_gap = nla.inputField.LABEL_GAP; h = LABEL_H + label_gap + table_h + label_gap + LABEL_H + label_gap + LABEL_H; %% Create label @@ -208,7 +208,7 @@ function read(obj, input_struct) button.Text = label; button.Position(3) = nla.inputField.widthOfString(button.Text, nla.inputField.LABEL_H) +... - inputField.widthOfString(' ', nla.inputField.LABEL_H + nla.inputField.LABEL_GAP); + nla.inputField.widthOfString(' ', nla.inputField.LABEL_H + nla.inputField.LABEL_GAP); w = button.Position(3); end @@ -372,7 +372,7 @@ function update(obj) else obj.button.Text = obj.behavior_filename; end - obj.button.Position(3) = widthOfString(obj.button.Text, LABEL_H) + widthOfString(' ', LABEL_H + inputField.LABEL_GAP); + obj.button.Position(3) = widthOfString(obj.button.Text, LABEL_H) + widthOfString(' ', LABEL_H + nla.inputField.LABEL_GAP); removeStyle(obj.table); if islogical(obj.behavior_full) diff --git a/+nla/+mex/run.m b/+nla/+mex/run.m index ccba8147..1a77cbcf 100755 --- a/+nla/+mex/run.m +++ b/+nla/+mex/run.m @@ -48,7 +48,7 @@ %% create function handle % does not error with invalid function names - func_name_full = ['mex.bin.' func_name_hashed]; + func_name_full = ['nla.mex.bin.' func_name_hashed]; func_handle = str2func(func_name_full); %% execute binary and return output diff --git a/+nla/+net/+test/WelchT.m b/+nla/+net/+test/WelchT.m index 4a96ceac..2955f6e8 100755 --- a/+nla/+net/+test/WelchT.m +++ b/+nla/+net/+test/WelchT.m @@ -24,7 +24,7 @@ for col = 1:row coeff_net = edge_result.coeff.get(net_atlas.nets(row).indexes, net_atlas.nets(col).indexes); - [p_val, t_val, ~] = welchT(coeff_net, edge_result.coeff.v); + [p_val, t_val, ~] = nla.welchT(coeff_net, edge_result.coeff.v); prob.set(row, col, p_val); t.set(row, col, t_val); diff --git a/+nla/+net/BaseResult.m b/+nla/+net/BaseResult.m index a0987ce2..d9cf5090 100755 --- a/+nla/+net/BaseResult.m +++ b/+nla/+net/BaseResult.m @@ -27,7 +27,7 @@ function output(obj, edge_input_struct, input_struct, net_atlas, edge_result, fl if isfield(flags, 'show_nonpermuted') && flags.show_nonpermuted if flags.plot_type == nla.PlotType.FIGURE %% Non-permuted - fig = gfx.createFigure(500, 900); + fig = nla.gfx.createFigure(500, 900); %% Check that network-pair size is not a confound obj.plotProbVsNetSize(net_atlas, subplot(2,1,2)); @@ -59,7 +59,7 @@ function output(obj, edge_input_struct, input_struct, net_atlas, edge_result, fl end else if isfield(flags, 'show_full_conn') && flags.show_full_conn - [sig, name] = obj.singleSigMat(net_atlas, input_struct, obj.perm_prob_ew, net.mcc.None,... + [sig, name] = obj.singleSigMat(net_atlas, input_struct, obj.perm_prob_ew, nla.net.mcc.None,... "Full Connectome"); [num_tests, sig_count_mat, names] = obj.appendSigMat(num_tests, sig_count_mat, names, sig, name); end diff --git a/+nla/NetworkAtlas.m b/+nla/NetworkAtlas.m index 471a8a7e..f40b2a65 100755 --- a/+nla/NetworkAtlas.m +++ b/+nla/NetworkAtlas.m @@ -55,7 +55,7 @@ %% Regions of interest for i = 1:ROI_count - obj.ROIs = [obj.ROIs; ROI(ROI_positions(i, :)')]; + obj.ROIs = [obj.ROIs; nla.ROI(ROI_positions(i, :)')]; end %% ROI order(re-orders elements of func_conn)