|
37 | 37 | label_gap = LABEL_GAP; |
38 | 38 | h = LABEL_H * 2 + label_gap; |
39 | 39 |
|
40 | | - %% Create label |
| 40 | + %% NETWORK ATLAS |
| 41 | + |
| 42 | + % Create label |
41 | 43 | if ~isgraphics(obj.label) |
42 | 44 | obj.label = uilabel(parent); |
43 | 45 | end |
|
46 | 48 | obj.label.HorizontalAlignment = 'left'; |
47 | 49 | obj.label.Position = [x, y - LABEL_H, label_w + label_gap, LABEL_H]; |
48 | 50 |
|
49 | | - %% Create button |
| 51 | + % Create button |
50 | 52 | if ~isgraphics(obj.button) |
51 | 53 | obj.button = uibutton(parent, 'push', 'ButtonPushedFcn', @(h,e)obj.buttonClickedCallback()); |
52 | 54 | end |
53 | 55 | button_w = 100; |
54 | 56 | obj.button.Position = [x + label_w + label_gap, y - LABEL_H, button_w, LABEL_H]; |
55 | 57 |
|
56 | | - %% Mesh inflation selector |
| 58 | + % Mesh inflation selector |
57 | 59 | if ~isgraphics(obj.inflation_label) |
58 | 60 | obj.inflation_label = uilabel(parent); |
59 | 61 | obj.inflation_label.HorizontalAlignment = 'right'; |
|
70 | 72 | end |
71 | 73 | obj.inflation_dropdown.Position = [0, y - LABEL_H, inflation_dropdown_w, LABEL_H]; |
72 | 74 |
|
73 | | - %% 'View as surface parcel' checkbox |
| 75 | + % 'View as surface parcel' checkbox |
74 | 76 | checkbox_surface_parcels_w = 108; |
75 | 77 | if ~isgraphics(obj.checkbox_surface_parcels) |
76 | 78 | obj.checkbox_surface_parcels = uicheckbox(parent); |
77 | 79 | obj.checkbox_surface_parcels.Text = ' Surface parcels'; |
78 | 80 | end |
79 | 81 | obj.checkbox_surface_parcels.Position = [0, y - LABEL_H, checkbox_surface_parcels_w, LABEL_H]; |
80 | 82 |
|
81 | | - %% Create view button |
| 83 | + % Create view button |
82 | 84 | if ~isgraphics(obj.button_view_net_atlas) |
83 | 85 | obj.button_view_net_atlas = uibutton(parent, 'push', 'ButtonPushedFcn',... |
84 | 86 | @(h,e)obj.buttonViewNetAtlasClickedCallback()); |
|
88 | 90 | obj.button_view_net_atlas.Position = [0, y - LABEL_H, button_view_net_atlas_w, LABEL_H]; |
89 | 91 |
|
90 | 92 | w = label_w + label_gap + button_w + label_gap + checkbox_surface_parcels_w + label_gap + button_view_net_atlas_w; |
91 | | - |
92 | | - %% Create label2 |
| 93 | + %% |
| 94 | + |
| 95 | + %% FUNCTIONAL CONNECTIVITY |
| 96 | + % Create label2 |
93 | 97 | if ~isgraphics(obj.label2) |
94 | 98 | obj.label2 = uilabel(parent); |
95 | 99 | end |
|
98 | 102 | obj.label2.HorizontalAlignment = 'left'; |
99 | 103 | obj.label2.Position = [x, y - h, label2_w + label_gap, LABEL_H]; |
100 | 104 |
|
101 | | - %% Create button2 |
| 105 | + % Create button2 |
102 | 106 | if ~isgraphics(obj.button2) |
103 | 107 | obj.button2 = uibutton(parent, 'push', 'ButtonPushedFcn', @(h,e)obj.button2ClickedCallback()); |
104 | 108 | end |
105 | 109 | button2_w = 100; |
106 | 110 | obj.button2.Position = [x + label2_w + label_gap, y - h, button2_w, LABEL_H]; |
107 | 111 |
|
108 | | - %% Create view button |
| 112 | + % Create view button |
109 | 113 | if ~isgraphics(obj.button_view_fc_avg) |
110 | 114 | obj.button_view_fc_avg = uibutton(parent, 'push', 'ButtonPushedFcn', @(h,e)obj.buttonViewFCAvgClickedCallback()); |
111 | 115 | end |
|
116 | 120 |
|
117 | 121 | w2 = label2_w + label_gap + button2_w + label_gap + button_view_fc_avg_w; |
118 | 122 | w = max(w, w2); |
| 123 | + %% |
119 | 124 | end |
120 | 125 |
|
121 | 126 | function undraw(obj) |
@@ -204,55 +209,81 @@ function buttonClickedCallback(obj, ~) |
204 | 209 | end |
205 | 210 |
|
206 | 211 | function button2ClickedCallback(obj, ~) |
207 | | - [file, path, idx] = uigetfile({'*.mat', 'Functional connectivity matrix (*.mat)'}, 'Select Functional Connectivity Matrix'); |
208 | | - if idx == 1 |
209 | | - prog = uiprogressdlg(obj.fig, 'Title', 'Loading functional connectivity data', 'Message',... |
210 | | - sprintf('Loading %s', file), 'Indeterminate', true); |
211 | | - drawnow; |
212 | | - |
| 212 | + [file, path, idx] = uigetfile(... |
| 213 | + {'*.mat', 'MATLAB File (*.mat)'; '*.csv', 'Comma-separated Values (*.csv)'; '*.txt', 'Text file (*.txt)'},... |
| 214 | + 'Select Functional Connectivity Matrix', 'MultiSelect', 'on'... |
| 215 | + ); |
| 216 | + text_file = file; |
| 217 | + if iscell(file) |
| 218 | + text_file = file{1}; |
| 219 | + end |
| 220 | + prog = uiprogressdlg(obj.fig, 'Title', 'Loading functional connectivity data', 'Message',... |
| 221 | + sprintf('Loading %s', text_file), 'Indeterminate', true); |
| 222 | + drawnow; |
| 223 | + |
| 224 | + fc_unordered = false; |
| 225 | + if idx == 1 |
213 | 226 | fc_data = load([path file]); |
214 | | - fc_unordered = false; |
215 | | - if isnumeric(fc_data) |
216 | | - fc_unordered = fc_data; |
217 | | - elseif isstruct(fc_data) |
218 | | - if isfield(fc_data, 'functional_connectivity') |
219 | | - fc_unordered = fc_data.functional_connectivity; |
220 | | - elseif isfield(fc_data, 'func_conn') |
221 | | - fc_unordered = fc_data.func_conn; |
222 | | - elseif isfield(fc_data, 'fc') |
223 | | - fc_unordered = fc_data.fc; |
224 | | - else |
225 | | - fn = fieldnames(fc_data); |
226 | | - if numel(fn) == 1 |
227 | | - fname = fn{1}; |
228 | | - if isnumeric(fc_data.(fname)) |
229 | | - fc_unordered = fc_data.(fname); |
230 | | - end |
| 227 | + else |
| 228 | + if iscell(file) |
| 229 | + fc_data = readmatrix([path file{1}]); |
| 230 | + for current_file = 2:numel(file) |
| 231 | + fc_data(:,:,current_file) = readmatrix([path file{current_file}]); |
| 232 | + end |
| 233 | + else |
| 234 | + fc_data = readmatrix([path file]); |
| 235 | + fc_data_size = size(fc_data); |
| 236 | + if numel(fc_data_size) == 2 && fc_data_size(1) ~= fc_data_size(2) |
| 237 | + greater_dimension = fc_data_size(2); |
| 238 | + lesser_dimension = fc_data_size(1); |
| 239 | + if fc_data_size(1) > fc_data_size(2) |
| 240 | + greater_dimension = fc_data_size(1); |
| 241 | + lesser_dimension = fc_data_size(2); |
231 | 242 | end |
| 243 | + third_dimension = greater_dimension / lesser_dimension; |
| 244 | + fc_data = reshape(fc_data, [lesser_dimension, lesser_dimension, third_dimension]); |
232 | 245 | end |
233 | 246 | end |
| 247 | + end |
234 | 248 |
|
235 | | - % functional connectivity matrix (not ordered/trimmed according to network atlas yet) |
236 | | - if ~islogical(fc_unordered) |
237 | | - obj.func_conn_unordered = double(fc_unordered); |
238 | | - |
239 | | - %% Transform R-values to Z-scores |
240 | | - % If this condition isn't true, it cannot be R values |
241 | | - % If it is true, it is almost certainly R values but might not be |
242 | | - if all(abs(obj.func_conn_unordered(:)) <= 1) |
243 | | - sel = uiconfirm(obj.fig, sprintf('Fisher Z transform functional connectivity data?\n(If you have provided R-values)'), 'Fisher Z transform?'); |
244 | | - if strcmp(sel, 'Ok') |
245 | | - obj.func_conn_unordered = nla.fisherR2Z(obj.func_conn_unordered); |
| 249 | + if isnumeric(fc_data) |
| 250 | + fc_unordered = fc_data; |
| 251 | + elseif isstruct(fc_data) |
| 252 | + if isfield(fc_data, 'functional_connectivity') |
| 253 | + fc_unordered = fc_data.functional_connectivity; |
| 254 | + elseif isfield(fc_data, 'func_conn') |
| 255 | + fc_unordered = fc_data.func_conn; |
| 256 | + elseif isfield(fc_data, 'fc') |
| 257 | + fc_unordered = fc_data.fc; |
| 258 | + else |
| 259 | + fn = fieldnames(fc_data); |
| 260 | + if numel(fn) == 1 |
| 261 | + fname = fn{1}; |
| 262 | + if isnumeric(fc_data.(fname)) |
| 263 | + fc_unordered = fc_data.(fname); |
246 | 264 | end |
247 | 265 | end |
248 | | - |
249 | | - obj.update(); |
250 | | - close(prog); |
251 | | - else |
252 | | - close(prog); |
253 | | - uialert(obj.fig, sprintf('Could not load functional connectivity matrix from %s', file), 'Invalid functional connectivity file'); |
254 | 266 | end |
255 | 267 | end |
| 268 | + |
| 269 | + % functional connectivity matrix (not ordered/trimmed according to network atlas yet) |
| 270 | + if ~islogical(fc_unordered) |
| 271 | + obj.func_conn_unordered = double(fc_unordered); |
| 272 | + |
| 273 | + %% Transform R-values to Z-scores |
| 274 | + % If this condition isn't true, it cannot be R values |
| 275 | + % If it is true, it is almost certainly R values but might not be |
| 276 | + if all(abs(obj.func_conn_unordered(:)) <= 1) |
| 277 | + sel = uiconfirm(obj.fig, sprintf('Fisher Z transform functional connectivity data?\n(If you have provided R-values)'), 'Fisher Z transform?'); |
| 278 | + if strcmp(sel, 'Ok') |
| 279 | + obj.func_conn_unordered = nla.fisherR2Z(obj.func_conn_unordered); |
| 280 | + end |
| 281 | + end |
| 282 | + obj.update(); |
| 283 | + else |
| 284 | + uialert(obj.fig, sprintf('Could not load functional connectivity matrix from %s', file), 'Invalid functional connectivity file'); |
| 285 | + end |
| 286 | + close(prog); |
256 | 287 | end |
257 | 288 |
|
258 | 289 | function buttonViewNetAtlasClickedCallback(obj) |
|
0 commit comments