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
2 changes: 1 addition & 1 deletion +nla/+edge/+result/Base.m
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,7 +44,7 @@ function output(obj, net_atlas, flags, prob_label)

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));
'upper_limit', obj.coeff_range(2), 'app_plot', false);
matrix_plot.displayImage();
w = matrix_plot.image_dimensions("image_width");
h = matrix_plot.image_dimensions("image_height");
Expand Down
60 changes: 51 additions & 9 deletions +nla/+gfx/+plots/MatrixPlot.m
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,6 +35,7 @@
current_settings % the settings for the plot (upper, lower, scale)
display_legend
p_value_max
app_plot % Used when called for FC Avg
end

properties (Dependent)
Expand DownExpand Up@@ -112,12 +113,13 @@
addParameter(matrix_input_parser, 'y_position', 0, validNumberInput);
addParameter(matrix_input_parser, 'discrete_colorbar', false, @islogical);
addParameter(matrix_input_parser, 'plot_scale', nla.gfx.ProbPlotMethod.DEFAULT);
addParameter(matrix_input_parser, 'p_value_max', 0.05)
addParameter(matrix_input_parser, 'p_value_max', 0.05);
addParameter(matrix_input_parser, 'app_plot', true, @islogical)

parse(matrix_input_parser, figure, name, matrix, networks, figure_size, varargin{:});
properties = {'figure', 'name', 'matrix', 'networks', 'figure_size', 'network_clicked_callback',...
'marked_networks', 'figure_margins', 'draw_legend', 'draw_colorbar', 'color_map', 'lower_limit',...
'upper_limit', 'x_position', 'y_position', 'discrete_colorbar', 'plot_scale', 'p_value_max'};
'upper_limit', 'x_position', 'y_position', 'discrete_colorbar', 'plot_scale', 'p_value_max', 'app_plot'};
for property = properties
obj.(property{1}) = matrix_input_parser.Results.(property{1});
if property{1} == "marked_networks"
Expand DownExpand Up@@ -182,6 +184,18 @@ function displayImage(obj)
'HorizontalAlignment', 'center');
end

if isequal(obj.app_plot, false)
settings_menu = uimenu(obj.figure, 'Text', 'Settings');
change_scale_option = uimenu(settings_menu,'Text','Change Scale');
change_scale_option.MenuSelectedFcn = {...
@obj.adjustScale, [obj.lower_limit, obj.upper_limit], obj.figure,...
struct('lower_bound', obj.lower_limit, 'upper_bound', obj.upper_limit, 'p_value_plot_max', obj.p_value_max),...
false...
};
change_color_map = uimenu(settings_menu, 'Text', 'Change Color Map');
change_color_map.MenuSelectedFcn = {@obj.adjustColor, obj.figure, struct('color_map', obj.color_map, 'color_map_name', ""), false};
end

obj.fixRendering();
hold(obj.axes, 'off') % This may have been turned on. Does nothing if it wasn't.

Expand All@@ -196,7 +210,7 @@ function applyScale(obj, ~, ~, upper_limit_box, lower_limit_box, old_scale, new_
obj.color_bar.Ticks = [];

color_map = color_map_select;
if ~isstring(color_map_select) && ~ischar(color_map_select)
if ~isstring(color_map_select) && ~ischar(color_map_select) && ~isequal(color_map, false)
color_map = get(color_map_select, "Value");
color_map = obj.colormap_choices{color_map};
end
Expand All@@ -207,13 +221,20 @@ function applyScale(obj, ~, ~, upper_limit_box, lower_limit_box, old_scale, new_
if isnumeric(upper_limit_box)
obj.upper_limit = upper_limit_box;
else
obj.upper_limit = get(upper_limit_box, "String");
obj.upper_limit = get(upper_limit_box, 'String');
end

if isnumeric(lower_limit_box)
obj.lower_limit = lower_limit_box;
else
obj.lower_limit = get(lower_limit_box, "String");
obj.lower_limit = get(lower_limit_box, 'String');
end

if isstring(obj.upper_limit) || ischar(obj.upper_limit)
obj.upper_limit = str2double(obj.upper_limit);
end
if isstring(obj.lower_limit) || ischar(obj.lower_limit)
obj.lower_limit = str2double(obj.lower_limit);
end

if ~isstring(obj.plot_scale)
Expand All@@ -239,7 +260,11 @@ function applyScale(obj, ~, ~, upper_limit_box, lower_limit_box, old_scale, new_
discrete_colors = NetworkResultPlotParameter().default_discrete_colors;

if new_scale == "nla.gfx.ProbPlotMethod.DEFAULT"
new_color_map = NetworkResultPlotParameter.getColormap(discrete_colors, obj.upper_limit, color_map);
if ~isequal(color_map, false)
new_color_map = NetworkResultPlotParameter.getColormap(discrete_colors, obj.upper_limit, color_map);
else
new_color_map = obj.color_map;
end
obj.plot_scale = new_scale;
elseif new_scale == "nla.gfx.ProbPlotMethod.LOG"
new_color_map = NetworkResultPlotParameter.getLogColormap(discrete_colors, obj.matrix, obj.upper_limit, color_map);
Expand DownExpand Up@@ -337,7 +362,7 @@ function removeLegend(obj)
image_height = image_height + 20;
end

% colorbar margins
% colorbar marginsobj
if obj.draw_colorbar
image_width = image_width + obj.colorbar_width + obj.colorbar_offset + obj.colorbar_text_w;
end
Expand DownExpand Up@@ -435,10 +460,10 @@ function addCallback(obj, x)
initial_render = false;
upper_value = varargin{2};
lower_value = varargin{1};
if isstring(upper_value)
if isstring(upper_value) || ischar(upper_value) % why are strings not chars???
upper_value = str2double(upper_value);
end
if isstring(lower_value)
if isstring(lower_value) || ischar(lower_value)
lower_value = str2double(lower_value);
end
end
Expand DownExpand Up@@ -677,5 +702,22 @@ function applyColorToData(obj, position_x, position_y, chunk_height, chunk_width
obj.image_display.CData(position_y:position_y + chunk_height - 1, position_x + chunk_width, :) =...
repelem(chunk_color(1:size(chunk_color, 1), size(chunk_color, 2), :), obj.elementSize(), 1);
end

function adjustScale(obj, src, ~, bounds, plot_figure, parameters, ~)
nla.gfx.scaleSelector(src, bounds, plot_figure, parameters, false, @obj.applyScaleWrapper);
end

function adjustColor(obj, src, ~, plot_figure, parameters, ~)
nla.gfx.colorSelector(src, plot_figure, parameters, false, @obj.applyScaleWrapper, obj.colormap_choices);
end

function applyScaleWrapper(obj, ~, ~, upper_limit_box, lower_limit_box, color_map, ~, ~, ~)
% This is used for the edge trimatrix, fc avg which is why we keep the ProbPlotMethod to DEFAULT
if isequal(upper_limit_box, false)
upper_limit_box = obj.upper_limit;
lower_limit_box = obj.lower_limit;
end
obj.applyScale(false, false, upper_limit_box, lower_limit_box, "nla.gfx.ProbPlotMethod.DEFAULT", "nla.gfx.ProbPlotMethod.DEFAULT", color_map)
end
end
end
46 changes: 46 additions & 0 deletions +nla/+gfx/colorSelector.m
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
function colorSelector(src, plot_figure, plot_parameters, chord_type, callback_function, color_choices)
original_figure = src.Parent.Parent;
modal = figure('WindowStyle', 'normal', 'Units', 'pixels', 'Position',...
[original_figure.Position(1), original_figure.Position(2), original_figure.Position(3) / 2, original_figure.Position(4) / 3]);

% Color Map selector
% Adapted from colormap-dropdown: https://www.mathworks.com/matlabcentral/fileexchange/43659-colormap-dropdown-menu

color_map_select = uicontrol('Style', 'popupmenu',...
'Position', [90, 130, 275, 30], "Units", "pixels",...
'FontName', 'Courier');
uicontrol("Style", "text", "string", "Colormaps", "Units", "pixels",...
"Position", [color_map_select.Position(1) - 80, color_map_select.Position(2) - 2, 80, color_map_select.Position(4)]);
initial_colors = 16;
colormap_html = {};
for colors = 1:numel(color_choices)
colormap_function = str2func(strcat(strcat("@(x) ",lower(color_choices{colors})), "(x)"));
CData = colormap_function(initial_colors);
new_html_start = '<HTML> ';
new_html = '';
for color_iterator = initial_colors:-1:1
hex_code = nla.gfx.rgb2hex([CData(color_iterator, 1), CData(color_iterator, 2),...
CData(color_iterator, 3)]);
new_html = [new_html '<FONT bgcolor="' hex_code ' "color="' hex_code '">__</FONT>'];
end
new_html_end = [new_html ' </HTML>'];
new_html = [new_html_start new_html_end];
colormap_html = [colormap_html; new_html];
end

if ~isfield(parameters, "color_map_name")
parameters.color_map_name = 1;
end
set(color_map_select, "Value", parameters.color_map_name, "String", colormap_html);

apply_button_position = [10, 10, 100, 30];
apply_button = uicontrol('String', 'Apply',...
"Callback", {callback_function, false, false, color_map_select, plot_figure, parameters, chord_type},...
"Units", "pixels",...
'Position', apply_button_position);

close_button_position = [apply_button.Position(1) + apply_button.Position(3) + 10,...
apply_button.Position(2), apply_button.Position(3), apply_button.Position(4)];
uicontrol('String', 'Close', 'Callback', @(~, ~)close(modal), "Units", "pixels", 'Position',...
close_button_position);
end
28 changes: 28 additions & 0 deletions +nla/+gfx/scaleSelector.m
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
function scaleSelector(src, bounds, plot_figure, parameters, chord_type, callback_function)
original_figure = src.Parent.Parent;
modal = figure('WindowStyle', 'normal', 'Units', 'pixels', 'Position',...
[original_figure.Position(1), original_figure.Position(2), original_figure.Position(3) / 3, original_figure.Position(4) / 3]);

upper_limit_box = uicontrol('Style', 'edit', "Units", "pixels", 'Position', [90, 130, 100, 30], "String",...
bounds(2));
upper_limit_box.Position(4) = upper_limit_box.FontSize * 2;
lower_limit_box = uicontrol('Style', 'edit', "Units", "pixels", 'Position', [90, 100, 100, 30], "String",...
bounds(1));
lower_limit_box.Position(4) = lower_limit_box.FontSize * 2;

uicontrol('Style', 'text', 'String', 'Upper Limit', "Units", "pixels", 'Position',...
[upper_limit_box.Position(1) - 80, upper_limit_box.Position(2) - 2, 80, upper_limit_box.Position(4)]);
uicontrol('Style', 'text', 'String', 'Lower Limit', "Units", "pixels", 'Position',...
[lower_limit_box.Position(1) - 80, lower_limit_box.Position(2) - 2, 80, lower_limit_box.Position(4)]);

apply_button_position = [10, 10, 100, 30];
apply_button = uicontrol('String', 'Apply',...
"Callback", {callback_function, upper_limit_box, lower_limit_box, false, plot_figure, parameters, chord_type},...
"Units", "pixels",...
'Position', apply_button_position);

close_button_position = [apply_button.Position(1) + apply_button.Position(3) + 10,...
apply_button.Position(2), apply_button.Position(3), apply_button.Position(4)];
uicontrol('String', 'Close', 'Callback', @(~, ~)close(modal), "Units", "pixels", 'Position',...
close_button_position);
end
3 changes: 2 additions & 1 deletion +nla/+inputField/NetworkAtlasFuncConn.m
Original file line numberDiff line numberDiff line change
Expand Up@@ -322,8 +322,9 @@ function buttonViewFCAvgClickedCallback(obj)
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,...
nla.gfx.FigSize.LARGE);
nla.gfx.FigSize.LARGE, "app_plot", false);
fig_l.Position(3) = matrix_plot.image_dimensions("image_width");
fig_l.Position(4) = matrix_plot.image_dimensions("image_height");
matrix_plot.displayImage();
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
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
2 changes: 1 addition & 1 deletion +nla/+edge/+result/Base.m
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,7 +44,7 @@ function output(obj, net_atlas, flags, prob_label)

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));
'upper_limit', obj.coeff_range(2), 'app_plot', false);
matrix_plot.displayImage();
w = matrix_plot.image_dimensions("image_width");
h = matrix_plot.image_dimensions("image_height");
Expand Down
60 changes: 51 additions & 9 deletions +nla/+gfx/+plots/MatrixPlot.m
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,6 +35,7 @@
current_settings % the settings for the plot (upper, lower, scale)
display_legend
p_value_max
app_plot % Used when called for FC Avg
end

