Skip to content

Commit ac8ed26

Browse files
Net279 windows fixes (#121)
* Fix issues specific to windows: Make findRootPath OS agnostic, fix child figs drawing offscreen, comment out icon loading in Windows. Fix error in QualityControl GUI where calls to .lib functions missing leading 'nla' * Exported mlapp files --------- Co-authored-by: Github Action <action@github.com>
1 parent 6dc8c22 commit ac8ed26

15 files changed

Lines changed: 151 additions & 73 deletions
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
function moveFigToParentUILocation(fig_h, parent_h)
2+
3+
%Intended to fix issue in Windows where plots generated from NLA_GUI
4+
%and NLA_Result get drawn way off top of screen.
5+
%Inputs are:
6+
% fig_h - figure handle
7+
% parent_h - UIFigure handle to move to (matlab.ui.Figure)
8+
9+
figPos = get(fig_h, 'Position');
10+
11+
currWidth = figPos(3);
12+
currHeight = figPos(4);
13+
14+
parentPos = parent_h.Position;
15+
16+
%Position sets bottom left of figure, but we want to match the
17+
%top left (to ensure that top of new figure is on screen()
18+
vertOffset = currHeight - parentPos(4);
19+
20+
additionalOffset = [10, -10];
21+
22+
moveFigTo_x = parentPos(1) + additionalOffset(1);
23+
moveFigTo_y = parentPos(2) + additionalOffset(2) - vertOffset;
24+
25+
26+
set(fig_h, 'Position', [moveFigTo_x moveFigTo_y currWidth currHeight]);
27+
28+
end

+nla/+inputField/Behavior.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
button_remove_permutation_level = false
3030
select_partial_variance_label = false
3131
select_partial_variance = false
32+
UIParent = []
3233
end
3334

3435
methods
@@ -48,6 +49,7 @@ function resetSelectedCol(obj)
4849
import nla.inputField.LABEL_H nla.inputField.LABEL_GAP
4950

5051
obj.fig = fig;
52+
obj.UIParent = parent;
5153

5254
table_w = max(parent.Position(3) - (LABEL_GAP * 4), 500);
5355
table_h = 300;
@@ -385,6 +387,8 @@ function button_view_design_mtxClickedCallback(obj)
385387
if ~islogical(obj.covariates_idx)
386388
labels = {obj.table.ColumnName{obj.covariates_idx}};
387389
nla.gfx.drawDesignMtx(obj.covariates, labels);
390+
391+
388392
end
389393
end
390394

+nla/+inputField/NetworkAtlas.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
label = false
1717
inflation_label = false
1818
inflation_dropdown = false
19+
UIParent = []
1920
end
2021

2122
methods
@@ -28,6 +29,7 @@
2829
import nla.gfx.MeshType
2930

3031
obj.fig = fig;
32+
obj.UIParent = parent;
3133

3234
label_gap = LABEL_GAP;
3335
h = LABEL_H;
@@ -174,6 +176,9 @@ function buttonViewNetAtlasClickedCallback(obj)
174176
nla.gfx.drawNetworkROIs(obj.net_atlas, mesh_inf, 0.8, 4, false);
175177
end
176178

179+
if ispc
180+
nla.gfx.moveFigToParentUILocation(gcf, obj.UIParent);
181+
end
177182
close(prog);
178183
drawnow();
179184
end

+nla/+inputField/NetworkAtlasFuncConn.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
label2 = false
2222
inflation_label = false
2323
inflation_dropdown = false
24+
UIParent = []
2425
end
2526

2627
methods
@@ -33,6 +34,7 @@
3334
import nla.gfx.MeshType
3435

3536
obj.fig = fig;
37+
obj.UIParent = parent;
3638

3739
label_gap = LABEL_GAP;
3840
h = LABEL_H * 2 + label_gap;
@@ -303,6 +305,9 @@ function buttonViewNetAtlasClickedCallback(obj)
303305
nla.gfx.drawNetworkROIs(obj.net_atlas, mesh_inf, 0.8, 4, false);
304306
end
305307

308+
if ispc
309+
nla.gfx.moveFigToParentUILocation(gcf, obj.UIParent);
310+
end
306311
close(prog);
307312
drawnow();
308313
end
@@ -323,6 +328,9 @@ function buttonViewFCAvgClickedCallback(obj)
323328
fig_l.Position(4) = matrix_plot.image_dimensions("image_height");
324329
matrix_plot.displayImage();
325330

331+
if ispc
332+
nla.gfx.moveFigToParentUILocation(fig_l, obj.UIParent);
333+
end
326334
close(prog);
327335
drawnow();
328336
end
9.59 KB
Binary file not shown.

+nla/+net/+result/+plot/NetworkTestPlotApp_exported.m

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,36 @@
55
UIFigure matlab.ui.Figure
66
Menu matlab.ui.container.Menu
77
SaveasMenu matlab.ui.container.Menu
8+
Panel_2 matlab.ui.container.Panel
89
Panel matlab.ui.container.Panel
9-
PlotScaleDropDownLabel matlab.ui.control.Label
10-
PlotScaleDropDown matlab.ui.control.DropDown
11-
RankingDropDownLabel matlab.ui.control.Label
12-
RankingDropDown matlab.ui.control.DropDown
13-
UpperLimitEditFieldLabel matlab.ui.control.Label
14-
UpperLimitEditField matlab.ui.control.NumericEditField
15-
LowerLimitEditFieldLabel matlab.ui.control.Label
16-
LowerLimitEditField matlab.ui.control.NumericEditField
17-
pvalueThresholdEditFieldLabel matlab.ui.control.Label
18-
pvalueThresholdEditField matlab.ui.control.NumericEditField
19-
CohensDThresholdEditFieldLabel matlab.ui.control.Label
20-
CohensDThresholdEditField matlab.ui.control.NumericEditField
21-
ColormapDropDownLabel matlab.ui.control.Label
22-
ColormapDropDown matlab.ui.control.DropDown
23-
LegendVisibleDropDownLabel matlab.ui.control.Label
24-
LegendVisibleDropDown matlab.ui.control.DropDown
25-
MultipleComparisonCorrectionDropDownLabel matlab.ui.control.Label
26-
MultipleComparisonCorrectionDropDown matlab.ui.control.DropDown
27-
CohensDThresholdCheckBox matlab.ui.control.CheckBox
28-
ROIcentroidsonbrainplotsCheckBox matlab.ui.control.CheckBox
29-
ViewChordPlotsButton matlab.ui.control.Button
30-
ViewEdgeChordPlotsButton matlab.ui.control.Button
31-
EdgeChordPlotTypeDropDownLabel matlab.ui.control.Label
32-
EdgeChordPlotTypeDropDown matlab.ui.control.DropDown
33-
ViewConvergenceMapButton matlab.ui.control.Button
34-
ConvergencePlotColorDropDownLabel matlab.ui.control.Label
35-
ConvergencePlotColorDropDown matlab.ui.control.DropDown
3610
ApplyButton matlab.ui.control.Button
37-
Panel_2 matlab.ui.container.Panel
11+
ConvergencePlotColorDropDown matlab.ui.control.DropDown
12+
ConvergencePlotColorDropDownLabel matlab.ui.control.Label
13+
ViewConvergenceMapButton matlab.ui.control.Button
14+
EdgeChordPlotTypeDropDown matlab.ui.control.DropDown
15+
EdgeChordPlotTypeDropDownLabel matlab.ui.control.Label
16+
ViewEdgeChordPlotsButton matlab.ui.control.Button
17+
ViewChordPlotsButton matlab.ui.control.Button
18+
ROIcentroidsonbrainplotsCheckBox matlab.ui.control.CheckBox
19+
CohensDThresholdCheckBox matlab.ui.control.CheckBox
20+
MultipleComparisonCorrectionDropDown matlab.ui.control.DropDown
21+
MultipleComparisonCorrectionDropDownLabel matlab.ui.control.Label
22+
LegendVisibleDropDown matlab.ui.control.DropDown
23+
LegendVisibleDropDownLabel matlab.ui.control.Label
24+
ColormapDropDown matlab.ui.control.DropDown
25+
ColormapDropDownLabel matlab.ui.control.Label
26+
CohensDThresholdEditField matlab.ui.control.NumericEditField
27+
CohensDThresholdEditFieldLabel matlab.ui.control.Label
28+
pvalueThresholdEditField matlab.ui.control.NumericEditField
29+
pvalueThresholdEditFieldLabel matlab.ui.control.Label
30+
LowerLimitEditField matlab.ui.control.NumericEditField
31+
LowerLimitEditFieldLabel matlab.ui.control.Label
32+
UpperLimitEditField matlab.ui.control.NumericEditField
33+
UpperLimitEditFieldLabel matlab.ui.control.Label
34+
RankingDropDown matlab.ui.control.DropDown
35+
RankingDropDownLabel matlab.ui.control.Label
36+
PlotScaleDropDown matlab.ui.control.DropDown
37+
PlotScaleDropDownLabel matlab.ui.control.Label
3838
end
3939

4040

@@ -273,10 +273,8 @@ function drawChords(app, event)
273273
chord_plotter.generateChordFigure(probability_parameters, plot_type)
274274
end
275275

276-
% Value changed function: ColormapDropDown,
277-
% LegendVisibleDropDown, LowerLimitEditField,
278-
% MultipleComparisonCorrectionDropDown, PlotScaleDropDown,
279-
% RankingDropDown, UpperLimitEditField
276+
% Value changed function: ColormapDropDown, LegendVisibleDropDown,
277+
% ...and 5 other components
280278
function PlotScaleValueChanged(app, event)
281279
if isequal(app.settings, false)
282280
app.settings = struct();
@@ -309,6 +307,9 @@ function pvalueThresholdEditFieldValueChanged(app, event)
309307
function ViewEdgeChordPlotsButtonPushed(app, event)
310308
app.chord_type = "nla.PlotType.CHORD_EDGE";
311309
app.drawChords(event);
310+
if ispc
311+
nla.gfx.moveFigToParentUILocation(gcf, app.UIFigure);
312+
end
312313
end
313314

314315
% Value changed function: EdgeChordPlotTypeDropDown
@@ -321,6 +322,9 @@ function EdgeChordPlotTypeDropDownValueChanged(app, event)
321322
function ViewChordPlotsButtonPushed(app, event)
322323
app.chord_type = "nla.PlotType.CHORD";
323324
app.drawChords(event);
325+
if ispc
326+
nla.gfx.moveFigToParentUILocation(gcf, app.UIFigure);
327+
end
324328
end
325329

326330
% Button pushed function: ApplyButton
@@ -365,6 +369,10 @@ function ViewConvergenceMapButtonPushed(app, event)
365369

366370
nla.gfx.drawConvergenceMap(app.edge_test_options, app.network_test_options, app.edge_test_options.net_atlas, significance_count_matrix,...
367371
test_number, names, app.edge_test_result, color_map);
372+
373+
if ispc
374+
nla.gfx.moveFigToParentUILocation(gcf, app.UIFigure);
375+
end
368376
end
369377

370378
% Menu selected function: SaveasMenu

+nla/NetworkAtlas.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@
9191

9292
%% Cortex anatomy
9393
try
94-
obj.anat = nla.CortexAnatomy(sprintf('%ssupport_files/meshes/%s.mat', nla.findRootPath(), obj.space));
94+
%obj.anat = nla.CortexAnatomy(sprintf('%ssupport_files/meshes/%s.mat', nla.findRootPath(), obj.space));
95+
obj.anat = nla.CortexAnatomy(fullfile(nla.findRootPath(),'support_files','meshes',[obj.space,'.mat']));
9596
catch
9697
error("Could not load cortex anatomy - you may have forgotten to set the 'space' field in your Network Atlas")
9798
end

+nla/findRootPath.m

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
function root_path = findRootPath()
22
%FINDROOTPATH Find the root path of the NLA toolbox
3-
path_split = split(string(which('nla.VERSION')), "/");
4-
path_joined = join(path_split(1:end-2), "/");
5-
root_path = char(path_joined + "/");
3+
% path_split = split(string(which('nla.VERSION')), "/");
4+
% path_joined = join(path_split(1:end-2), "/");
5+
% root_path = char(path_joined + "/");
6+
7+
root_path_no_ending_slash = fileparts(which('nla.VERSION'));
8+
%root path will be location of parent folder containing the '+nla'
9+
%folder. Get this by trimming last 4 characters off of the directory
10+
%containing nla.VERSION
11+
root_path = root_path_no_ending_slash(1:(end-4));
12+
root_path = strrep(root_path, '\','\\'); %Replace windows style path separator with double slash to avoid confusion with escape characters. Has no effect on linux style slashes
13+
614
end
715

+nla/genTests.m

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@
33
% subpackage: dot-seperated subpackage name within NLA namespace, eg.
44
% 'net.test' for net-level tests
55
root_path = nla.findRootPath();
6-
relative_path = strrep(subpackage, '.', '/+');
7-
path_to = [root_path '+nla/+' relative_path];
8-
network_tests_struct = dir(path_to);
6+
subfolders = strsplit(subpackage,'.');
7+
%First add '+nla' to root_path, and then add each subpackage as folder
8+
path_to_subfolder = fullfile(root_path,'+nla');
9+
for i = 1:length(subfolders)
10+
path_to_subfolder = fullfile(path_to_subfolder, ['+', subfolders{i}]);
11+
end
12+
13+
network_tests_struct = dir(path_to_subfolder);
914
network_test_folder_contents = {network_tests_struct.name};
1015
network_test_filenames = network_test_folder_contents(~[network_tests_struct.isdir]);
1116

+nla/silhouetteCoeff.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
end
2323

2424
% calculating correlation distance pairwise by ignoring the diagonals
25-
corr_distance = lib.calc_correlationdist(fc_included);
25+
corr_distance = nla.lib.calc_correlationdist(fc_included);
2626

2727
% all networks are connected to all other networks, but no self-pairing
2828
net_pair_connected = true(numel(networks));
2929
net_pair_connected = net_pair_connected - diag(diag(net_pair_connected));
3030

3131
%% Calculate silhouette values
32-
si_vals = lib.silhouette_mod(ROI_keys_kept, corr_distance, net_pair_connected);
32+
si_vals = nla.lib.silhouette_mod(ROI_keys_kept, corr_distance, net_pair_connected);
3333
end
3434

0 commit comments

Comments
 (0)