-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathpspm_display.m
1100 lines (928 loc) · 36.4 KB
/
pspm_display.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
function varargout = pspm_display(varargin)
% ● Description
% pspm_display is the code for the GUI that is used to display different data from scr
% datafiles.
% ● Arguments
% Accepts input: 'filepath/filename'
% ● History
% Introduced in PsPM 3.0
% Written in 2013 Philipp C Paulus (Technische Universitaet Dresden)
% Maintained in 2021 by Teddy Chao (UCL)
%% Initialise
global settings
if isempty(settings)
pspm_init;
end
sts = -1;
global channel_type_reference_list;
channel_type_reference_list = settings.channeltypes;
% -------------------------------------------------------------------------
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @pspm_display_OpeningFcn, ...
'gui_OutputFcn', @pspm_display_OutputFcn, ...
'gui_LayoutFcn', [], ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
end
% --- Executes just before pspm_display is made visible.
function pspm_display_OpeningFcn(hObject, ~, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin unrecognized PropertyName/PropertyValue pairs from the
% command line (see VARARGIN)
% ---initialise------------------------------------------------------------
global settings;
if isempty(settings)
pspm_init;
end
% load channeltypes from settings variable
j = 1 ; l = 1;
for k = 1:length(settings.channeltypes)
if strcmp(settings.channeltypes(k).data,'wave')
handles.prop.setwave{j} = settings.channeltypes(k).type;
j = j+1;
elseif strcmp(settings.channeltypes(k).data,'events')
handles.prop.setevent{l} = settings.channeltypes(k).type;
l = l+1;
end
end
% -------------------------------------------------------------------------
pspm_ui(hObject, handles, 'display');
if(numel(varargin)) == 1
if iscell(varargin{1,1})
filename = varargin{1,1}{1};
else
filename = varargin{1,1};
end
[~, handles.info, handles.data, ~] = pspm_load_data(filename,0);
handles.name = filename;
[~,filename_display,~] = fileparts(filename);
handles.tag_summary_source_file_content.String = filename_display;
update_summary_list(handles);
% handles.text_file_summary = filename;
% text_file_summary = ['Data source: ', filename, newline, newline, ...
% 'Duration: ', num2str(info.duration), newline,...
% 'Import date: ', info.importdate, newline, ...
% 'Position of marker: ', num2str(filestruct.posofmarker)];
% set(handles.text_file_summary, 'String', text_file_summary);
guidata(hObject, handles);
% ---add text to wave listbox--------------------------------------
listitems{1,1} = 'none';
handles.prop.wavechans(1) = 0;
j = 2;
for k = 1:length(handles.data)
if any(strcmp(handles.data{k,1}.header.chantype,handles.prop.setwave))
listitems{j,1} = handles.data{k,1}.header.chantype;
handles.prop.wavechans(j) = k;
j = j+1;
end
end
set(handles.list_wave_channel,'String',listitems);
clear listitems
% ---add text to event listbox & activate additional options-------
listitems{1,1} = 'none';
handles.prop.eventchans(1) = 0;
j = 2;
for k = 1:length(handles.data)
if any(strcmp(handles.data{k,1}.header.chantype,handles.prop.setevent))
listitems{j,1} = handles.data{k,1}.header.chantype;
handles.prop.eventchans(j) = k;
j = j+1;
set(handles.option_integrated,'Enable','on');
set(handles.option_extra,'Enable','on');
end
end
set(handles.list_event_channel,'String',listitems);
set(handles.button_autoscale,'Value',0);
set(handles.button_all,'Value',1);
elseif numel(varargin)>1
warning('Too many input arguments. Inputs 2:end ignored. ');
end
% Choose default command line output for pspm_display
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes pspm_display wait for user response (see UIRESUME)
% uiwait(handles.figure1);
end
% --- Outputs from this function are returned to the command line.
function varargout = pspm_display_OutputFcn(~, ~, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
end
% --- Executes on button press in push_next.
function push_next_Callback(~, ~, handles)
% hObject handle to push_next (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x1 = str2double(get(handles.edit_start_x,'String'));
x2 = str2double(get(handles.edit_winsize_x,'String'));
y = get(handles.display_plot,'YLim');
x1 = x1+x2; x2 = x1+x2;
axis([x1 x2 y(1) y(2)])
set(handles.edit_start_x,'String',num2str(x1));
set(handles.edit_y_min,'String',num2str(y(1)));
set(handles.edit_y_max,'String',num2str(y(2)));
set(handles.button_all,'Value',0);
end
% --- Executes on button press in push_back.
function push_back_Callback(~, ~, handles)
% hObject handle to push_back (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x1 = str2double(get(handles.edit_start_x,'String'));
x2 = str2double(get(handles.edit_winsize_x,'String'));
x1 = x1-x2;
x2 = x1+x2;
set(handles.edit_start_x,'String',num2str(x1));
y = get(handles.display_plot,'YLim');
axis([x1 x2 y(1) y(2)])
set(handles.edit_start_x,'String',num2str(x1));
set(handles.edit_y_min,'String',num2str(y(1)));
set(handles.edit_y_max,'String',num2str(y(2)));
set(handles.button_all,'Value',0);
end
% --- Executes on button press in option_extra.
function option_extra_Callback(hObject, ~, handles)
% hObject handle to option_extra (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of option_extra
status = get(handles.option_extra,'Value');
if status == 1
set(handles.option_integrated,'Value',0)
elseif status == 0
set(handles.option_integrated,'Value',1)
end
% -------------------------------------------------------------------------
% Update handles structure
guidata(hObject, handles);
% -------------------------------------------------------------------------
end
% --- Executes on button press in radio_hb.
function radio_hb_Callback(~, ~, ~)
% hObject handle to radio_hb (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radio_hb
end
% --- Executes on button press in radio_integrated.
function radio_integrated_Callback(~, ~, ~)
% hObject handle to radio_integrated (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radio_integrated
end
function edit_winsize_x_Callback(~, ~, handles)
% hObject handle to edit_winsize_x (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_winsize_x as text
% str2double(get(hObject,'String')) returns contents of edit_winsize_x as a double
x1 = str2double(get(handles.edit_start_x,'String'));
x2 = str2double(get(handles.edit_winsize_x,'String'))+x1;
y1 = str2double(get(handles.edit_y_min,'String'));
y2 = str2double(get(handles.edit_y_max,'String'));
if y1 >= y2
warning([' Ymin ( current input: %d ) must be smaller than',...
' Ymax ( current input: %d ) ! '],y1,y2);
else
axis([x1 x2 y1 y2])
end
set(handles.button_autoscale,'Value',0);
set(handles.button_all,'Value',0);
end
% --- Executes during object creation, after setting all properties.
function edit_winsize_x_CreateFcn(hObject, ~, ~)
% hObject handle to edit_winsize_x (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && ...
isequal(get(hObject,'BackgroundColor'), ...
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
end
function edit_y_min_Callback(~, ~, handles)
% hObject handle to edit_y_min (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_y_min as text
% str2double(get(hObject,'String')) returns contents of edit_y_min as a double
x1 = str2double(get(handles.edit_start_x,'String'));
x2 = str2double(get(handles.edit_winsize_x,'String'))+x1;
y1 = str2double(get(handles.edit_y_min,'String'));
y2 = str2double(get(handles.edit_y_max,'String'));
if y1 >= y2
warning([' Ymin ( current input: %d ) must be smaller than ',...
'Ymax ( current input: %d ) ! '],y1,y2);
else
axis([x1 x2 y1 y2])
end
set(handles.button_autoscale,'Value',0);
set(handles.button_all,'Value',0);
end
% --- Executes during object creation, after setting all properties.
function edit_y_min_CreateFcn(hObject, ~, ~)
% hObject handle to edit_y_min (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), ...
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
end
function edit_start_x_Callback(~, ~, handles)
% hObject handle to edit_start_x (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_start_x as text
% str2double(get(hObject,'String')) returns contents of edit_start_x
% as a double
x1 = str2double(get(handles.edit_start_x,'String'));
x2 = str2double(get(handles.edit_winsize_x,'String'))+x1;
y1 = str2double(get(handles.edit_y_min,'String'));
y2 = str2double(get(handles.edit_y_max,'String'));
if y1 >= y2
warning([' Ymin ( current input: %d ) must be smaller than ',...
'Ymax ( current input: %d ) ! '],y1,y2);
else
axis([x1 x2 y1 y2])
end
set(handles.button_autoscale,'Value',0);
set(handles.button_all,'Value',0);
end
% --- Executes during object creation, after setting all properties.
function edit_start_x_CreateFcn(hObject, ~, ~)
% hObject handle to edit_start_x (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && ...
isequal(get(hObject,'BackgroundColor'), ...
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
end
% --- Executes on button press in button_autoscale.
function button_autoscale_Callback(~, ~, handles)
% hObject handle to button_autoscale (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axis('auto')
y = get(handles.display_plot,'ylim');
x = str2double(get(handles.edit_start_x,'String'));
x(2) = x(1) + 15;
axis([x(1) x(2) y(1) y(2)])
set(handles.edit_start_x,'String',num2str(x(1)));
set(handles.edit_winsize_x,'String',num2str(x(2)-x(1)));
set(handles.edit_y_min,'String',num2str(y(1)));
set(handles.edit_y_max,'String',num2str(y(2)));
set(handles.button_all,'Value',0);
end
% --- Executes on button press in button_all.
function button_all_Callback(~, ~, handles)
% hObject handle to button_all (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axis('auto');
y = get(handles.display_plot,'ylim');
x = get(handles.display_plot,'xlim');
set(handles.edit_start_x,'String',num2str(x(1)));
set(handles.edit_winsize_x,'String',num2str(x(2)-x(1)));
set(handles.edit_y_min,'String',num2str(y(1)));
set(handles.edit_y_max,'String',num2str(y(2)));
set(handles.button_autoscale,'Value',0);
end
% --------------------------------------------------------------------
function file_Callback(~, ~, ~)
% hObject handle to file (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
end
% --------------------------------------------------------------------
function load_Callback(hObject, ~, handles)
% hObject handle to load (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------------
wd = cd;
typ = 'mat';
sel = [];
mesg = 'select pspm_datafiles to display';
[filename,sts] = spm_select(1,typ,mesg,sel,wd);
if not(sts == 0)
handles.name = filename;
[~, handles.info, handles.data, ~] = pspm_load_data(filename,0);
handles.name = filename;
[~,filename_display,~] = fileparts(filename);
handles.tag_summary_source_file_content.String = filename_display;
update_summary_list(handles);
guidata(hObject, handles);
% ---set wave and event channel value to none ---------------------
handles.prop.wave = 'none';
set(handles.list_wave_channel,'Value',1)
handles.prop.event = 'none';
set(handles.list_event_channel,'Value',1)
% ---add text to wave listbox--------------------------------------
listitems{1,1} = 'none';
handles.prop.wavechans(1) = 0;
j = 2;
for k = 1:length(handles.data)
if any(strcmp(handles.data{k,1}.header.chantype,handles.prop.setwave))
listitems{j,1} = handles.data{k,1}.header.chantype;
handles.prop.wavechans(j) = k;
j = j+1;
end
end
set(handles.list_wave_channel,'String',listitems);
clear listitems
% ---add text to event listbox & activate additional options-------
listitems{1,1} = 'none';
handles.prop.eventchans(1) = 0;
j = 2;
for k = 1:length(handles.data)
if any(strcmp(handles.data{k,1}.header.chantype,handles.prop.setevent))
listitems{j,1} = handles.data{k,1}.header.chantype;
handles.prop.eventchans(j) = k;
j = j+1;
set(handles.option_integrated,'Enable','on');
set(handles.option_extra,'Enable','on');
end
end
set(handles.list_event_channel,'String',listitems);
set(handles.button_autoscale,'Value',0);
set(handles.button_all,'Value',1);
elseif numel(varargin)>1
warning('Too many input arguments. Inputs 2:end ignored. ');
end
% Update handles structure
guidata(hObject, handles);
end
% --------------------------------------------------------------------
function saveas_Callback(~, ~, handles)
% hObject handle to saveas (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
y = get(handles.display_plot,'ylim');
x = get(handles.display_plot,'xlim');
[filename,pathname] = uiputfile(...
{'*.jpg';'*.tif';'*.png';'*.gif';'*.bmp'},'Save Image');
screen_size = get(0, 'ScreenSize');
savename = sprintf('%s%s',pathname,filename);
q = figure('Visible','Off');
set(q, 'Position', [0 0 screen_size(3) screen_size(4) ] );
pp_plot(handles);
axis([x(1) x(2) y(1) y(2)]);
% save the image as PNG
saveas(q,savename);
%imwrite(q,savename);
close(q)
end
% --------------------------------------------------------------------
function exit_Callback(~, ~, ~)
% hObject handle to exit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close(gcbf);
end
% --- Executes during object creation, after setting all properties.
function display_plot_CreateFcn(~, ~, ~)
% hObject handle to display_plot (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: place code in OpeningFcn to populate display_plot
end
% --- Executes during object creation, after setting all properties.
function panel_wave_CreateFcn(~, ~, ~)
% hObject handle to panel_wave (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
end
% --- Executes when selected object is changed in panel_wave.
function panel_wave_SelectionChangeFcn(hObject, ~, handles)
% hObject handle to the selected object in panel_wave
% eventdata structure with the following fields (see UIBUTTONGROUP)
% EventName: string 'SelectionChanged' (read only)
% OldValue: handle of the previously selected object or empty if none was
% selected
% NewValue: handle of the currently selected object
% handles structure with handles and user data (see GUIDATA)
status0 = get(handles.radio_wnone,'Value');
status1 = get(handles.radio_scr,'Value');
status2 = get(handles.radio_ecg,'Value');
status3 = get(handles.radio_hr,'Value');
status4 = get(handles.radio_hp,'Value');
status5 = get(handles.radio_pupil,'Value');
status6 = get(handles.radio_emg,'Value');
status7 = get(handles.radio_resp,'Value');
set(handles.button_autoscale,'Enable','on');
set(handles.button_all,'Enable','on');
if status0 == 1
handles.prop.wave = 'none';
set(handles.radio_hb,'Enable','on');
set(handles.button_autoscale,'Enable','off');
set(handles.button_all,'Enable','off')
set(handles.radio_integrated,'Enable','off')
elseif status1 == 1
handles.prop.wave='scr';
elseif status2 == 1
handles.prop.wave='ecg';
elseif status3 == 1
handles.prop.wave='hr';
elseif status4 == 1
handles.prop.wave='hp';
elseif status5 == 1
handles.prop.wave='pupil';
elseif status6 == 1
handles.prop.wave='emg';
elseif status7 == 1
handles.prop.resp='resp';
end
if ~(strcmp(handles.prop.wave,'ecg')) && strcmp(handles.prop.event,'hb')
handles.prop.event='extra';
set(handles.option_extra,'Value',1)
end
if status0 == 0
set(handles.radio_integrated,'Enable','on') ;
end
guidata(hObject, handles);
pp_plot(handles);
set(handles.button_autoscale,'Value',0);
set(handles.button_all,'Value',1);
end
% --- Executes when selected object is changed in panel_event.
function panel_event_SelectionChangeFcn(hObject, ~, handles)
% hObject handle to the selected object in panel_event
% eventdata structure with the following fields (see UIBUTTONGROUP)
% EventName: string 'SelectionChanged' (read only)
% OldValue: handle of the previously selected object or empty if none was
% selected
% NewValue: handle of the currently selected object
% handles structure with handles and user data (see GUIDATA)
status0 = get(handles.radio_enone,'Value');
status1 = get(handles.option_extra,'Value');
status2 = get(handles.radio_integrated,'Value');
status3 = get(handles.radio_hb,'Value');
if status0 == 1
handles.prop.event='none';
elseif status1 == 1
handles.prop.event='extra';
elseif status2 == 1
handles.prop.event='integrated';
elseif status3 == 1
handles.prop.event='hb';
end
guidata(hObject, handles);
pp_plot(handles);
set(handles.button_autoscale,'Value',0);
set(handles.button_all,'Value',1);
end
% --- Executes on button press in radio_wnone.
function radio_wnone_Callback(~, ~, ~)
% hObject handle to radio_wnone (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radio_wnone
end
function edit_y_max_Callback(~, ~, handles)
% hObject handle to edit_y_max (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_y_max as text
% str2double(get(hObject,'String')) returns contents of edit_y_max
% as a double
x1 = str2double(get(handles.edit_start_x,'String'));
x2 = str2double(get(handles.edit_winsize_x,'String'))+x1;
y1 = str2double(get(handles.edit_y_min,'String'));
y2 = str2double(get(handles.edit_y_max,'String'));
if y1 >= y2
warning([' Ymin ( current input: %d ) must be smaller than Ymax ',...
'( current input: %d ) ! '],y1,y2);
else
axis([x1 x2 y1 y2])
end
set(handles.button_autoscale,'Value',0);
set(handles.button_all,'Value',0);
end
% --- Executes during object creation, after setting all properties.
function edit_y_max_CreateFcn(hObject, ~, ~)
% hObject handle to edit_y_max (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), ...
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
end
%% pp_plot
function pp_plot(handles)
global settings;
if isempty(settings)
pspm_init;
end
% ---header----------------------------------------------------------------
% handles.name ... filename
% prop... struct with fields
% .wave (channel number)
% .event(channel number)
%
% Initialise
marker = [];
hbeat = [];
events = []; % any other marker channels
wave = [];
% Obtain data
% Get eventchan info
if not(isempty(handles.prop.eventchans)) && ...
not(handles.prop.eventchans(handles.prop.idevent)==0) && ...
strcmp(handles.data{...
handles.prop.eventchans(handles.prop.idevent),1}.header.chantype,...
'marker')
marker = handles.data{handles.prop.eventchans(handles.prop.idevent),1}.data;
if get(handles.option_extra,'Value') == 1
handles.prop.event = 'extra';
else
handles.prop.event = 'integrated';
end
elseif not(isempty(handles.prop.eventchans)) && ...
not(handles.prop.eventchans(handles.prop.idevent)==0) && ...
strcmp(...
handles.data{...
handles.prop.eventchans(handles.prop.idevent),1}.header.chantype,'hb')
hbeat = handles.data{handles.prop.eventchans(handles.prop.idevent),1}.data;
if get(handles.option_extra,'Value') == 1
handles.prop.event = 'extra';
else
handles.prop.event = 'integrated';
end
elseif not(isempty(handles.prop.eventchans)) && ...
not(handles.prop.eventchans(handles.prop.idevent)==0)
events = handles.data{handles.prop.eventchans(handles.prop.idevent),1}.data;
if get(handles.option_extra,'Value')==1
handles.prop.event = 'extra';
else
handles.prop.event = 'integrated';
end
end
% Get wave channel info
if handles.prop.wavechans(handles.prop.idwave) ~= 0
wave = handles.data{handles.prop.wavechans(handles.prop.idwave),1}.data;
sr.wave = handles.data{handles.prop.wavechans(handles.prop.idwave),1}.header.sr;
end
time_length = handles.tag_summary_recording_duration_content.Value;
% Do not plot if no wave channel is selected
if isempty(wave)
if not(isempty(hbeat))
x_axis = 0:time_length/(length(hbeat)-2):time_length;
plot(x_axis,diff(hbeat),'ro');
xlabel('Time [s] ','Fontsize',settings.ui.FontSizeText);
ylabel('Duration of ibi [s]','Fontsize',settings.ui.FontSizeText);
legend('heartbeats','Fontsize',settings.ui.FontSizeText);
elseif not(isempty(marker))
x_axis = 0:time_length/(length(marker)-2):time_length;
stem(x_axis,diff(marker),'r');
legend('marker','Fontsize',settings.ui.FontSizeText);
xlabel('Time [s] ','Fontsize',settings.ui.FontSizeText);
ylabel('Inter-marker duration [s]','Fontsize',settings.ui.FontSizeText)
elseif not(isempty(events))
x_axis = 0:time_length/(length(events)-2):time_length;
plot(x_axis,diff(events),'ro')
xlabel('Time [s] ','Fontsize',settings.ui.FontSizeText);
ylabel('Inter-event duration [s]','Fontsize',settings.ui.FontSizeText)
legend([handles.list_event_channel.String{handles.prop.idevent},' events'],...
'Fontsize',settings.ui.FontSizeText)
else
f = msgbox(['Nothing to display. ',...
'Please select at least one channel.'], 'Error');
end
else
y = (0:1/sr.wave:(length(wave)/sr.wave));
y = y';
y = y(1:size(wave,1),1:size(wave,2));
y = y(1:size(wave,1),1);
plot(y, wave, 'Color', 'k'); % plot wave channel
legend(handles.prop.wave);
% set basline value for the event chanel
base(1) = min(wave)-.1*min(wave);
base(2) = min(wave)-(max(wave)-min(wave));
% Plot heart beats
if ~isempty(hbeat)
hbeat = round(hbeat*sr.wave);
HBEAT = nan(size(wave));
if strcmp(handles.prop.event,'extra')
HBEAT(hbeat,1) = min(wave)-.5;
elseif strcmp(handles.prop.event,'integrated')
temp = wave(hbeat,1);
temp(isnan(temp)) = median(temp,'omitnan');
HBEAT(hbeat,1) = temp;
end
hold on
h = stem(y,HBEAT,'ro');
legend(handles.prop.wave,'heartbeats');
hbase = get(h,'Baseline');
if strcmp(handles.prop.event,'extra')
set(hbase,'BaseValue',base(2),'Visible','off');
elseif strcmp(handles.prop.event,'integrated')
set(hbase,'BaseValue',base(1),'Visible','off');
end
hold off
end
% Plot marker
if ~isempty(marker)
marker = round(marker*sr.wave);
if marker(1,1)==0
marker(1,1) = 1;
end
marker = marker(marker~=0);
MARKER = nan(size(wave));
if strcmp(handles.prop.event,'extra')
MARKER(marker,1) = min(wave)-.5;
elseif strcmp(handles.prop.event,'integrated')
temp = wave(marker,1);
temp(isnan(temp)) = median(temp,'omitnan');
MARKER(marker,1) = temp;
end
hold on
h = stem(y,MARKER,'ro');
legend(handles.prop.wave,'marker');
hbase = get(h,'Baseline');
if strcmp(handles.prop.event,'extra')
set(hbase,'BaseValue',base(2),'Visible','off');
elseif strcmp(handles.prop.event,'integrated')
set(hbase,'BaseValue',base(1),'Visible','off');
end
hold off
end
% Plot events
if ~isempty(events)
events = round(events*sr.wave);
EVENTS = nan(size(wave));
if strcmp(handles.prop.event,'extra')
EVENTS(events,1) = min(wave)-.5;
elseif strcmp(handles.prop.event,'integrated')
temp = wave(events,1);
temp(isnan(temp)) = median(temp,'omitnan');
EVENTS(events,1) = temp;
end
hold on ; h = stem(y,EVENTS,'r');
hbase = get(h,'Baseline');
legend(handles.prop.wave,...
[handles.list_event_channel.String{handles.prop.idevent},...
' events'])
if strcmp(handles.prop.event,'extra')
set(hbase,'BaseValue',base(2),'Visible','off');
elseif strcmp(handles.prop.event,'integrated')
set(hbase,'BaseValue',base(1),'Visible','off');
end
hold off
end
% Add labels
xlabel('Time [s]','Fontsize',settings.ui.FontSizeText);
wv_chanid = handles.prop.wavechans(handles.prop.idwave);
unit = deblank(handles.data{wv_chanid}.header.units);
Ylab = ['Unknown unit [',unit,']']; % default value
switch handles.prop.wave
case 'ecg'
Ylab = ['Amplitude [',unit,']'];
case 'scr'
Ylab = ['Amplitude [',unit,']'];
case 'emg'
Ylab = ['Amplitude [',unit,']'];
case 'hp'
Ylab = 'Interpolated IBI [ms]';
case {'pupil','pupil_l','pupil_r',...
'pupil_pp','pupil_pp_l','pupil_pp_r'}
Ylab = ['Pupil size [',unit,']'];
case {'gaze_x','gaze_x_l','gaze_x_r',...
'gaze_x_pp','gaze_x_pp_l','gaze_x_pp_r'}
Ylab = ['Gaze x coordinate [',unit,']'];
case {'gaze_y','gaze_y_l','gaze_y_r',...
'gaze_y_pp','gaze_y_pp_l','gaze_y_pp_r'}
Ylab = ['Gaze y coordinate [',unit,']'];
end
ylabel(Ylab,'Fontsize',settings.ui.FontSizeText);
end
hold on
set(handles.display_plot,'XGrid','on')
hold off
x = get(handles.display_plot,'xlim');
if handles.tag_summary_recording_duration_content.Value>0
set(handles.display_plot,'xlim',...
[0,handles.tag_summary_recording_duration_content.Value]);
end
y = get(handles.display_plot,'ylim');
x(2) = x(2)-x(1);
set(handles.edit_y_min,'String',num2str(y(1)))
set(handles.edit_y_max,'String',num2str(y(2)))
set(handles.edit_start_x,'String',num2str(x(1)))
set(handles.edit_winsize_x,'String',num2str(x(2)))
end
% --- Executes when pspm_display is resized.
function pspm_display_ResizeFcn(~, ~, ~)
% hObject handle to pspm_display (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
end
% --- Executes during object creation, after setting all properties.
function module_display_options_CreateFcn(~, ~, ~)
% hObject handle to module_display_options (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
end
% --- Executes during object creation, after setting all properties.
function panel_event_CreateFcn(~, ~, ~)
% hObject handle to panel_event (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
end
% --- Executes on selection change in list_wave.
function list_wave_Callback(~, ~, ~)
% hObject handle to list_wave (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns list_wave
% contents as cell array
% contents{get(hObject,'Value')} returns selected item from list_wave
end
% --- Executes during object creation, after setting all properties.
function list_wave_CreateFcn(hObject, ~, ~)
% hObject handle to list_wave (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), ...
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
end
% --- Executes on selection change in list_wave_channel.
function list_wave_channel_Callback(~, ~, ~)
% hObject handle to list_wave_channel (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns
% list_wave_channel contents as cell array
% contents{get(hObject,'Value')} returns selected item from
% list_wave_channel
end
% --- Executes during object creation, after setting all properties.
function list_wave_channel_CreateFcn(hObject, ~, ~)
% hObject handle to list_wave_channel (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), ...
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
end
% --- Executes on selection change in list_event_channel.
function list_event_channel_Callback(~, ~, ~)
% hObject handle to list_event_channel (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns
% list_event_channel contents as cell array
% contents{get(hObject,'Value')} returns selected item from
% list_event_channel
end
% --- Executes during object creation, after setting all properties.
function list_event_channel_CreateFcn(hObject, ~, ~)
% hObject handle to list_event_channel (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), ...
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
end
% --- Executes on button press in button_plot.
function button_plot_Callback(hObject, ~, handles)
% hObject handle to button_plot (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get selected wave channel
if ~isfield(handles,'info')