properties (Dependent)
Expand DownExpand Up@@ -112,12 +113,13 @@
addParameter(matrix_input_parser, 'y_position', 0, validNumberInput);
addParameter(matrix_input_parser, 'discrete_colorbar', false, @islogical);
addParameter(matrix_input_parser, 'plot_scale', nla.gfx.ProbPlotMethod.DEFAULT);
addParameter(matrix_input_parser, 'p_value_max', 0.05)
addParameter(matrix_input_parser, 'p_value_max', 0.05);
addParameter(matrix_input_parser, 'app_plot', true, @islogical)

parse(matrix_input_parser, figure, name, matrix, networks, figure_size, varargin{:});
properties = {'figure', 'name', 'matrix', 'networks', 'figure_size', 'network_clicked_callback',...
'marked_networks', 'figure_margins', 'draw_legend', 'draw_colorbar', 'color_map', 'lower_limit',...
'upper_limit', 'x_position', 'y_position', 'discrete_colorbar', 'plot_scale', 'p_value_max'};
'upper_limit', 'x_position', 'y_position', 'discrete_colorbar', 'plot_scale', 'p_value_max', 'app_plot'};
for property = properties
obj.(property{1}) = matrix_input_parser.Results.(property{1});
if property{1} == "marked_networks"
Expand DownExpand Up@@ -182,6 +184,18 @@ function displayImage(obj)
'HorizontalAlignment', 'center');
end

if isequal(obj.app_plot, false)
settings_menu = uimenu(obj.figure, 'Text', 'Settings');
change_scale_option = uimenu(settings_menu,'Text','Change Scale');
change_scale_option.MenuSelectedFcn = {...
@obj.adjustScale, [obj.lower_limit, obj.upper_limit], obj.figure,...
struct('lower_bound', obj.lower_limit, 'upper_bound', obj.upper_limit, 'p_value_plot_max', obj.p_value_max),...
false...
};
change_color_map = uimenu(settings_menu, 'Text', 'Change Color Map');
change_color_map.MenuSelectedFcn = {@obj.adjustColor, obj.figure, struct('color_map', obj.color_map, 'color_map_name', ""), false};
end

obj.fixRendering();
hold(obj.axes, 'off') % This may have been turned on. Does nothing if it wasn't.

Expand All@@ -196,7 +210,7 @@ function applyScale(obj, ~, ~, upper_limit_box, lower_limit_box, old_scale, new_
obj.color_bar.Ticks = [];

color_map = color_map_select;
if ~isstring(color_map_select) && ~ischar(color_map_select)
if ~isstring(color_map_select) && ~ischar(color_map_select) && ~isequal(color_map, false)
color_map = get(color_map_select, "Value");
color_map = obj.colormap_choices{color_map};
end
Expand All@@ -207,13 +221,20 @@ function applyScale(obj, ~, ~, upper_limit_box, lower_limit_box, old_scale, new_
if isnumeric(upper_limit_box)
obj.upper_limit = upper_limit_box;
else
obj.upper_limit = get(upper_limit_box, "String");
obj.upper_limit = get(upper_limit_box, 'String');
end

if isnumeric(lower_limit_box)
obj.lower_limit = lower_limit_box;
else
obj.lower_limit = get(lower_limit_box, "String");
obj.lower_limit = get(lower_limit_box, 'String');
end

if isstring(obj.upper_limit) || ischar(obj.upper_limit)
obj.upper_limit = str2double(obj.upper_limit);
end
if isstring(obj.lower_limit) || ischar(obj.lower_limit)
obj.lower_limit = str2double(obj.lower_limit);
end

if ~isstring(obj.plot_scale)
Expand All@@ -239,7 +260,11 @@ function applyScale(obj, ~, ~, upper_limit_box, lower_limit_box, old_scale, new_
discrete_colors = NetworkResultPlotParameter().default_discrete_colors;

if new_scale == "nla.gfx.ProbPlotMethod.DEFAULT"
new_color_map = NetworkResultPlotParameter.getColormap(discrete_colors, obj.upper_limit, color_map);
if ~isequal(color_map, false)
new_color_map = NetworkResultPlotParameter.getColormap(discrete_colors, obj.upper_limit, color_map);
else
new_color_map = obj.color_map;
end
obj.plot_scale = new_scale;
elseif new_scale == "nla.gfx.ProbPlotMethod.LOG"
new_color_map = NetworkResultPlotParameter.getLogColormap(discrete_colors, obj.matrix, obj.upper_limit, color_map);
Expand DownExpand Up@@ -337,7 +362,7 @@ function removeLegend(obj)
image_height = image_height + 20;
end

% colorbar margins
% colorbar marginsobj
if obj.draw_colorbar
image_width = image_width + obj.colorbar_width + obj.colorbar_offset + obj.colorbar_text_w;
end
Expand DownExpand Up@@ -435,10 +460,10 @@ function addCallback(obj, x)
initial_render = false;
upper_value = varargin{2};
lower_value = varargin{1};
if isstring(upper_value)
if isstring(upper_value) || ischar(upper_value) % why are strings not chars???
upper_value = str2double(upper_value);
end
if isstring(lower_value)
if isstring(lower_value) || ischar(lower_value)
lower_value = str2double(lower_value);
end
end
Expand DownExpand Up@@ -677,5 +702,22 @@ function applyColorToData(obj, position_x, position_y, chunk_height, chunk_width
obj.image_display.CData(position_y:position_y + chunk_height - 1, position_x + chunk_width, :) =...
repelem(chunk_color(1:size(chunk_color, 1), size(chunk_color, 2), :), obj.elementSize(), 1);
end

function adjustScale(obj, src, ~, bounds, plot_figure, parameters, ~)
nla.gfx.scaleSelector(src, bounds, plot_figure, parameters, false, @obj.applyScaleWrapper);
end

function adjustColor(obj, src, ~, plot_figure, parameters, ~)
nla.gfx.colorSelector(src, plot_figure, parameters, false, @obj.applyScaleWrapper, obj.colormap_choices);
end

function applyScaleWrapper(obj, ~, ~, upper_limit_box, lower_limit_box, color_map, ~, ~, ~)
% This is used for the edge trimatrix, fc avg which is why we keep the ProbPlotMethod to DEFAULT
if isequal(upper_limit_box, false)
upper_limit_box = obj.upper_limit;
lower_limit_box = obj.lower_limit;
end
obj.applyScale(false, false, upper_limit_box, lower_limit_box, "nla.gfx.ProbPlotMethod.DEFAULT", "nla.gfx.ProbPlotMethod.DEFAULT", color_map)
end
end
end
46 changes: 46 additions & 0 deletions +nla/+gfx/colorSelector.m
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
function colorSelector(src, plot_figure, plot_parameters, chord_type, callback_function, color_choices)
original_figure = src.Parent.Parent;
modal = figure('WindowStyle', 'normal', 'Units', 'pixels', 'Position',...
[original_figure.Position(1), original_figure.Position(2), original_figure.Position(3) / 2, original_figure.Position(4) / 3]);

% Color Map selector
% Adapted from colormap-dropdown: https://www.mathworks.com/matlabcentral/fileexchange/43659-colormap-dropdown-menu

color_map_select = uicontrol('Style', 'popupmenu',...
'Position', [90, 130, 275, 30], "Units", "pixels",...
'FontName', 'Courier');
uicontrol("Style", "text", "string", "Colormaps", "Units", "pixels",...
"Position", [color_map_select.Position(1) - 80, color_map_select.Position(2) - 2, 80, color_map_select.Position(4)]);
initial_colors = 16;
colormap_html = {};
for colors = 1:numel(color_choices)
colormap_function = str2func(strcat(strcat("@(x) ",lower(color_choices{colors})), "(x)"));
CData = colormap_function(initial_colors);
new_html_start = '<HTML> ';
new_html = '';
for color_iterator = initial_colors:-1:1
hex_code = nla.gfx.rgb2hex([CData(color_iterator, 1), CData(color_iterator, 2),...
CData(color_iterator, 3)]);
new_html = [new_html '<FONT bgcolor="' hex_code ' "color="' hex_code '">__</FONT>'];
end
new_html_end = [new_html ' </HTML>'];
new_html = [new_html_start new_html_end];
colormap_html = [colormap_html; new_html];
end

if ~isfield(parameters, "color_map_name")
parameters.color_map_name = 1;
end
set(color_map_select, "Value", parameters.color_map_name, "String", colormap_html);

apply_button_position = [10, 10, 100, 30];
apply_button = uicontrol('String', 'Apply',...
"Callback", {callback_function, false, false, color_map_select, plot_figure, parameters, chord_type},...
"Units", "pixels",...
'Position', apply_button_position);

close_button_position = [apply_button.Position(1) + apply_button.Position(3) + 10,...
apply_button.Position(2), apply_button.Position(3), apply_button.Position(4)];
uicontrol('String', 'Close', 'Callback', @(~, ~)close(modal), "Units", "pixels", 'Position',...
close_button_position);
end
28 changes: 28 additions & 0 deletions +nla/+gfx/scaleSelector.m
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
function scaleSelector(src, bounds, plot_figure, parameters, chord_type, callback_function)
original_figure = src.Parent.Parent;
modal = figure('WindowStyle', 'normal', 'Units', 'pixels', 'Position',...
[original_figure.Position(1), original_figure.Position(2), original_figure.Position(3) / 3, original_figure.Position(4) / 3]);

upper_limit_box = uicontrol('Style', 'edit', "Units", "pixels", 'Position', [90, 130, 100, 30], "String",...
bounds(2));
upper_limit_box.Position(4) = upper_limit_box.FontSize * 2;
lower_limit_box = uicontrol('Style', 'edit', "Units", "pixels", 'Position', [90, 100, 100, 30], "String",...
bounds(1));
lower_limit_box.Position(4) = lower_limit_box.FontSize * 2;

uicontrol('Style', 'text', 'String', 'Upper Limit', "Units", "pixels", 'Position',...
[upper_limit_box.Position(1) - 80, upper_limit_box.Position(2) - 2, 80, upper_limit_box.Position(4)]);
uicontrol('Style', 'text', 'String', 'Lower Limit', "Units", "pixels", 'Position',...
[lower_limit_box.Position(1) - 80, lower_limit_box.Position(2) - 2, 80, lower_limit_box.Position(4)]);

apply_button_position = [10, 10, 100, 30];
apply_button = uicontrol('String', 'Apply',...
"Callback", {callback_function, upper_limit_box, lower_limit_box, false, plot_figure, parameters, chord_type},...
"Units", "pixels",...
'Position', apply_button_position);

close_button_position = [apply_button.Position(1) + apply_button.Position(3) + 10,...
apply_button.Position(2), apply_button.Position(3), apply_button.Position(4)];
uicontrol('String', 'Close', 'Callback', @(~, ~)close(modal), "Units", "pixels", 'Position',...
close_button_position);
end
3 changes: 2 additions & 1 deletion +nla/+inputField/NetworkAtlasFuncConn.m
Original file line numberDiff line numberDiff line change
Expand Up@@ -322,8 +322,9 @@ function buttonViewFCAvgClickedCallback(obj)
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,...
nla.gfx.FigSize.LARGE);
nla.gfx.FigSize.LARGE, "app_plot", false);
fig_l.Position(3) = matrix_plot.image_dimensions("image_width");
fig_l.Position(4) = matrix_plot.image_dimensions("image_height");
matrix_plot.displayImage();
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
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
2 changes: 1 addition & 1 deletion +nla/+edge/+result/Base.m
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,7 +44,7 @@ function output(obj, net_atlas, flags, prob_label)

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));
'upper_limit', obj.coeff_range(2), 'app_plot', false);
matrix_plot.displayImage();
w = matrix_plot.image_dimensions("image_width");
h = matrix_plot.image_dimensions("image_height");
Expand Down
60 changes: 51 additions & 9 deletions +nla/+gfx/+plots/MatrixPlot.m
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,6 +35,7 @@
current_settings % the settings for the plot (upper, lower, scale)
display_legend
p_value_max
app_plot % Used when called for FC Avg
end

