22
22
23
23
% Edit the above text to modify the response to pushbutton_help DQ_Table_GUI
24
24
25
- % Last Modified by GUIDE v2.5 15-Oct-2019 17:13:28
25
+ % Last Modified by GUIDE v2.5 05-Aug-2020 04:05:17
26
26
27
27
% Begin initialization code - DO NOT EDIT
28
28
gui_Singleton = 1 ;
@@ -112,6 +112,7 @@ function DQ_Table_GUI_OpeningFcn(hObject, eventdata, handles, varargin)
112
112
113
113
table_data = ERP .dataquality(selected_DQ_type ).data(: ,: ,selected_bin );
114
114
handles.dq_table.Data = table_data ;
115
+ handles.orig_data = table_data ;
115
116
116
117
% electrode labels from ERPset, iff present and number matches
117
118
if isfield(ERP .chanlocs ,' labels' ) && numel(ERP .chanlocs ) == n_elec
@@ -145,6 +146,7 @@ function DQ_Table_GUI_OpeningFcn(hObject, eventdata, handles, varargin)
145
146
desired_fontsize = erpworkingmemory(' fontsizeGUI' );
146
147
handles.dq_table.FontSize = desired_fontsize ;
147
148
149
+ handles.heatmap_on = 0 ;
148
150
149
151
% Update handles structure
150
152
handles.ERP = ERP ;
@@ -204,6 +206,7 @@ function popupmenu_DQ_type_Callback(hObject, eventdata, handles)
204
206
205
207
206
208
handles.dq_table.Data = table_data ;
209
+ handles.orig_data = table_data ;
207
210
208
211
% Time-window labels
209
212
clear tw_labels
@@ -223,6 +226,13 @@ function popupmenu_DQ_type_Callback(hObject, eventdata, handles)
223
226
end
224
227
handles.dq_table.ColumnName = tw_labels ;
225
228
229
+ if handles .heatmap_on
230
+ redraw_heatmap(hObject , eventdata , handles );
231
+ end
232
+ % Update handles structure
233
+ guidata(hObject , handles );
234
+
235
+
226
236
227
237
% --- Executes during object creation, after setting all properties.
228
238
function popupmenu_DQ_type_CreateFcn(hObject , eventdata , handles )
@@ -269,6 +279,14 @@ function popupmenu_bin_Callback(hObject, eventdata, handles)
269
279
270
280
271
281
handles.dq_table.Data = table_data ;
282
+ handles.orig_data = table_data ;
283
+
284
+ if handles .heatmap_on
285
+ redraw_heatmap(hObject , eventdata , handles );
286
+ end
287
+
288
+ % Update handles structure
289
+ guidata(hObject , handles );
272
290
273
291
274
292
% --- Executes during object creation, after setting all properties.
@@ -296,6 +314,7 @@ function checkbox_text_labels_Callback(hObject, eventdata, handles)
296
314
297
315
table_data = handles .ERP .dataquality(selected_DQ_type ).data(: ,: ,selected_bin );
298
316
handles.dq_table.Data = table_data ;
317
+ handles.orig_data = table_data ;
299
318
300
319
% Time-window labels
301
320
clear tw_labels
@@ -315,6 +334,14 @@ function checkbox_text_labels_Callback(hObject, eventdata, handles)
315
334
end
316
335
handles.dq_table.ColumnName = tw_labels ;
317
336
337
+ if handles .heatmap_on
338
+ redraw_heatmap(hObject , eventdata , handles );
339
+ end
340
+
341
+
342
+ % Update handles structure
343
+ guidata(hObject , handles );
344
+
318
345
319
346
% --- Executes on button press in pushbutton_xls.
320
347
function pushbutton_xls_Callback(hObject , eventdata , handles )
@@ -326,6 +353,7 @@ function pushbutton_xls_Callback(hObject, eventdata, handles)
326
353
save_data_quality(handles .ERP ,empty_filename ,' xls' ,selected_DQ_type )
327
354
328
355
356
+
329
357
% --- Executes on button press in pushbutton_mat.
330
358
function pushbutton_mat_Callback(hObject , eventdata , handles )
331
359
% hObject handle to pushbutton_mat (see GCBO)
@@ -361,3 +389,64 @@ function figure1_CloseRequestFcn(hObject, eventdata, handles)
361
389
362
390
% Hint: delete(hObject) closes the figure
363
391
delete(hObject );
392
+
393
+
394
+ % --- Executes on button press in checkbox_heatmap.
395
+ function checkbox_heatmap_Callback(hObject , eventdata , handles )
396
+ % hObject handle to checkbox_heatmap (see GCBO)
397
+ % eventdata reserved - to be defined in a future version of MATLAB
398
+ % handles structure with handles and user data (see GUIDATA)
399
+
400
+ % Hint: get(hObject,'Value') returns toggle state of checkbox_heatmap
401
+ heatmap_on = get(hObject ,' Value' );
402
+
403
+ if heatmap_on == 1
404
+ handles.heatmap_on = 1 ;
405
+ redraw_heatmap(hObject , eventdata , handles );
406
+
407
+ else
408
+ handles.heatmap_on = 0 ;
409
+ clear_heatmap(hObject , eventdata , handles );
410
+
411
+ end
412
+ % Update handles structure
413
+ guidata(hObject , handles );
414
+
415
+
416
+ function redraw_heatmap(hObject , eventdata , handles )
417
+
418
+ color_map = viridis ;
419
+ data = handles .dq_table .Data ;
420
+
421
+ data_min = min(data(: ));
422
+ range_val = max(data(: )) - data_min ;
423
+ range_colormap = size(color_map ,1 ); % as in, 256 shades?
424
+ val_increase_per_shade = range_val / range_colormap ;
425
+
426
+ % Use this @ anonymous function to make HTML tag in box in loop below
427
+ colergen = @(color ,text ) [' <html><table border=0 width=400 bgcolor=' ,color ,' ><TR><TD>' ,text ,' </TD></TR> </table>' ];
428
+
429
+
430
+ for cell = 1 : numel(data )
431
+ data_here = data(cell );
432
+ shades_up_here = round((data_here - data_min ) / val_increase_per_shade );
433
+ if shades_up_here < 1
434
+ shades_up_here = 1 ;
435
+ end
436
+ if shades_up_here > range_colormap
437
+ shades_up_here = range_colormap ;
438
+ end
439
+ RGB_here = color_map(shades_up_here ,: );
440
+ hex_color_here = [' #' dec2hex(round(255 * RGB_here(1 )),2 ) dec2hex(round(255 * RGB_here(2 )),2 ) dec2hex(round(255 * RGB_here(3 )),2 )];
441
+ data2{cell } = colergen(hex_color_here ,num2str(data_here ));
442
+ end
443
+
444
+ data2 = reshape(data2 ,size(data ));
445
+
446
+ handles.dq_table.Data = data2 ;
447
+
448
+
449
+
450
+ function clear_heatmap(hObject , eventdata , handles )
451
+ handles.dq_table.Data = handles .orig_data ;
452
+
0 commit comments