Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions +nla/+gfx/+plots/MatrixPlot.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
figure_size % Size to display. Either nla.gfx.FigSize.SMALL or nla.gfx.FigSize.LARGE
draw_legend % Legend on/off
draw_colorbar % Colorbar on/off
color_map % Colormap to use (enter 'turbo(256)' for default)
color_map % Colormap to use (enter 'jet(1000)' for default)
marked_networks % networks to mark with a symbol
discrete_colorbar % colorbar as discrete. TRUE == discrete, FALSE == continuous
network_clicked_callback % Button function to add to each network. Used for clickable networks
Expand Down Expand Up @@ -55,7 +55,7 @@
end

properties (Constant)
colormap_choices = {"Parula", "Turbo", "HSV", "Hot", "Cool", "Spring", "Summer", "Autumn", "Winter", "Gray",...
colormap_choices = {"Jet", "Parula", "Turbo", "HSV", "Hot", "Cool", "Spring", "Summer", "Autumn", "Winter", "Gray",...
"Bone", "Copper", "Pink"}; % Colorbar choices
end

Expand All @@ -82,7 +82,7 @@
% figure_margins = nla.gfx.FigMargins.WHITESPACE
% draw_legend = true
% draw_colorbar = true
% color_map = turbo(256)
% color_map = jet(1000)
% lower_limit = -0.3
% upper_limit = 0.3
% x_position = 0
Expand All @@ -104,7 +104,7 @@
addParameter(matrix_input_parser, 'figure_margins', nla.gfx.FigMargins.WHITESPACE, @isenum);
addParameter(matrix_input_parser, 'draw_legend', true, @islogical);
addParameter(matrix_input_parser, 'draw_colorbar', true, @islogical);
addParameter(matrix_input_parser, 'color_map', turbo(256));
addParameter(matrix_input_parser, 'color_map', jet(1000)); %reverted to jet(1000) by request
addParameter(matrix_input_parser, 'lower_limit', -0.3, validNumberInput);
addParameter(matrix_input_parser, 'upper_limit', 0.3, validNumberInput);
addParameter(matrix_input_parser, 'x_position', 0, validNumberInput);
Expand Down
Binary file modified +nla/+net/+result/+plot/NetworkTestPlotApp.mlapp
Binary file not shown.
52 changes: 34 additions & 18 deletions +nla/+net/+result/+plot/NetworkTestPlotApp_exported.m
Original file line number Diff line number Diff line change
Expand Up @@ -175,28 +175,41 @@ function getPlotTitle(app)
methods (Access = private)

function cohens_d_filter = createSignificanceFilter(app)
cohens_d_filter = nla.TriMatrix(app.edge_test_options.net_atlas.numNets, "logical", nla.TriMatrixDiag.KEEP_DIAGONAL);
if isequal(app.CohensDThresholdCheckBox.Enable, true) && isequal(app.CohensDThresholdCheckBox.Value, true)
if isequal(app.test_method, "no_permutations") && ~isequal(app.network_test_result.no_permutations, false)

end
if isequal(app.test_method, "full_connectome") && ~isequal(app.network_test_result.full_connectome, false)
cohens_d_filter.v = (app.network_test_result.full_connectome.d.v >= app.network_test_options.d_max);
end
if ~isequal(app.network_test_result.within_network_pair, false) && isfield(app.network_test_result.within_network_pair, "d")...
&& ~isequal(app.test_method, "full_connectome")
cohens_d_filter.v = (app.network_test_result.within_network_pair.d.v >= app.network_test_options.d_max);
end
else
cohens_d_filter.v = true(numel(cohens_d_filter.v), 1);
end
%REMOVE COHENS D FILTERING UNTIL WE DETERMINE CORRECT CALCULATION FOR IT - ADE 2025MAR24
num_nets = app.edge_test_options.net_atlas.numNets;
cohens_d_filter = nla.TriMatrix(num_nets, "logical", nla.TriMatrixDiag.KEEP_DIAGONAL);
cohens_d_filter.v = true(numel(cohens_d_filter.v), 1);
return;

% cohens_d_filter = nla.TriMatrix(app.edge_test_options.net_atlas.numNets, "logical", nla.TriMatrixDiag.KEEP_DIAGONAL);
% if isequal(app.CohensDThresholdCheckBox.Enable, true) && isequal(app.CohensDThresholdCheckBox.Value, true)
% if isequal(app.test_method, "no_permutations") && ~isequal(app.network_test_result.no_permutations, false)
%
% end
% if isequal(app.test_method, "full_connectome") && ~isequal(app.network_test_result.full_connectome, false)
% cohens_d_filter.v = (app.network_test_result.full_connectome.d.v >= app.network_test_options.d_max);
% end
% if ~isequal(app.network_test_result.within_network_pair, false) && isfield(app.network_test_result.within_network_pair, "d")...
% && ~isequal(app.test_method, "full_connectome")
% cohens_d_filter.v = (app.network_test_result.within_network_pair.d.v >= app.network_test_options.d_max);
% end
% else
% cohens_d_filter.v = true(numel(cohens_d_filter.v), 1);
% end
end

function applyScaleChange(app)
progress_bar = uiprogressdlg(app.UIFigure, "Title", "Please Wait", "Message", "Applying Changes...", "Indeterminate", true);
progress_bar.Message = "Chaning scale of existing TriMatrix...";
app.matrix_plot.applyScale(false, false, app.UpperLimitEditField.Value, app.LowerLimitEditField.Value, app.PlotScaleDropDown.Value, app.ColormapDropDown.Value)
end

function hideCohensDControls(app)
app.CohensDThresholdEditField.Visible = false;
app.CohensDThresholdCheckBox.Visible = false;
app.CohensDThresholdEditFieldLabel.Visible = false;

end
end


Expand All @@ -213,6 +226,8 @@ function startupFcn(app, network_test_result, edge_test_result, flags, edge_test
test_method = "within_network_pair";
end

app.hideCohensDControls(); %keep cohens d controls in code, but hide from user until we get right calcluations - ADE2025MAR24

app.network_test_result = network_test_result;
app.edge_test_result = edge_test_result;
app.test_method = test_method;
Expand All @@ -232,7 +247,7 @@ function startupFcn(app, network_test_result, edge_test_result, flags, edge_test
app.ColormapDropDown.Items = app.colormap_choices;
app.ColormapDropDown.Value = app.colormap_choices{1};

app.drawTriMatrixPlot()
app.drawTriMatrixPlot();
end

% Callback function
Expand Down Expand Up @@ -451,13 +466,14 @@ function createComponents(app)
% Create CohensDThresholdEditFieldLabel
app.CohensDThresholdEditFieldLabel = uilabel(app.Panel);
app.CohensDThresholdEditFieldLabel.HorizontalAlignment = 'right';
app.CohensDThresholdEditFieldLabel.Enable = 'off';
app.CohensDThresholdEditFieldLabel.Position = [195 237 118 22];
app.CohensDThresholdEditFieldLabel.Text = 'Cohen''s D Threshold';

% Create CohensDThresholdEditField
app.CohensDThresholdEditField = uieditfield(app.Panel, 'numeric');
app.CohensDThresholdEditField.Enable = 'off';
app.CohensDThresholdEditField.Position = [339 237 52 22];
app.CohensDThresholdEditField.Value = 0.5;

% Create ColormapDropDownLabel
app.ColormapDropDownLabel = uilabel(app.Panel);
Expand Down Expand Up @@ -501,9 +517,9 @@ function createComponents(app)

% Create CohensDThresholdCheckBox
app.CohensDThresholdCheckBox = uicheckbox(app.Panel);
app.CohensDThresholdCheckBox.Enable = 'off';
app.CohensDThresholdCheckBox.Text = 'Cohen''s D Threshold';
app.CohensDThresholdCheckBox.Position = [257 207 134 22];
app.CohensDThresholdCheckBox.Value = true;

% Create ROIcentroidsonbrainplotsCheckBox
app.ROIcentroidsonbrainplotsCheckBox = uicheckbox(app.Panel);
Expand Down
59 changes: 34 additions & 25 deletions +nla/+net/CohenDTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,40 @@
end

function result_object = run(obj, edge_test_results, network_atlas, result_object)
import nla.TriMatrix nla.TriMatrixDiag

number_of_networks = network_atlas.numNets();

for row = 1:number_of_networks
for column = 1:row

network_rho = edge_test_results.coeff.get(network_atlas.nets(row).indexes,...
network_atlas.nets(column).indexes);

single_sample_d = abs(mean(network_rho)) / std(network_rho);
d = abs((mean(network_rho) - mean(edge_test_results.coeff.v)) / sqrt(((std(network_rho).^2)) +...
(std(edge_test_results.coeff.v).^2)));

if isprop(result_object, "no_permutations") && ~isequal(result_object.no_permutations, false)
result_object.no_permutations.d.set(row, column, single_sample_d);
end
if isprop(result_object, "full_connectome") && ~isequal(result_object.full_connectome, false)
result_object.full_connectome.d.set(row, column, d);
end
if isprop(result_object, "within_network_pair") && ~isequal(result_object.within_network_pair, false)
result_object.within_network_pair.d.set(row, column, single_sample_d);
end
end
end


%DETERMINED THAT CURRENT COHEN'S D CALC IS INVALID
%RETURN WITHOUT MODIFYING EXISTING D PLACEHOLDER VALUE FROM 0
%RECOMMEND THAT, WHEN REENABLED, THIS FN BE CHANGED TO ACCEPT
%VECTOR OF INPUT AND RETURN VECTOR OF OUTPUT RATHER THAN
%RESULTS CLASS
%ADE 2025MAR24
return;




%LEAVING COMMENTED CODE BELOW THAT WOULD MODIFY FIELDS AS DONE
%PREVIOUSLY FOR REFERENCE.
% number_of_networks = network_atlas.numNets();
%
% for row = 1:number_of_networks
% for column = 1:row
%
% if isprop(result_object, "no_permutations") && ~isequal(result_object.no_permutations, false)
% %this_netpair_nonperm_d = COMPUTE NONPERMUTED D HERE;
% result_object.no_permutations.d.set(row, column, this_netpair_nonperm_d);
% end
% if isprop(result_object, "full_connectome") && ~isequal(result_object.full_connectome, false)
% %this_netpair_fullconn_d = COMPUTE FULLCONN D HERE;
% result_object.full_connectome.d.set(row, column, this_netpair_fullconn_d);
% end
% if isprop(result_object, "within_network_pair") && ~isequal(result_object.within_network_pair, false)
% %this_netpair_withinNP_d = COMPUTE WITHIN NET PAIR D HERE
% result_object.within_network_pair.d.set(row, column, this_netpair_withinNP_d);
% end
% end
% end
end
end
end
20 changes: 12 additions & 8 deletions +nla/TestPool.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@
function ranked_results = collateNetworkPermutationResults(obj, nonpermuted_edge_test_results, network_atlas, nonpermuted_network_test_results,...
permuted_network_test_results, network_test_options)

% Run Cohen's D
cohen_d_test = nla.net.CohenDTest();


% Warning: Hacky code. Because of the way non-permuted network tests and permuted are called from the front, they are stored
% in different objects. (Notice the input argument for non-permuted network results). Eventually, it should probably be done
Expand All @@ -78,10 +77,15 @@
end
end
end
for test_index = 1:numNetTests(obj)
permuted_network_test_results{test_index} = cohen_d_test.run(nonpermuted_edge_test_results, network_atlas,...
permuted_network_test_results{test_index});
end

% REMOVE CALL TO COHENS D UNTIL WE DETERMINE CORRECT CALC FOR IT ADE 2025MAR24
% Run Cohen's D
% cohen_d_test = nla.net.CohenDTest();
% for test_index = 1:numNetTests(obj)
%
% permuted_network_test_results{test_index} = cohen_d_test.run(nonpermuted_edge_test_results, network_atlas,...
% permuted_network_test_results{test_index});
% end

ranked_results = obj.rankResults(network_test_options, permuted_network_test_results, network_atlas.numNetPairs());
end
Expand Down Expand Up @@ -274,11 +278,11 @@
end

function ranked_results = rankResults(obj, input_options, permuted_network_results, number_of_network_pairs)
import nla.net.ResultRank


ranked_results = permuted_network_results;
for test = 1:numNetTests(obj)
ranker = ResultRank(permuted_network_results{test}, number_of_network_pairs);
ranker = nla.net.ResultRank(permuted_network_results{test}, number_of_network_pairs);
ranked_results_object = ranker.rank();
ranked_results{test} = ranked_results_object;
if any(strcmp(ranked_results{test}.test_name, obj.correlation_input_tests))
Expand Down
Binary file modified NLAResult.mlapp
Binary file not shown.
5 changes: 1 addition & 4 deletions NLAResult_exported.m
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,7 @@ function initFromResult(app, result, file_name, ~, old_data)
app.results = false;
end

if ~islogical(result.network_test_results)
app.genadjustableNetParams();
end

end

function enableNetButtons(app, val)
Expand Down Expand Up @@ -416,7 +414,6 @@ function RunButtonPushed(app, event)
drawnow();

app.setNesting();
app.genadjustableNetParams();

close(prog);
end
Expand Down
Binary file modified NLA_GUI.mlapp
Binary file not shown.