properties (Dependent)
Expand DownExpand Up@@ -112,12 +113,13 @@
addParameter(matrix_input_parser, 'y_position', 0, validNumberInput);
addParameter(matrix_input_parser, 'discrete_colorbar', false, @islogical);
addParameter(matrix_input_parser, 'plot_scale', nla.gfx.ProbPlotMethod.DEFAULT);
addParameter(matrix_input_parser, 'p_value_max', 0.05)
addParameter(matrix_input_parser, 'p_value_max', 0.05);
addParameter(matrix_input_parser, 'app_plot', true, @islogical)

parse(matrix_input_parser, figure, name, matrix, networks, figure_size, varargin{:});
properties = {'figure', 'name', 'matrix', 'networks', 'figure_size', 'network_clicked_callback',...
'marked_networks', 'figure_margins', 'draw_legend', 'draw_colorbar', 'color_map', 'lower_limit',...
'upper_limit', 'x_position', 'y_position', 'discrete_colorbar', 'plot_scale', 'p_value_max'};
'upper_limit', 'x_position', 'y_position', 'discrete_colorbar', 'plot_scale', 'p_value_max', 'app_plot'};
for property = properties
obj.(property{1}) = matrix_input_parser.Results.(property{1});
if property{1} == "marked_networks"
Expand DownExpand Up@@ -182,6 +184,18 @@ function displayImage(obj)
'HorizontalAlignment', 'center');
end

if isequal(obj.app_plot, false)
settings_menu = uimenu(obj.figure, 'Text', 'Settings');
change_scale_option = uimenu(settings_menu,'Text','Change Scale');
change_scale_option.MenuSelectedFcn = {...
@obj.adjustScale, [obj.lower_limit, obj.upper_limit], obj.figure,...
struct('lower_bound', obj.lower_limit, 'upper_bound', obj.upper_limit, 'p_value_plot_max', obj.p_value_max),...
false...
};
change_color_map = uimenu(settings_menu, 'Text', 'Change Color Map');
change_color_map.MenuSelectedFcn = {@obj.adjustColor, obj.figure, struct('color_map', obj.color_map, 'color_map_name', ""), false};
end

obj.fixRendering();
hold(obj.axes, 'off') % This may have been turned on. Does nothing if it wasn't.

Expand All@@ -196,7 +210,7 @@ function applyScale(obj, ~, ~, upper_limit_box, lower_limit_box, old_scale, new_
obj.color_bar.Ticks = [];

color_map = color_map_select;
if ~isstring(color_map_select) && ~ischar(color_map_select)
if ~isstring(color_map_select) && ~ischar(color_map_select) && ~isequal(color_map, false)
color_map = get(color_map_select, "Value");
color_map = obj.colormap_choices{color_map};
end
Expand All@@ -207,13 +221,20 @@ function applyScale(obj, ~, ~, upper_limit_box, lower_limit_box, old_scale, new_
if isnumeric(upper_limit_box)
obj.upper_limit = upper_limit_box;
else
obj.upper_limit = get(upper_limit_box, "String");
obj.upper_limit = get(upper_limit_box, 'String');
end

if isnumeric(lower_limit_box)
obj.lower_limit = lower_limit_box;
else
obj.lower_limit = get(lower_limit_box, "String");
obj.lower_limit = get(lower_limit_box, 'String');
end

if isstring(obj.upper_limit) || ischar(obj.upper_limit)
obj.upper_limit = str2double(obj.upper_limit);
end
if isstring(obj.lower_limit) || ischar(obj.lower_limit)
obj.lower_limit = str2double(obj.lower_limit);
end

if ~isstring(obj.plot_scale)
Expand All@@ -239,7 +260,11 @@ function applyScale(obj, ~, ~, upper_limit_box, lower_limit_box, old_scale, new_
discrete_colors = NetworkResultPlotParameter().default_discrete_colors;

if new_scale == "nla.gfx.ProbPlotMethod.DEFAULT"
new_color_map = NetworkResultPlotParameter.getColormap(discrete_colors, obj.upper_limit, color_map);
if ~isequal(color_map, false)
new_color_map = NetworkResultPlotParameter.getColormap(discrete_colors, obj.upper_limit, color_map);
else
new_color_map = obj.color_map;
end
obj.plot_scale = new_scale;
elseif new_scale == "nla.gfx.ProbPlotMethod.LOG"
new_color_map = NetworkResultPlotParameter.getLogColormap(discrete_colors, obj.matrix, obj.upper_limit, color_map);
Expand DownExpand Up@@ -337,7 +362,7 @@ function removeLegend(obj)
image_height = image_height + 20;
end

% colorbar margins
% colorbar marginsobj
if obj.draw_colorbar
image_width = image_width + obj.colorbar_width + obj.colorbar_offset + obj.colorbar_text_w;
end
Expand DownExpand Up@@ -435,10 +460,10 @@ function addCallback(obj, x)
initial_render = false;
upper_value = varargin{2};
lower_value = varargin{1};
if isstring(upper_value)
if isstring(upper_value) || ischar(upper_value) % why are strings not chars???
upper_value = str2double(upper_value);
end
if isstring(lower_value)
if isstring(lower_value) || ischar(lower_value)
lower_value = str2double(lower_value);
end
end
Expand DownExpand Up@@ -677,5 +702,22 @@ function applyColorToData(obj, position_x, position_y, chunk_height, chunk_width
obj.image_display.CData(position_y:position_y + chunk_height - 1, position_x + chunk_width, :) =...
repelem(chunk_color(1:size(chunk_color, 1), size(chunk_color, 2), :), obj.elementSize(), 1);
end

function adjustScale(obj, src, ~, bounds, plot_figure, parameters, ~)
nla.gfx.scaleSelector(src, bounds, plot_figure, parameters, false, @obj.applyScaleWrapper);
end

function adjustColor(obj, src, ~, plot_figure, parameters, ~)
nla.gfx.colorSelector(src, plot_figure, parameters, false, @obj.applyScaleWrapper, obj.colormap_choices);
end

function applyScaleWrapper(obj, ~, ~, upper_limit_box, lower_limit_box, color_map, ~, ~, ~)
% This is used for the edge trimatrix, fc avg which is why we keep the ProbPlotMethod to DEFAULT
if isequal(upper_limit_box, false)
upper_limit_box = obj.upper_limit;
lower_limit_box = obj.lower_limit;
end
obj.applyScale(false, false, upper_limit_box, lower_limit_box, "nla.gfx.ProbPlotMethod.DEFAULT", "nla.gfx.ProbPlotMethod.DEFAULT", color_map)
end
end
end
46 changes: 46 additions & 0 deletions +nla/+gfx/colorSelector.m
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
function colorSelector(src, plot_figure, plot_parameters, chord_type, callback_function, color_choices)
original_figure = src.Parent.Parent;
modal = figure('WindowStyle', 'normal', 'Units', 'pixels', 'Position',...
[original_figure.Position(1), original_figure.Position(2), original_figure.Position(3) / 2, original_figure.Position(4) / 3]);

% Color Map selector
% Adapted from colormap-dropdown: https://www.mathworks.com/matlabcentral/fileexchange/43659-colormap-dropdown-menu

color_map_select = uicontrol('Style', 'popupmenu',...
'Position', [90, 130, 275, 30], "Units", "pixels",...
'FontName', 'Courier');
uicontrol("Style", "text", "string", "Colormaps", "Units", "pixels",...
"Position", [color_map_select.Position(1) - 80, color_map_select.Position(2) - 2, 80, color_map_select.Position(4)]);
initial_colors = 16;
colormap_html = {};
for colors = 1:numel(color_choices)
colormap_function = str2func(strcat(strcat("@(x) ",lower(color_choices{colors})), "(x)"));
CData = colormap_function(initial_colors);
new_html_start = '<HTML> ';
new_html = '';
for color_iterator = initial_colors:-1:1
hex_code = nla.gfx.rgb2hex([CData(color_iterator, 1), CData(color_iterator, 2),...
CData(color_iterator, 3)]);
new_html = [new_html '<FONT bgcolor="' hex_code ' "color="' hex_code '">__</FONT>'];
end
new_html_end = [new_html ' </HTML>'];
new_html = [new_html_start new_html_end];
colormap_html = [colormap_html; new_html];
end

if ~isfield(parameters, "color_map_name")
parameters.color_map_name = 1;
end
set(color_map_select, "Value", parameters.color_map_name, "String", colormap_html);

apply_button_position = [10, 10, 100, 30];
apply_button = uicontrol('String', 'Apply',...
"Callback", {callback_function, false, false, color_map_select, plot_figure, parameters, chord_type},...
"Units", "pixels",...
'Position', apply_button_position);

close_button_position = [apply_button.Position(1) + apply_button.Position(3) + 10,...
apply_button.Position(2), apply_button.Position(3), apply_button.Position(4)];
uicontrol('String', 'Close', 'Callback', @(~, ~)close(modal), "Units", "pixels", 'Position',...
close_button_position);
end
28 changes: 28 additions & 0 deletions +nla/+gfx/scaleSelector.m
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
function scaleSelector(src, bounds, plot_figure, parameters, chord_type, callback_function)
original_figure = src.Parent.Parent;
modal = figure('WindowStyle', 'normal', 'Units', 'pixels', 'Position',...
[original_figure.Position(1), original_figure.Position(2), original_figure.Position(3) / 3, original_figure.Position(4) / 3]);

upper_limit_box = uicontrol('Style', 'edit', "Units", "pixels", 'Position', [90, 130, 100, 30], "String",...
bounds(2));
upper_limit_box.Position(4) = upper_limit_box.FontSize * 2;
lower_limit_box = uicontrol('Style', 'edit', "Units", "pixels", 'Position', [90, 100, 100, 30], "String",...
bounds(1));
lower_limit_box.Position(4) = lower_limit_box.FontSize * 2;

uicontrol('Style', 'text', 'String', 'Upper Limit', "Units", "pixels", 'Position',...
[upper_limit_box.Position(1) - 80, upper_limit_box.Position(2) - 2, 80, upper_limit_box.Position(4)]);
uicontrol('Style', 'text', 'String', 'Lower Limit', "Units", "pixels", 'Position',...
[lower_limit_box.Position(1) - 80, lower_limit_box.Position(2) - 2, 80, lower_limit_box.Position(4)]);

apply_button_position = [10, 10, 100, 30];
apply_button = uicontrol('String', 'Apply',...
"Callback", {callback_function, upper_limit_box, lower_limit_box, false, plot_figure, parameters, chord_type},...
"Units", "pixels",...
'Position', apply_button_position);

close_button_position = [apply_button.Position(1) + apply_button.Position(3) + 10,...
apply_button.Position(2), apply_button.Position(3), apply_button.Position(4)];
uicontrol('String', 'Close', 'Callback', @(~, ~)close(modal), "Units", "pixels", 'Position',...
close_button_position);
end
3 changes: 2 additions & 1 deletion +nla/+inputField/NetworkAtlasFuncConn.m
Original file line numberDiff line numberDiff line change
Expand Up@@ -322,8 +322,9 @@ function buttonViewFCAvgClickedCallback(obj)
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,...
nla.gfx.FigSize.LARGE);
nla.gfx.FigSize.LARGE, "app_plot", false);
fig_l.Position(3) = matrix_plot.image_dimensions("image_width");
fig_l.Position(4) = matrix_plot.image_dimensions("image_height");
matrix_plot.displayImage();
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
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
2 changes: 1 addition & 1 deletion +nla/+edge/+result/Base.m
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,7 +44,7 @@ function output(obj, net_atlas, flags, prob_label)

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));
'upper_limit', obj.coeff_range(2), 'app_plot', false);
matrix_plot.displayImage();
w = matrix_plot.image_dimensions("image_width");
h = matrix_plot.image_dimensions("image_height");
Expand Down
60 changes: 51 additions & 9 deletions +nla/+gfx/+plots/MatrixPlot.m
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,6 +35,7 @@
current_settings % the settings for the plot (upper, lower, scale)
display_legend
p_value_max
app_plot % Used when called for FC Avg
end

properties (Dependent)
Expand DownExpand Up@@ -112,12 +113,13 @@
addParameter(matrix_input_parser, 'y_position', 0, validNumberInput);
addParameter(matrix_input_parser, 'discrete_colorbar', false, @islogical);
addParameter(matrix_input_parser, 'plot_scale', nla.gfx.ProbPlotMethod.DEFAULT);
addParameter(matrix_input_parser, 'p_value_max', 0.05)
addParameter(matrix_input_parser, 'p_value_max', 0.05);
addParameter(matrix_input_parser, 'app_plot', true, @islogical)

parse(matrix_input_parser, figure, name, matrix, networks, figure_size, varargin{:});
properties = {'figure', 'name', 'matrix', 'networks', 'figure_size', 'network_clicked_callback',...
'marked_networks', 'figure_margins', 'draw_legend', 'draw_colorbar', 'color_map', 'lower_limit',...
'upper_limit', 'x_position', 'y_position', 'discrete_colorbar', 'plot_scale', 'p_value_max'};
'upper_limit', 'x_position', 'y_position', 'discrete_colorbar', 'plot_scale', 'p_value_max', 'app_plot'};
for property = properties
obj.(property{1}) = matrix_input_parser.Results.(property{1});
if property{1} == "marked_networks"
Expand DownExpand Up@@ -182,6 +184,18 @@ function displayImage(obj)
'HorizontalAlignment', 'center');
end

if isequal(obj.app_plot, false)
settings_menu = uimenu(obj.figure, 'Text', 'Settings');
change_scale_option = uimenu(settings_menu,'Text','Change Scale');
change_scale_option.MenuSelectedFcn = {...
@obj.adjustScale, [obj.lower_limit, obj.upper_limit], obj.figure,...
struct('lower_bound', obj.lower_limit, 'upper_bound', obj.upper_limit, 'p_value_plot_max', obj.p_value_max),...
false...
};
change_color_map = uimenu(settings_menu, 'Text', 'Change Color Map');
change_color_map.MenuSelectedFcn = {@obj.adjustColor, obj.figure, struct('color_map', obj.color_map, 'color_map_name', ""), false};
end

obj.fixRendering();
hold(obj.axes, 'off') % This may have been turned on. Does nothing if it wasn't.

Expand All@@ -196,7 +210,7 @@ function applyScale(obj, ~, ~, upper_limit_box, lower_limit_box, old_scale, new_
obj.color_bar.Ticks = [];

color_map = color_map_select;
if ~isstring(color_map_select) && ~ischar(color_map_select)
if ~isstring(color_map_select) && ~ischar(color_map_select) && ~isequal(color_map, false)
color_map = get(color_map_select, "Value");
color_map = obj.colormap_choices{color_map};
end
Expand All@@ -207,13 +221,20 @@ function applyScale(obj, ~, ~, upper_limit_box, lower_limit_box, old_scale, new_
if isnumeric(upper_limit_box)
obj.upper_limit = upper_limit_box;
else
obj.upper_limit = get(upper_limit_box, "String");
obj.upper_limit = get(upper_limit_box, 'String');
end

if isnumeric(lower_limit_box)
obj.lower_limit = lower_limit_box;
else
obj.lower_limit = get(lower_limit_box, "String");
obj.lower_limit = get(lower_limit_box, 'String');
end

if isstring(obj.upper_limit) || ischar(obj.upper_limit)
obj.upper_limit = str2double(obj.upper_limit);
end
if isstring(obj.lower_limit) || ischar(obj.lower_limit)
obj.lower_limit = str2double(obj.lower_limit);
end

if ~isstring(obj.plot_scale)
Expand All@@ -239,7 +260,11 @@ function applyScale(obj, ~, ~, upper_limit_box, lower_limit_box, old_scale, new_
discrete_colors = NetworkResultPlotParameter().default_discrete_colors;

if new_scale == "nla.gfx.ProbPlotMethod.DEFAULT"
new_color_map = NetworkResultPlotParameter.getColormap(discrete_colors, obj.upper_limit, color_map);
if ~isequal(color_map, false)
new_color_map = NetworkResultPlotParameter.getColormap(discrete_colors, obj.upper_limit, color_map);
else
new_color_map = obj.color_map;
end
obj.plot_scale = new_scale;
elseif new_scale == "nla.gfx.ProbPlotMethod.LOG"
new_color_map = NetworkResultPlotParameter.getLogColormap(discrete_colors, obj.matrix, obj.upper_limit, color_map);
Expand DownExpand Up@@ -337,7 +362,7 @@ function removeLegend(obj)
image_height = image_height + 20;
end

% colorbar margins
% colorbar marginsobj
if obj.draw_colorbar
image_width = image_width + obj.colorbar_width + obj.colorbar_offset + obj.colorbar_text_w;
end
Expand DownExpand Up@@ -435,10 +460,10 @@ function addCallback(obj, x)
initial_render = false;
upper_value = varargin{2};
lower_value = varargin{1};
if isstring(upper_value)
if isstring(upper_value) || ischar(upper_value) % why are strings not chars???
upper_value = str2double(upper_value);
end
if isstring(lower_value)
if isstring(lower_value) || ischar(lower_value)
lower_value = str2double(lower_value);
end
end
Expand DownExpand Up@@ -677,5 +702,22 @@ function applyColorToData(obj, position_x, position_y, chunk_height, chunk_width
obj.image_display.CData(position_y:position_y + chunk_height - 1, position_x + chunk_width, :) =...
repelem(chunk_color(1:size(chunk_color, 1), size(chunk_color, 2), :), obj.elementSize(), 1);
end

function adjustScale(obj, src, ~, bounds, plot_figure, parameters, ~)
nla.gfx.scaleSelector(src, bounds, plot_figure, parameters, false, @obj.applyScaleWrapper);
end

function adjustColor(obj, src, ~, plot_figure, parameters, ~)
nla.gfx.colorSelector(src, plot_figure, parameters, false, @obj.applyScaleWrapper, obj.colormap_choices);
end

function applyScaleWrapper(obj, ~, ~, upper_limit_box, lower_limit_box, color_map, ~, ~, ~)
% This is used for the edge trimatrix, fc avg which is why we keep the ProbPlotMethod to DEFAULT
if isequal(upper_limit_box, false)
upper_limit_box = obj.upper_limit;
lower_limit_box = obj.lower_limit;
end
obj.applyScale(false, false, upper_limit_box, lower_limit_box, "nla.gfx.ProbPlotMethod.DEFAULT", "nla.gfx.ProbPlotMethod.DEFAULT", color_map)
end
end
end
46 changes: 46 additions & 0 deletions +nla/+gfx/colorSelector.m
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
function colorSelector(src, plot_figure, plot_parameters, chord_type, callback_function, color_choices)
original_figure = src.Parent.Parent;
modal = figure('WindowStyle', 'normal', 'Units', 'pixels', 'Position',...
[original_figure.Position(1), original_figure.Position(2), original_figure.Position(3) / 2, original_figure.Position(4) / 3]);

% Color Map selector
% Adapted from colormap-dropdown: https://www.mathworks.com/matlabcentral/fileexchange/43659-colormap-dropdown-menu

color_map_select = uicontrol('Style', 'popupmenu',...
'Position', [90, 130, 275, 30], "Units", "pixels",...
'FontName', 'Courier');
uicontrol("Style", "text", "string", "Colormaps", "Units", "pixels",...
"Position", [color_map_select.Position(1) - 80, color_map_select.Position(2) - 2, 80, color_map_select.Position(4)]);
initial_colors = 16;
colormap_html = {};
for colors = 1:numel(color_choices)
colormap_function = str2func(strcat(strcat("@(x) ",lower(color_choices{colors})), "(x)"));
CData = colormap_function(initial_colors);
new_html_start = '<HTML> ';
new_html = '';
for color_iterator = initial_colors:-1:1
hex_code = nla.gfx.rgb2hex([CData(color_iterator, 1), CData(color_iterator, 2),...
CData(color_iterator, 3)]);
new_html = [new_html '<FONT bgcolor="' hex_code ' "color="' hex_code '">__</FONT>'];
end
new_html_end = [new_html ' </HTML>'];
new_html = [new_html_start new_html_end];
colormap_html = [colormap_html; new_html];
end

if ~isfield(parameters, "color_map_name")
parameters.color_map_name = 1;
end
set(color_map_select, "Value", parameters.color_map_name, "String", colormap_html);

apply_button_position = [10, 10, 100, 30];
apply_button = uicontrol('String', 'Apply',...
"Callback", {callback_function, false, false, color_map_select, plot_figure, parameters, chord_type},...
"Units", "pixels",...
'Position', apply_button_position);

close_button_position = [apply_button.Position(1) + apply_button.Position(3) + 10,...
apply_button.Position(2), apply_button.Position(3), apply_button.Position(4)];
uicontrol('String', 'Close', 'Callback', @(~, ~)close(modal), "Units", "pixels", 'Position',...
close_button_position);
end
28 changes: 28 additions & 0 deletions +nla/+gfx/scaleSelector.m
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
function scaleSelector(src, bounds, plot_figure, parameters, chord_type, callback_function)
original_figure = src.Parent.Parent;
modal = figure('WindowStyle', 'normal', 'Units', 'pixels', 'Position',...
[original_figure.Position(1), original_figure.Position(2), original_figure.Position(3) / 3, original_figure.Position(4) / 3]);

upper_limit_box = uicontrol('Style', 'edit', "Units", "pixels", 'Position', [90, 130, 100, 30], "String",...
bounds(2));
upper_limit_box.Position(4) = upper_limit_box.FontSize * 2;
lower_limit_box = uicontrol('Style', 'edit', "Units", "pixels", 'Position', [90, 100, 100, 30], "String",...
bounds(1));
lower_limit_box.Position(4) = lower_limit_box.FontSize * 2;

uicontrol('Style', 'text', 'String', 'Upper Limit', "Units", "pixels", 'Position',...
[upper_limit_box.Position(1) - 80, upper_limit_box.Position(2) - 2, 80, upper_limit_box.Position(4)]);
uicontrol('Style', 'text', 'String', 'Lower Limit', "Units", "pixels", 'Position',...
[lower_limit_box.Position(1) - 80, lower_limit_box.Position(2) - 2, 80, lower_limit_box.Position(4)]);

apply_button_position = [10, 10, 100, 30];
apply_button = uicontrol('String', 'Apply',...
"Callback", {callback_function, upper_limit_box, lower_limit_box, false, plot_figure, parameters, chord_type},...
"Units", "pixels",...
'Position', apply_button_position);

close_button_position = [apply_button.Position(1) + apply_button.Position(3) + 10,...
apply_button.Position(2), apply_button.Position(3), apply_button.Position(4)];
uicontrol('String', 'Close', 'Callback', @(~, ~)close(modal), "Units", "pixels", 'Position',...
close_button_position);
end
3 changes: 2 additions & 1 deletion +nla/+inputField/NetworkAtlasFuncConn.m
Original file line numberDiff line numberDiff line change
Expand Up@@ -322,8 +322,9 @@ function buttonViewFCAvgClickedCallback(obj)
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,...
nla.gfx.FigSize.LARGE);
nla.gfx.FigSize.LARGE, "app_plot", false);
fig_l.Position(3) = matrix_plot.image_dimensions("image_width");
fig_l.Position(4) = matrix_plot.image_dimensions("image_height");
matrix_plot.displayImage();
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
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
2 changes: 1 addition & 1 deletion +nla/+edge/+result/Base.m
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,7 +44,7 @@ function output(obj, net_atlas, flags, prob_label)

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));
'upper_limit', obj.coeff_range(2), 'app_plot', false);
matrix_plot.displayImage();
w = matrix_plot.image_dimensions("image_width");
h = matrix_plot.image_dimensions("image_height");
Expand Down
60 changes: 51 additions & 9 deletions +nla/+gfx/+plots/MatrixPlot.m
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,6 +35,7 @@
current_settings % the settings for the plot (upper, lower, scale)
display_legend
p_value_max
app_plot % Used when called for FC Avg
end

properties (Dependent)
Expand DownExpand Up@@ -112,12 +113,13 @@
addParameter(matrix_input_parser, 'y_position', 0, validNumberInput);
addParameter(matrix_input_parser, 'discrete_colorbar', false, @islogical);
addParameter(matrix_input_parser, 'plot_scale', nla.gfx.ProbPlotMethod.DEFAULT);
addParameter(matrix_input_parser, 'p_value_max', 0.05)
addParameter(matrix_input_parser, 'p_value_max', 0.05);
addParameter(matrix_input_parser, 'app_plot', true, @islogical)

parse(matrix_input_parser, figure, name, matrix, networks, figure_size, varargin{:});
properties = {'figure', 'name', 'matrix', 'networks', 'figure_size', 'network_clicked_callback',...
'marked_networks', 'figure_margins', 'draw_legend', 'draw_colorbar', 'color_map', 'lower_limit',...
'upper_limit', 'x_position', 'y_position', 'discrete_colorbar', 'plot_scale', 'p_value_max'};
'upper_limit', 'x_position', 'y_position', 'discrete_colorbar', 'plot_scale', 'p_value_max', 'app_plot'};
for property = properties
obj.(property{1}) = matrix_input_parser.Results.(property{1});
if property{1} == "marked_networks"
Expand DownExpand Up@@ -182,6 +184,18 @@ function displayImage(obj)
'HorizontalAlignment', 'center');
end

if isequal(obj.app_plot, false)
settings_menu = uimenu(obj.figure, 'Text', 'Settings');
change_scale_option = uimenu(settings_menu,'Text','Change Scale');
change_scale_option.MenuSelectedFcn = {...
@obj.adjustScale, [obj.lower_limit, obj.upper_limit], obj.figure,...
struct('lower_bound', obj.lower_limit, 'upper_bound', obj.upper_limit, 'p_value_plot_max', obj.p_value_max),...
false...
};
change_color_map = uimenu(settings_menu, 'Text', 'Change Color Map');
change_color_map.MenuSelectedFcn = {@obj.adjustColor, obj.figure, struct('color_map', obj.color_map, 'color_map_name', ""), false};
end

obj.fixRendering();
hold(obj.axes, 'off') % This may have been turned on. Does nothing if it wasn't.

Expand All@@ -196,7 +210,7 @@ function applyScale(obj, ~, ~, upper_limit_box, lower_limit_box, old_scale, new_
obj.color_bar.Ticks = [];

color_map = color_map_select;
if ~isstring(color_map_select) && ~ischar(color_map_select)
if ~isstring(color_map_select) && ~ischar(color_map_select) && ~isequal(color_map, false)
color_map = get(color_map_select, "Value");
color_map = obj.colormap_choices{color_map};
end
Expand All@@ -207,13 +221,20 @@ function applyScale(obj, ~, ~, upper_limit_box, lower_limit_box, old_scale, new_
if isnumeric(upper_limit_box)
obj.upper_limit = upper_limit_box;
else
obj.upper_limit = get(upper_limit_box, "String");
obj.upper_limit = get(upper_limit_box, 'String');
end

if isnumeric(lower_limit_box)
obj.lower_limit = lower_limit_box;
else
obj.lower_limit = get(lower_limit_box, "String");
obj.lower_limit = get(lower_limit_box, 'String');
end

if isstring(obj.upper_limit) || ischar(obj.upper_limit)
obj.upper_limit = str2double(obj.upper_limit);
end
if isstring(obj.lower_limit) || ischar(obj.lower_limit)
obj.lower_limit = str2double(obj.lower_limit);
end

if ~isstring(obj.plot_scale)
Expand All@@ -239,7 +260,11 @@ function applyScale(obj, ~, ~, upper_limit_box, lower_limit_box, old_scale, new_
discrete_colors = NetworkResultPlotParameter().default_discrete_colors;

if new_scale == "nla.gfx.ProbPlotMethod.DEFAULT"
new_color_map = NetworkResultPlotParameter.getColormap(discrete_colors, obj.upper_limit, color_map);
if ~isequal(color_map, false)
new_color_map = NetworkResultPlotParameter.getColormap(discrete_colors, obj.upper_limit, color_map);
else
new_color_map = obj.color_map;
end
obj.plot_scale = new_scale;
elseif new_scale == "nla.gfx.ProbPlotMethod.LOG"
new_color_map = NetworkResultPlotParameter.getLogColormap(discrete_colors, obj.matrix, obj.upper_limit, color_map);
Expand DownExpand Up@@ -337,7 +362,7 @@ function removeLegend(obj)
image_height = image_height + 20;
end

% colorbar margins
% colorbar marginsobj
if obj.draw_colorbar
image_width = image_width + obj.colorbar_width + obj.colorbar_offset + obj.colorbar_text_w;
end
Expand DownExpand Up@@ -435,10 +460,10 @@ function addCallback(obj, x)
initial_render = false;
upper_value = varargin{2};
lower_value = varargin{1};
if isstring(upper_value)
if isstring(upper_value) || ischar(upper_value) % why are strings not chars???
upper_value = str2double(upper_value);
end
if isstring(lower_value)
if isstring(lower_value) || ischar(lower_value)
lower_value = str2double(lower_value);
end
end
Expand DownExpand Up@@ -677,5 +702,22 @@ function applyColorToData(obj, position_x, position_y, chunk_height, chunk_width
obj.image_display.CData(position_y:position_y + chunk_height - 1, position_x + chunk_width, :) =...
repelem(chunk_color(1:size(chunk_color, 1), size(chunk_color, 2), :), obj.elementSize(), 1);
end

function adjustScale(obj, src, ~, bounds, plot_figure, parameters, ~)
nla.gfx.scaleSelector(src, bounds, plot_figure, parameters, false, @obj.applyScaleWrapper);
end

function adjustColor(obj, src, ~, plot_figure, parameters, ~)
nla.gfx.colorSelector(src, plot_figure, parameters, false, @obj.applyScaleWrapper, obj.colormap_choices);
end

function applyScaleWrapper(obj, ~, ~, upper_limit_box, lower_limit_box, color_map, ~, ~, ~)
% This is used for the edge trimatrix, fc avg which is why we keep the ProbPlotMethod to DEFAULT
if isequal(upper_limit_box, false)
upper_limit_box = obj.upper_limit;
lower_limit_box = obj.lower_limit;
end
obj.applyScale(false, false, upper_limit_box, lower_limit_box, "nla.gfx.ProbPlotMethod.DEFAULT", "nla.gfx.ProbPlotMethod.DEFAULT", color_map)
end
end
end
46 changes: 46 additions & 0 deletions +nla/+gfx/colorSelector.m
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
function colorSelector(src, plot_figure, plot_parameters, chord_type, callback_function, color_choices)
original_figure = src.Parent.Parent;
modal = figure('WindowStyle', 'normal', 'Units', 'pixels', 'Position',...
[original_figure.Position(1), original_figure.Position(2), original_figure.Position(3) / 2, original_figure.Position(4) / 3]);

% Color Map selector
% Adapted from colormap-dropdown: https://www.mathworks.com/matlabcentral/fileexchange/43659-colormap-dropdown-menu

color_map_select = uicontrol('Style', 'popupmenu',...
'Position', [90, 130, 275, 30], "Units", "pixels",...
'FontName', 'Courier');
uicontrol("Style", "text", "string", "Colormaps", "Units", "pixels",...
"Position", [color_map_select.Position(1) - 80, color_map_select.Position(2) - 2, 80, color_map_select.Position(4)]);
initial_colors = 16;
colormap_html = {};
for colors = 1:numel(color_choices)
colormap_function = str2func(strcat(strcat("@(x) ",lower(color_choices{colors})), "(x)"));
CData = colormap_function(initial_colors);
new_html_start = '<HTML> ';
new_html = '';
for color_iterator = initial_colors:-1:1
hex_code = nla.gfx.rgb2hex([CData(color_iterator, 1), CData(color_iterator, 2),...
CData(color_iterator, 3)]);
new_html = [new_html '<FONT bgcolor="' hex_code ' "color="' hex_code '">__</FONT>'];
end
new_html_end = [new_html ' </HTML>'];
new_html = [new_html_start new_html_end];
colormap_html = [colormap_html; new_html];
end

if ~isfield(parameters, "color_map_name")
parameters.color_map_name = 1;
end
set(color_map_select, "Value", parameters.color_map_name, "String", colormap_html);

apply_button_position = [10, 10, 100, 30];
apply_button = uicontrol('String', 'Apply',...
"Callback", {callback_function, false, false, color_map_select, plot_figure, parameters, chord_type},...
"Units", "pixels",...
'Position', apply_button_position);

close_button_position = [apply_button.Position(1) + apply_button.Position(3) + 10,...
apply_button.Position(2), apply_button.Position(3), apply_button.Position(4)];
uicontrol('String', 'Close', 'Callback', @(~, ~)close(modal), "Units", "pixels", 'Position',...
close_button_position);
end
28 changes: 28 additions & 0 deletions +nla/+gfx/scaleSelector.m
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
function scaleSelector(src, bounds, plot_figure, parameters, chord_type, callback_function)
original_figure = src.Parent.Parent;
modal = figure('WindowStyle', 'normal', 'Units', 'pixels', 'Position',...
[original_figure.Position(1), original_figure.Position(2), original_figure.Position(3) / 3, original_figure.Position(4) / 3]);

upper_limit_box = uicontrol('Style', 'edit', "Units", "pixels", 'Position', [90, 130, 100, 30], "String",...
bounds(2));
upper_limit_box.Position(4) = upper_limit_box.FontSize * 2;
lower_limit_box = uicontrol('Style', 'edit', "Units", "pixels", 'Position', [90, 100, 100, 30], "String",...
bounds(1));
lower_limit_box.Position(4) = lower_limit_box.FontSize * 2;

uicontrol('Style', 'text', 'String', 'Upper Limit', "Units", "pixels", 'Position',...
[upper_limit_box.Position(1) - 80, upper_limit_box.Position(2) - 2, 80, upper_limit_box.Position(4)]);
uicontrol('Style', 'text', 'String', 'Lower Limit', "Units", "pixels", 'Position',...
[lower_limit_box.Position(1) - 80, lower_limit_box.Position(2) - 2, 80, lower_limit_box.Position(4)]);

apply_button_position = [10, 10, 100, 30];
apply_button = uicontrol('String', 'Apply',...
"Callback", {callback_function, upper_limit_box, lower_limit_box, false, plot_figure, parameters, chord_type},...
"Units", "pixels",...
'Position', apply_button_position);

close_button_position = [apply_button.Position(1) + apply_button.Position(3) + 10,...
apply_button.Position(2), apply_button.Position(3), apply_button.Position(4)];
uicontrol('String', 'Close', 'Callback', @(~, ~)close(modal), "Units", "pixels", 'Position',...
close_button_position);
end
3 changes: 2 additions & 1 deletion +nla/+inputField/NetworkAtlasFuncConn.m
Original file line numberDiff line numberDiff line change
Expand Up@@ -322,8 +322,9 @@ function buttonViewFCAvgClickedCallback(obj)
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,...
nla.gfx.FigSize.LARGE);
nla.gfx.FigSize.LARGE, "app_plot", false);
fig_l.Position(3) = matrix_plot.image_dimensions("image_width");
fig_l.Position(4) = matrix_plot.image_dimensions("image_height");
matrix_plot.displayImage();
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
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
2 changes: 1 addition & 1 deletion +nla/+edge/+result/Base.m
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,7 +44,7 @@ function output(obj, net_atlas, flags, prob_label)

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));
'upper_limit', obj.coeff_range(2), 'app_plot', false);
matrix_plot.displayImage();
w = matrix_plot.image_dimensions("image_width");
h = matrix_plot.image_dimensions("image_height");
Expand Down
60 changes: 51 additions & 9 deletions +nla/+gfx/+plots/MatrixPlot.m
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,6 +35,7 @@
current_settings % the settings for the plot (upper, lower, scale)
display_legend
p_value_max
app_plot % Used when called for FC Avg
end

properties (Dependent)
Expand DownExpand Up@@ -112,12 +113,13 @@
addParameter(matrix_input_parser, 'y_position', 0, validNumberInput);
addParameter(matrix_input_parser, 'discrete_colorbar', false, @islogical);
addParameter(matrix_input_parser, 'plot_scale', nla.gfx.ProbPlotMethod.DEFAULT);
addParameter(matrix_input_parser, 'p_value_max', 0.05)
addParameter(matrix_input_parser, 'p_value_max', 0.05);
addParameter(matrix_input_parser, 'app_plot', true, @islogical)

parse(matrix_input_parser, figure, name, matrix, networks, figure_size, varargin{:});
properties = {'figure', 'name', 'matrix', 'networks', 'figure_size', 'network_clicked_callback',...
'marked_networks', 'figure_margins', 'draw_legend', 'draw_colorbar', 'color_map', 'lower_limit',...
'upper_limit', 'x_position', 'y_position', 'discrete_colorbar', 'plot_scale', 'p_value_max'};
'upper_limit', 'x_position', 'y_position', 'discrete_colorbar', 'plot_scale', 'p_value_max', 'app_plot'};
for property = properties
obj.(property{1}) = matrix_input_parser.Results.(property{1});
if property{1} == "marked_networks"
Expand DownExpand Up@@ -182,6 +184,18 @@ function displayImage(obj)
'HorizontalAlignment', 'center');
end

if isequal(obj.app_plot, false)
settings_menu = uimenu(obj.figure, 'Text', 'Settings');
change_scale_option = uimenu(settings_menu,'Text','Change Scale');
change_scale_option.MenuSelectedFcn = {...
@obj.adjustScale, [obj.lower_limit, obj.upper_limit], obj.figure,...
struct('lower_bound', obj.lower_limit, 'upper_bound', obj.upper_limit, 'p_value_plot_max', obj.p_value_max),...
false...
};
change_color_map = uimenu(settings_menu, 'Text', 'Change Color Map');
change_color_map.MenuSelectedFcn = {@obj.adjustColor, obj.figure, struct('color_map', obj.color_map, 'color_map_name', ""), false};
end

obj.fixRendering();
hold(obj.axes, 'off') % This may have been turned on. Does nothing if it wasn't.

Expand All@@ -196,7 +210,7 @@ function applyScale(obj, ~, ~, upper_limit_box, lower_limit_box, old_scale, new_
obj.color_bar.Ticks = [];

color_map = color_map_select;
if ~isstring(color_map_select) && ~ischar(color_map_select)
if ~isstring(color_map_select) && ~ischar(color_map_select) && ~isequal(color_map, false)
color_map = get(color_map_select, "Value");
color_map = obj.colormap_choices{color_map};
end
Expand All@@ -207,13 +221,20 @@ function applyScale(obj, ~, ~, upper_limit_box, lower_limit_box, old_scale, new_
if isnumeric(upper_limit_box)
obj.upper_limit = upper_limit_box;
else
obj.upper_limit = get(upper_limit_box, "String");
obj.upper_limit = get(upper_limit_box, 'String');
end

if isnumeric(lower_limit_box)
obj.lower_limit = lower_limit_box;
else
obj.lower_limit = get(lower_limit_box, "String");
obj.lower_limit = get(lower_limit_box, 'String');
end

if isstring(obj.upper_limit) || ischar(obj.upper_limit)
obj.upper_limit = str2double(obj.upper_limit);
end
if isstring(obj.lower_limit) || ischar(obj.lower_limit)
obj.lower_limit = str2double(obj.lower_limit);
end

if ~isstring(obj.plot_scale)
Expand All@@ -239,7 +260,11 @@ function applyScale(obj, ~, ~, upper_limit_box, lower_limit_box, old_scale, new_
discrete_colors = NetworkResultPlotParameter().default_discrete_colors;

if new_scale == "nla.gfx.ProbPlotMethod.DEFAULT"
new_color_map = NetworkResultPlotParameter.getColormap(discrete_colors, obj.upper_limit, color_map);
if ~isequal(color_map, false)
new_color_map = NetworkResultPlotParameter.getColormap(discrete_colors, obj.upper_limit, color_map);
else
new_color_map = obj.color_map;
end
obj.plot_scale = new_scale;
elseif new_scale == "nla.gfx.ProbPlotMethod.LOG"
new_color_map = NetworkResultPlotParameter.getLogColormap(discrete_colors, obj.matrix, obj.upper_limit, color_map);
Expand DownExpand Up@@ -337,7 +362,7 @@ function removeLegend(obj)
image_height = image_height + 20;
end

% colorbar margins
% colorbar marginsobj
if obj.draw_colorbar
image_width = image_width + obj.colorbar_width + obj.colorbar_offset + obj.colorbar_text_w;
end
Expand DownExpand Up@@ -435,10 +460,10 @@ function addCallback(obj, x)
initial_render = false;
upper_value = varargin{2};
lower_value = varargin{1};
if isstring(upper_value)
if isstring(upper_value) || ischar(upper_value) % why are strings not chars???
upper_value = str2double(upper_value);
end
if isstring(lower_value)
if isstring(lower_value) || ischar(lower_value)
lower_value = str2double(lower_value);
end
end
Expand DownExpand Up@@ -677,5 +702,22 @@ function applyColorToData(obj, position_x, position_y, chunk_height, chunk_width
obj.image_display.CData(position_y:position_y + chunk_height - 1, position_x + chunk_width, :) =...
repelem(chunk_color(1:size(chunk_color, 1), size(chunk_color, 2), :), obj.elementSize(), 1);
end

function adjustScale(obj, src, ~, bounds, plot_figure, parameters, ~)
nla.gfx.scaleSelector(src, bounds, plot_figure, parameters, false, @obj.applyScaleWrapper);
end

function adjustColor(obj, src, ~, plot_figure, parameters, ~)
nla.gfx.colorSelector(src, plot_figure, parameters, false, @obj.applyScaleWrapper, obj.colormap_choices);
end

function applyScaleWrapper(obj, ~, ~, upper_limit_box, lower_limit_box, color_map, ~, ~, ~)
% This is used for the edge trimatrix, fc avg which is why we keep the ProbPlotMethod to DEFAULT
if isequal(upper_limit_box, false)
upper_limit_box = obj.upper_limit;
lower_limit_box = obj.lower_limit;
end
obj.applyScale(false, false, upper_limit_box, lower_limit_box, "nla.gfx.ProbPlotMethod.DEFAULT", "nla.gfx.ProbPlotMethod.DEFAULT", color_map)
end
end
end
46 changes: 46 additions & 0 deletions +nla/+gfx/colorSelector.m
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
function colorSelector(src, plot_figure, plot_parameters, chord_type, callback_function, color_choices)
original_figure = src.Parent.Parent;
modal = figure('WindowStyle', 'normal', 'Units', 'pixels', 'Position',...
[original_figure.Position(1), original_figure.Position(2), original_figure.Position(3) / 2, original_figure.Position(4) / 3]);

% Color Map selector
% Adapted from colormap-dropdown: https://www.mathworks.com/matlabcentral/fileexchange/43659-colormap-dropdown-menu

color_map_select = uicontrol('Style', 'popupmenu',...
'Position', [90, 130, 275, 30], "Units", "pixels",...
'FontName', 'Courier');
uicontrol("Style", "text", "string", "Colormaps", "Units", "pixels",...
"Position", [color_map_select.Position(1) - 80, color_map_select.Position(2) - 2, 80, color_map_select.Position(4)]);
initial_colors = 16;
colormap_html = {};
for colors = 1:numel(color_choices)
colormap_function = str2func(strcat(strcat("@(x) ",lower(color_choices{colors})), "(x)"));
CData = colormap_function(initial_colors);
new_html_start = '<HTML> ';
new_html = '';
for color_iterator = initial_colors:-1:1
hex_code = nla.gfx.rgb2hex([CData(color_iterator, 1), CData(color_iterator, 2),...
CData(color_iterator, 3)]);
new_html = [new_html '<FONT bgcolor="' hex_code ' "color="' hex_code '">__</FONT>'];
end
new_html_end = [new_html ' </HTML>'];
new_html = [new_html_start new_html_end];
colormap_html = [colormap_html; new_html];
end

if ~isfield(parameters, "color_map_name")
parameters.color_map_name = 1;
end
set(color_map_select, "Value", parameters.color_map_name, "String", colormap_html);

apply_button_position = [10, 10, 100, 30];
apply_button = uicontrol('String', 'Apply',...
"Callback", {callback_function, false, false, color_map_select, plot_figure, parameters, chord_type},...
"Units", "pixels",...
'Position', apply_button_position);

close_button_position = [apply_button.Position(1) + apply_button.Position(3) + 10,...
apply_button.Position(2), apply_button.Position(3), apply_button.Position(4)];
uicontrol('String', 'Close', 'Callback', @(~, ~)close(modal), "Units", "pixels", 'Position',...
close_button_position);
end
28 changes: 28 additions & 0 deletions +nla/+gfx/scaleSelector.m
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
function scaleSelector(src, bounds, plot_figure, parameters, chord_type, callback_function)
original_figure = src.Parent.Parent;
modal = figure('WindowStyle', 'normal', 'Units', 'pixels', 'Position',...
[original_figure.Position(1), original_figure.Position(2), original_figure.Position(3) / 3, original_figure.Position(4) / 3]);

upper_limit_box = uicontrol('Style', 'edit', "Units", "pixels", 'Position', [90, 130, 100, 30], "String",...
bounds(2));
upper_limit_box.Position(4) = upper_limit_box.FontSize * 2;
lower_limit_box = uicontrol('Style', 'edit', "Units", "pixels", 'Position', [90, 100, 100, 30], "String",...
bounds(1));
lower_limit_box.Position(4) = lower_limit_box.FontSize * 2;

uicontrol('Style', 'text', 'String', 'Upper Limit', "Units", "pixels", 'Position',...
[upper_limit_box.Position(1) - 80, upper_limit_box.Position(2) - 2, 80, upper_limit_box.Position(4)]);
uicontrol('Style', 'text', 'String', 'Lower Limit', "Units", "pixels", 'Position',...
[lower_limit_box.Position(1) - 80, lower_limit_box.Position(2) - 2, 80, lower_limit_box.Position(4)]);

apply_button_position = [10, 10, 100, 30];
apply_button = uicontrol('String', 'Apply',...
"Callback", {callback_function, upper_limit_box, lower_limit_box, false, plot_figure, parameters, chord_type},...
"Units", "pixels",...
'Position', apply_button_position);

close_button_position = [apply_button.Position(1) + apply_button.Position(3) + 10,...
apply_button.Position(2), apply_button.Position(3), apply_button.Position(4)];
uicontrol('String', 'Close', 'Callback', @(~, ~)close(modal), "Units", "pixels", 'Position',...
close_button_position);
end
3 changes: 2 additions & 1 deletion +nla/+inputField/NetworkAtlasFuncConn.m
Original file line numberDiff line numberDiff line change
Expand Up@@ -322,8 +322,9 @@ function buttonViewFCAvgClickedCallback(obj)
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,...
nla.gfx.FigSize.LARGE);
nla.gfx.FigSize.LARGE, "app_plot", false);
fig_l.Position(3) = matrix_plot.image_dimensions("image_width");
fig_l.Position(4) = matrix_plot.image_dimensions("image_height");
matrix_plot.displayImage();
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
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
2 changes: 1 addition & 1 deletion +nla/+edge/+result/Base.m
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,7 +44,7 @@ function output(obj, net_atlas, flags, prob_label)

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));
'upper_limit', obj.coeff_range(2), 'app_plot', false);
matrix_plot.displayImage();
w = matrix_plot.image_dimensions("image_width");
h = matrix_plot.image_dimensions("image_height");
Expand Down
60 changes: 51 additions & 9 deletions +nla/+gfx/+plots/MatrixPlot.m
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,6 +35,7 @@
current_settings % the settings for the plot (upper, lower, scale)
display_legend
p_value_max
app_plot % Used when called for FC Avg
end

properties (Dependent)
Expand DownExpand Up@@ -112,12 +113,13 @@
addParameter(matrix_input_parser, 'y_position', 0, validNumberInput);
addParameter(matrix_input_parser, 'discrete_colorbar', false, @islogical);
addParameter(matrix_input_parser, 'plot_scale', nla.gfx.ProbPlotMethod.DEFAULT);
addParameter(matrix_input_parser, 'p_value_max', 0.05)
addParameter(matrix_input_parser, 'p_value_max', 0.05);
addParameter(matrix_input_parser, 'app_plot', true, @islogical)

parse(matrix_input_parser, figure, name, matrix, networks, figure_size, varargin{:});
properties = {'figure', 'name', 'matrix', 'networks', 'figure_size', 'network_clicked_callback',...
'marked_networks', 'figure_margins', 'draw_legend', 'draw_colorbar', 'color_map', 'lower_limit',...
'upper_limit', 'x_position', 'y_position', 'discrete_colorbar', 'plot_scale', 'p_value_max'};
'upper_limit', 'x_position', 'y_position', 'discrete_colorbar', 'plot_scale', 'p_value_max', 'app_plot'};
for property = properties
obj.(property{1}) = matrix_input_parser.Results.(property{1});
if property{1} == "marked_networks"
Expand DownExpand Up@@ -182,6 +184,18 @@ function displayImage(obj)
'HorizontalAlignment', 'center');
end

if isequal(obj.app_plot, false)
settings_menu = uimenu(obj.figure, 'Text', 'Settings');
change_scale_option = uimenu(settings_menu,'Text','Change Scale');
change_scale_option.MenuSelectedFcn = {...
@obj.adjustScale, [obj.lower_limit, obj.upper_limit], obj.figure,...
struct('lower_bound', obj.lower_limit, 'upper_bound', obj.upper_limit, 'p_value_plot_max', obj.p_value_max),...
false...
};
change_color_map = uimenu(settings_menu, 'Text', 'Change Color Map');
change_color_map.MenuSelectedFcn = {@obj.adjustColor, obj.figure, struct('color_map', obj.color_map, 'color_map_name', ""), false};
end

obj.fixRendering();
hold(obj.axes, 'off') % This may have been turned on. Does nothing if it wasn't.

Expand All@@ -196,7 +210,7 @@ function applyScale(obj, ~, ~, upper_limit_box, lower_limit_box, old_scale, new_
obj.color_bar.Ticks = [];

color_map = color_map_select;
if ~isstring(color_map_select) && ~ischar(color_map_select)
if ~isstring(color_map_select) && ~ischar(color_map_select) && ~isequal(color_map, false)
color_map = get(color_map_select, "Value");
color_map = obj.colormap_choices{color_map};
end
Expand All@@ -207,13 +221,20 @@ function applyScale(obj, ~, ~, upper_limit_box, lower_limit_box, old_scale, new_
if isnumeric(upper_limit_box)
obj.upper_limit = upper_limit_box;
else
obj.upper_limit = get(upper_limit_box, "String");
obj.upper_limit = get(upper_limit_box, 'String');
end

if isnumeric(lower_limit_box)
obj.lower_limit = lower_limit_box;
else
obj.lower_limit = get(lower_limit_box, "String");
obj.lower_limit = get(lower_limit_box, 'String');
end

if isstring(obj.upper_limit) || ischar(obj.upper_limit)
obj.upper_limit = str2double(obj.upper_limit);
end
if isstring(obj.lower_limit) || ischar(obj.lower_limit)
obj.lower_limit = str2double(obj.lower_limit);
end

if ~isstring(obj.plot_scale)
Expand All@@ -239,7 +260,11 @@ function applyScale(obj, ~, ~, upper_limit_box, lower_limit_box, old_scale, new_
discrete_colors = NetworkResultPlotParameter().default_discrete_colors;

if new_scale == "nla.gfx.ProbPlotMethod.DEFAULT"
new_color_map = NetworkResultPlotParameter.getColormap(discrete_colors, obj.upper_limit, color_map);
if ~isequal(color_map, false)
new_color_map = NetworkResultPlotParameter.getColormap(discrete_colors, obj.upper_limit, color_map);
else
new_color_map = obj.color_map;
end
obj.plot_scale = new_scale;
elseif new_scale == "nla.gfx.ProbPlotMethod.LOG"
new_color_map = NetworkResultPlotParameter.getLogColormap(discrete_colors, obj.matrix, obj.upper_limit, color_map);
Expand DownExpand Up@@ -337,7 +362,7 @@ function removeLegend(obj)
image_height = image_height + 20;
end

% colorbar margins
% colorbar marginsobj
if obj.draw_colorbar
image_width = image_width + obj.colorbar_width + obj.colorbar_offset + obj.colorbar_text_w;
end
Expand DownExpand Up@@ -435,10 +460,10 @@ function addCallback(obj, x)
initial_render = false;
upper_value = varargin{2};
lower_value = varargin{1};
if isstring(upper_value)
if isstring(upper_value) || ischar(upper_value) % why are strings not chars???
upper_value = str2double(upper_value);
end
if isstring(lower_value)
if isstring(lower_value) || ischar(lower_value)
lower_value = str2double(lower_value);
end
end
Expand DownExpand Up@@ -677,5 +702,22 @@ function applyColorToData(obj, position_x, position_y, chunk_height, chunk_width
obj.image_display.CData(position_y:position_y + chunk_height - 1, position_x + chunk_width, :) =...
repelem(chunk_color(1:size(chunk_color, 1), size(chunk_color, 2), :), obj.elementSize(), 1);
end

function adjustScale(obj, src, ~, bounds, plot_figure, parameters, ~)
nla.gfx.scaleSelector(src, bounds, plot_figure, parameters, false, @obj.applyScaleWrapper);
end

function adjustColor(obj, src, ~, plot_figure, parameters, ~)
nla.gfx.colorSelector(src, plot_figure, parameters, false, @obj.applyScaleWrapper, obj.colormap_choices);
end

function applyScaleWrapper(obj, ~, ~, upper_limit_box, lower_limit_box, color_map, ~, ~, ~)
% This is used for the edge trimatrix, fc avg which is why we keep the ProbPlotMethod to DEFAULT
if isequal(upper_limit_box, false)
upper_limit_box = obj.upper_limit;
lower_limit_box = obj.lower_limit;
end
obj.applyScale(false, false, upper_limit_box, lower_limit_box, "nla.gfx.ProbPlotMethod.DEFAULT", "nla.gfx.ProbPlotMethod.DEFAULT", color_map)
end
end
end
46 changes: 46 additions & 0 deletions +nla/+gfx/colorSelector.m
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
function colorSelector(src, plot_figure, plot_parameters, chord_type, callback_function, color_choices)
original_figure = src.Parent.Parent;
modal = figure('WindowStyle', 'normal', 'Units', 'pixels', 'Position',...
[original_figure.Position(1), original_figure.Position(2), original_figure.Position(3) / 2, original_figure.Position(4) / 3]);

% Color Map selector
% Adapted from colormap-dropdown: https://www.mathworks.com/matlabcentral/fileexchange/43659-colormap-dropdown-menu

color_map_select = uicontrol('Style', 'popupmenu',...
'Position', [90, 130, 275, 30], "Units", "pixels",...
'FontName', 'Courier');
uicontrol("Style", "text", "string", "Colormaps", "Units", "pixels",...
"Position", [color_map_select.Position(1) - 80, color_map_select.Position(2) - 2, 80, color_map_select.Position(4)]);
initial_colors = 16;
colormap_html = {};
for colors = 1:numel(color_choices)
colormap_function = str2func(strcat(strcat("@(x) ",lower(color_choices{colors})), "(x)"));
CData = colormap_function(initial_colors);
new_html_start = '<HTML> ';
new_html = '';
for color_iterator = initial_colors:-1:1
hex_code = nla.gfx.rgb2hex([CData(color_iterator, 1), CData(color_iterator, 2),...
CData(color_iterator, 3)]);
new_html = [new_html '<FONT bgcolor="' hex_code ' "color="' hex_code '">__</FONT>'];
end
new_html_end = [new_html ' </HTML>'];
new_html = [new_html_start new_html_end];
colormap_html = [colormap_html; new_html];
end

if ~isfield(parameters, "color_map_name")
parameters.color_map_name = 1;
end
set(color_map_select, "Value", parameters.color_map_name, "String", colormap_html);

apply_button_position = [10, 10, 100, 30];
apply_button = uicontrol('String', 'Apply',...
"Callback", {callback_function, false, false, color_map_select, plot_figure, parameters, chord_type},...
"Units", "pixels",...
'Position', apply_button_position);

close_button_position = [apply_button.Position(1) + apply_button.Position(3) + 10,...
apply_button.Position(2), apply_button.Position(3), apply_button.Position(4)];
uicontrol('String', 'Close', 'Callback', @(~, ~)close(modal), "Units", "pixels", 'Position',...
close_button_position);
end
28 changes: 28 additions & 0 deletions +nla/+gfx/scaleSelector.m
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
function scaleSelector(src, bounds, plot_figure, parameters, chord_type, callback_function)
original_figure = src.Parent.Parent;
modal = figure('WindowStyle', 'normal', 'Units', 'pixels', 'Position',...
[original_figure.Position(1), original_figure.Position(2), original_figure.Position(3) / 3, original_figure.Position(4) / 3]);

upper_limit_box = uicontrol('Style', 'edit', "Units", "pixels", 'Position', [90, 130, 100, 30], "String",...
bounds(2));
upper_limit_box.Position(4) = upper_limit_box.FontSize * 2;
lower_limit_box = uicontrol('Style', 'edit', "Units", "pixels", 'Position', [90, 100, 100, 30], "String",...
bounds(1));
lower_limit_box.Position(4) = lower_limit_box.FontSize * 2;

uicontrol('Style', 'text', 'String', 'Upper Limit', "Units", "pixels", 'Position',...
[upper_limit_box.Position(1) - 80, upper_limit_box.Position(2) - 2, 80, upper_limit_box.Position(4)]);
uicontrol('Style', 'text', 'String', 'Lower Limit', "Units", "pixels", 'Position',...
[lower_limit_box.Position(1) - 80, lower_limit_box.Position(2) - 2, 80, lower_limit_box.Position(4)]);

apply_button_position = [10, 10, 100, 30];
apply_button = uicontrol('String', 'Apply',...
"Callback", {callback_function, upper_limit_box, lower_limit_box, false, plot_figure, parameters, chord_type},...
"Units", "pixels",...
'Position', apply_button_position);

close_button_position = [apply_button.Position(1) + apply_button.Position(3) + 10,...
apply_button.Position(2), apply_button.Position(3), apply_button.Position(4)];
uicontrol('String', 'Close', 'Callback', @(~, ~)close(modal), "Units", "pixels", 'Position',...
close_button_position);
end
3 changes: 2 additions & 1 deletion +nla/+inputField/NetworkAtlasFuncConn.m
Original file line numberDiff line numberDiff line change
Expand Up@@ -322,8 +322,9 @@ function buttonViewFCAvgClickedCallback(obj)
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,...
nla.gfx.FigSize.LARGE);
nla.gfx.FigSize.LARGE, "app_plot", false);
fig_l.Position(3) = matrix_plot.image_dimensions("image_width");
fig_l.Position(4) = matrix_plot.image_dimensions("image_height");
matrix_plot.displayImage();
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
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
2 changes: 1 addition & 1 deletion +nla/+edge/+result/Base.m
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,7 +44,7 @@ function output(obj, net_atlas, flags, prob_label)

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));
'upper_limit', obj.coeff_range(2), 'app_plot', false);
matrix_plot.displayImage();
w = matrix_plot.image_dimensions("image_width");
h = matrix_plot.image_dimensions("image_height");
Expand Down
60 changes: 51 additions & 9 deletions +nla/+gfx/+plots/MatrixPlot.m
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,6 +35,7 @@
current_settings % the settings for the plot (upper, lower, scale)
display_legend
p_value_max
app_plot % Used when called for FC Avg
end

properties (Dependent)
Expand DownExpand Up@@ -112,12 +113,13 @@
addParameter(matrix_input_parser, 'y_position', 0, validNumberInput);
addParameter(matrix_input_parser, 'discrete_colorbar', false, @islogical);
addParameter(matrix_input_parser, 'plot_scale', nla.gfx.ProbPlotMethod.DEFAULT);
addParameter(matrix_input_parser, 'p_value_max', 0.05)
addParameter(matrix_input_parser, 'p_value_max', 0.05);
addParameter(matrix_input_parser, 'app_plot', true, @islogical)

parse(matrix_input_parser, figure, name, matrix, networks, figure_size, varargin{:});
properties = {'figure', 'name', 'matrix', 'networks', 'figure_size', 'network_clicked_callback',...
'marked_networks', 'figure_margins', 'draw_legend', 'draw_colorbar', 'color_map', 'lower_limit',...
'upper_limit', 'x_position', 'y_position', 'discrete_colorbar', 'plot_scale', 'p_value_max'};
'upper_limit', 'x_position', 'y_position', 'discrete_colorbar', 'plot_scale', 'p_value_max', 'app_plot'};
for property = properties
obj.(property{1}) = matrix_input_parser.Results.(property{1});
if property{1} == "marked_networks"
Expand DownExpand Up@@ -182,6 +184,18 @@ function displayImage(obj)
'HorizontalAlignment', 'center');
end

if isequal(obj.app_plot, false)
settings_menu = uimenu(obj.figure, 'Text', 'Settings');
change_scale_option = uimenu(settings_menu,'Text','Change Scale');
change_scale_option.MenuSelectedFcn = {...
@obj.adjustScale, [obj.lower_limit, obj.upper_limit], obj.figure,...
struct('lower_bound', obj.lower_limit, 'upper_bound', obj.upper_limit, 'p_value_plot_max', obj.p_value_max),...
false...
};
change_color_map = uimenu(settings_menu, 'Text', 'Change Color Map');
change_color_map.MenuSelectedFcn = {@obj.adjustColor, obj.figure, struct('color_map', obj.color_map, 'color_map_name', ""), false};
end

obj.fixRendering();
hold(obj.axes, 'off') % This may have been turned on. Does nothing if it wasn't.

Expand All@@ -196,7 +210,7 @@ function applyScale(obj, ~, ~, upper_limit_box, lower_limit_box, old_scale, new_
obj.color_bar.Ticks = [];

color_map = color_map_select;
if ~isstring(color_map_select) && ~ischar(color_map_select)
if ~isstring(color_map_select) && ~ischar(color_map_select) && ~isequal(color_map, false)
color_map = get(color_map_select, "Value");
color_map = obj.colormap_choices{color_map};
end
Expand All@@ -207,13 +221,20 @@ function applyScale(obj, ~, ~, upper_limit_box, lower_limit_box, old_scale, new_
if isnumeric(upper_limit_box)
obj.upper_limit = upper_limit_box;
else
obj.upper_limit = get(upper_limit_box, "String");
obj.upper_limit = get(upper_limit_box, 'String');
end

if isnumeric(lower_limit_box)
obj.lower_limit = lower_limit_box;
else
obj.lower_limit = get(lower_limit_box, "String");
obj.lower_limit = get(lower_limit_box, 'String');
end

if isstring(obj.upper_limit) || ischar(obj.upper_limit)
obj.upper_limit = str2double(obj.upper_limit);
end
if isstring(obj.lower_limit) || ischar(obj.lower_limit)
obj.lower_limit = str2double(obj.lower_limit);
end

if ~isstring(obj.plot_scale)
Expand All@@ -239,7 +260,11 @@ function applyScale(obj, ~, ~, upper_limit_box, lower_limit_box, old_scale, new_
discrete_colors = NetworkResultPlotParameter().default_discrete_colors;

if new_scale == "nla.gfx.ProbPlotMethod.DEFAULT"
new_color_map = NetworkResultPlotParameter.getColormap(discrete_colors, obj.upper_limit, color_map);
if ~isequal(color_map, false)
new_color_map = NetworkResultPlotParameter.getColormap(discrete_colors, obj.upper_limit, color_map);
else
new_color_map = obj.color_map;
end
obj.plot_scale = new_scale;
elseif new_scale == "nla.gfx.ProbPlotMethod.LOG"
new_color_map = NetworkResultPlotParameter.getLogColormap(discrete_colors, obj.matrix, obj.upper_limit, color_map);
Expand DownExpand Up@@ -337,7 +362,7 @@ function removeLegend(obj)
image_height = image_height + 20;
end

% colorbar margins
% colorbar marginsobj
if obj.draw_colorbar
image_width = image_width + obj.colorbar_width + obj.colorbar_offset + obj.colorbar_text_w;
end
Expand DownExpand Up@@ -435,10 +460,10 @@ function addCallback(obj, x)
initial_render = false;
upper_value = varargin{2};
lower_value = varargin{1};
if isstring(upper_value)
if isstring(upper_value) || ischar(upper_value) % why are strings not chars???
upper_value = str2double(upper_value);
end
if isstring(lower_value)
if isstring(lower_value) || ischar(lower_value)
lower_value = str2double(lower_value);
end
end
Expand DownExpand Up@@ -677,5 +702,22 @@ function applyColorToData(obj, position_x, position_y, chunk_height, chunk_width
obj.image_display.CData(position_y:position_y + chunk_height - 1, position_x + chunk_width, :) =...
repelem(chunk_color(1:size(chunk_color, 1), size(chunk_color, 2), :), obj.elementSize(), 1);
end

function adjustScale(obj, src, ~, bounds, plot_figure, parameters, ~)
nla.gfx.scaleSelector(src, bounds, plot_figure, parameters, false, @obj.applyScaleWrapper);
end

function adjustColor(obj, src, ~, plot_figure, parameters, ~)
nla.gfx.colorSelector(src, plot_figure, parameters, false, @obj.applyScaleWrapper, obj.colormap_choices);
end

function applyScaleWrapper(obj, ~, ~, upper_limit_box, lower_limit_box, color_map, ~, ~, ~)
% This is used for the edge trimatrix, fc avg which is why we keep the ProbPlotMethod to DEFAULT
if isequal(upper_limit_box, false)
upper_limit_box = obj.upper_limit;
lower_limit_box = obj.lower_limit;
end
obj.applyScale(false, false, upper_limit_box, lower_limit_box, "nla.gfx.ProbPlotMethod.DEFAULT", "nla.gfx.ProbPlotMethod.DEFAULT", color_map)
end
end
end
46 changes: 46 additions & 0 deletions +nla/+gfx/colorSelector.m
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
function colorSelector(src, plot_figure, plot_parameters, chord_type, callback_function, color_choices)
original_figure = src.Parent.Parent;
modal = figure('WindowStyle', 'normal', 'Units', 'pixels', 'Position',...
[original_figure.Position(1), original_figure.Position(2), original_figure.Position(3) / 2, original_figure.Position(4) / 3]);

% Color Map selector
% Adapted from colormap-dropdown: https://www.mathworks.com/matlabcentral/fileexchange/43659-colormap-dropdown-menu

color_map_select = uicontrol('Style', 'popupmenu',...
'Position', [90, 130, 275, 30], "Units", "pixels",...
'FontName', 'Courier');
uicontrol("Style", "text", "string", "Colormaps", "Units", "pixels",...
"Position", [color_map_select.Position(1) - 80, color_map_select.Position(2) - 2, 80, color_map_select.Position(4)]);
initial_colors = 16;
colormap_html = {};
for colors = 1:numel(color_choices)
colormap_function = str2func(strcat(strcat("@(x) ",lower(color_choices{colors})), "(x)"));
CData = colormap_function(initial_colors);
new_html_start = '<HTML> ';
new_html = '';
for color_iterator = initial_colors:-1:1
hex_code = nla.gfx.rgb2hex([CData(color_iterator, 1), CData(color_iterator, 2),...
CData(color_iterator, 3)]);
new_html = [new_html '<FONT bgcolor="' hex_code ' "color="' hex_code '">__</FONT>'];
end
new_html_end = [new_html ' </HTML>'];
new_html = [new_html_start new_html_end];
colormap_html = [colormap_html; new_html];
end

if ~isfield(parameters, "color_map_name")
parameters.color_map_name = 1;
end
set(color_map_select, "Value", parameters.color_map_name, "String", colormap_html);

apply_button_position = [10, 10, 100, 30];
apply_button = uicontrol('String', 'Apply',...
"Callback", {callback_function, false, false, color_map_select, plot_figure, parameters, chord_type},...
"Units", "pixels",...
'Position', apply_button_position);

close_button_position = [apply_button.Position(1) + apply_button.Position(3) + 10,...
apply_button.Position(2), apply_button.Position(3), apply_button.Position(4)];
uicontrol('String', 'Close', 'Callback', @(~, ~)close(modal), "Units", "pixels", 'Position',...
close_button_position);
end
28 changes: 28 additions & 0 deletions +nla/+gfx/scaleSelector.m
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
function scaleSelector(src, bounds, plot_figure, parameters, chord_type, callback_function)
original_figure = src.Parent.Parent;
modal = figure('WindowStyle', 'normal', 'Units', 'pixels', 'Position',...
[original_figure.Position(1), original_figure.Position(2), original_figure.Position(3) / 3, original_figure.Position(4) / 3]);

upper_limit_box = uicontrol('Style', 'edit', "Units", "pixels", 'Position', [90, 130, 100, 30], "String",...
bounds(2));
upper_limit_box.Position(4) = upper_limit_box.FontSize * 2;
lower_limit_box = uicontrol('Style', 'edit', "Units", "pixels", 'Position', [90, 100, 100, 30], "String",...
bounds(1));
lower_limit_box.Position(4) = lower_limit_box.FontSize * 2;

uicontrol('Style', 'text', 'String', 'Upper Limit', "Units", "pixels", 'Position',...
[upper_limit_box.Position(1) - 80, upper_limit_box.Position(2) - 2, 80, upper_limit_box.Position(4)]);
uicontrol('Style', 'text', 'String', 'Lower Limit', "Units", "pixels", 'Position',...
[lower_limit_box.Position(1) - 80, lower_limit_box.Position(2) - 2, 80, lower_limit_box.Position(4)]);

apply_button_position = [10, 10, 100, 30];
apply_button = uicontrol('String', 'Apply',...
"Callback", {callback_function, upper_limit_box, lower_limit_box, false, plot_figure, parameters, chord_type},...
"Units", "pixels",...
'Position', apply_button_position);

close_button_position = [apply_button.Position(1) + apply_button.Position(3) + 10,...
apply_button.Position(2), apply_button.Position(3), apply_button.Position(4)];
uicontrol('String', 'Close', 'Callback', @(~, ~)close(modal), "Units", "pixels", 'Position',...
close_button_position);
end
3 changes: 2 additions & 1 deletion +nla/+inputField/NetworkAtlasFuncConn.m
Original file line numberDiff line numberDiff line change
Expand Up@@ -322,8 +322,9 @@ function buttonViewFCAvgClickedCallback(obj)
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,...
nla.gfx.FigSize.LARGE);
nla.gfx.FigSize.LARGE, "app_plot", false);
fig_l.Position(3) = matrix_plot.image_dimensions("image_width");
fig_l.Position(4) = matrix_plot.image_dimensions("image_height");
matrix_plot.displayImage();
Expand Down
Loading
Loading