-
Notifications
You must be signed in to change notification settings - Fork 0
/
OpSignalsummary.m
903 lines (671 loc) · 37.3 KB
/
OpSignalsummary.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
function varargout = OpSignal(varargin)
% OPSIGNAL MATLAB code for OpSignal.fig
% OPSIGNAL, by itself, creates a new OPSIGNAL or raises the existing
% singleton*.
%
% H = OPSIGNAL returns the handle to a new OPSIGNAL or the handle to
% the existing singleton*.
%
% OPSIGNAL('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in OPSIGNAL.M with the given input arguments.
%
% OPSIGNAL('Property','Value',...) creates a new OPSIGNAL or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before OpSignal_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to OpSignal_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help OpSignal
% Last Modified by GUIDE v2.5 26-May-2016 09:50:10
% Begin initialization code - DO NOT EDIT
%%%%%changed by zzg 161223
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @OpSignal_OpeningFcn, ...
'gui_OutputFcn', @OpSignal_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
% --- Executes just before OpSignal is made visible.
function OpSignal_OpeningFcn(hObject, eventdata, 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 command line arguments to OpSignal (see VARARGIN)
% Choose default command line output for OpSignal
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes OpSignal wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = OpSignal_OutputFcn(hObject, eventdata, 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;
% --- Executes on button press in pushbuttonLoad.
function pushbuttonLoad_Callback(hObject, eventdata, handles)
% hObject handle to pushbuttonLoad (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename, pathname] = uigetfile('*.CSV', 'Open CSV file'); %%%Open CSV file
handles.file_path_and_name = fullfile(pathname, filename); %%%%% changed by zzg 161223 可以学习其handles,直接把Excel的数据得到了。
if filename == 0
return;
end
set(handles.edit_file, 'String', handles.file_path_and_name);
data = csvread(handles.file_path_and_name); %%% read CSV file
handles.channelnum=size(data,2); %通道数目columns If X = rand(2,3,4) then m2 = size(X,2)(rows and columns) returns m2 = 3
handles.length = size(data,1); %通道的长度size(X,1) returns the number of rows.
set(handles.pm_cue,'String',num2str((1:1:handles.channelnum-1)')); %%% 让cue的个数很多
set(handles.pm_cue,'Value',1); %%% 让cue的初始值为1 Set object properties.
for i=1:handles.channelnum-1
eval(['handles.data',num2str(i),'=','data(:,i)',';']); %%% eval怎么使用?Execute string with MATLAB expression.
end
%%%%%% changed by zzg 161223
%在开始计算之前取zcore值
for i=handles.channelnum-7:handles.channelnum-1
average=mean(data(:,i));
stdev =std(data(:,i));
data(:,i) = (data(:,i)-average)/stdev ;
data(:,handles.channelnum-8)=(data(:,handles.channelnum-8)+data(:,i))/2;
end
% (计算EMG,delta/theta)
data(:,handles.channelnum)=abs(data(:,handles.channelnum));%
%%%利用handles.wave画前面的图.
handles.wave = data(:,handles.channelnum-8);
%新建一个矩阵,为了引出另一个数据EMG
handles.DATA1=data(:,handles.channelnum);
cell=[];
for i=1:handles.length-1 %由于是减一,需要注意数据的个数。
if handles.data1(i)==0 && handles.data1(i+1)==1 %% handles.data1是什么含义?是第一列吗?而且必须data=1,相邻的数为0?这个函数可以只标记第一个刺激的点,也可以试一下cell>0
cell(i+1) =1;
else
cell(i+1) =0;
end
end
handles.upindex=find(cell==1); %%%一定是cell==1才行,否则不返回,也可以试一下cell>0
trialnum = size(handles.upindex); %%%总共刺激的次数,trialnum size returns the two-element row vector
handles.trialnum = trialnum(2); %%%利用trialnum做???
set(handles.edit_sti1, 'String', num2str(handles.trialnum));
guidata(hObject, handles);
function edit_file_Callback(hObject, eventdata, handles)
% hObject handle to edit_file (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_file as text
% str2double(get(hObject,'String')) returns contents of edit_file as a double
% --- Executes during object creation, after setting all properties.
function edit_file_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_file (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
% --- Executes on button press in pushbuttonDrawAll. %%%利用DrawAll做所有图形的线???
function pushbuttonDrawAll_Callback(hObject, eventdata, handles)
% hObject handle to pushbuttonDrawAll (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% handles.f=figure;
% handles.bin = str2num(get(handles.edit_bin,'String')); %%%%handles.edit_bin=0.01
% handles.scrobin=handles.bin/handles.length;
% handles.scrolength=handles.length-handles.bin;
%
% a=axes('position',[.1 .9 .8 .05],'units','normalized');
% x=1:1:handles.length; %%%利用x坐标
% ylim([0,1]);
% set(gca,'xtick',[],'ytick',[])
% %axis([1 handles.length 0 1]); % %%%利用x坐标长度
% stairs(x,handles.data1); % stairs画一条一条cue? xlim?
% xlim([0,handles.bin]);
% b=axes('position',[.1 .2 .8 0.6],'units','normalized');
% plot(x,handles.wave); % %%%利用x坐标长度画图
% xlim([0,handles.bin]);
%
% uicontrol('units','normalized','Style','slider','pos',[.1 .1 .8 .05],'SliderStep',[handles.scrobin handles.scrobin],...
% 'min',0,'max',handles.scrolength,'callback',{@slider_callback,a,b});
% uicontrol('units','normalized','Style','pushbutton','pos',[.1 .03 .15 .05],'min',0,'max',10,'String', 'Zoomin',...
% 'Callback',{@zoomin_callback,a,b});
% uicontrol('units','normalized','Style','pushbutton','pos',[.3 .03 .15 .05],'min',0,'max',10,'String', 'Zoomout',...
% 'Callback',{@zoomout_callback,a,b});
% guidata(hObject, handles); %??????
interval = 1/str2num(get(handles.TB_SampleRate,'String')); %TB_SampleRate1,interval=1??????
t=interval*(1:1:handles.length); %t=2061s!!!
figure;
for i=1:handles.channelnum-1 %handles.channelnum=12?
subplot(handles.channelnum+2,1,i); %就是让一直画图表示画N列的意思 %subplot 13列,依次按i来画图
eval(['plot(t,handles.data',num2str(i),');']); % num2str eval(EXPRESSION) evaluates the MATLAB code in the string EXPRESSION.
% H = subplot(m,n,p), or subplot(mnp), breaks the Figure window into an m-by-n matrix of small axes, selects the p-th axes for the current plot, and returns the axes handle. The axes are counted along the top row of the Figure window, then the second
end
subplot(handles.channelnum+2,1,handles.channelnum:handles.channelnum+2); %subplot 13列,依次按11-13列来画图???/???
plot(t,handles.wave);
xlabel('Time (s)');
function edit_bin_Callback(hObject, eventdata, handles)
% hObject handle to edit_bin (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_bin as text
% str2double(get(hObject,'String')) returns contents of edit_bin as a double
% --- Executes during object creation, after setting all properties.
function edit_bin_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_bin (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
% --- Executes on button press in pushbuttonAverage.
function pushbuttonAverage_Callback(hObject, eventdata, handles) %%%这是这个函数的关键函数,注意其中handles的值已经给过了
% hObject handle to pushbuttonAverage (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
warning('off');
upindex=handles.upindex; %每个eventdata值的位置
trialnum=handles.trialnum; %=8
length=handles.length;
trial_from = str2num(get(handles.edit_trial_from,'String')); %=1
sti1_number = str2num(get(handles.edit_sti1,'String')); %=??
basal_time = str2double(get(handles.edit_pre_sti_time,'String')); %=2
odor_time = str2double(get(handles.edit_post_sti_time,'String')); %=10
control_time = str2num(get(handles.edit_control_time,'String')); %=-20 %三个重要的时间设定,一定要注意格式。 都变成了string.
offset = str2double(get(handles.edit_offset,'String')); %注意这两个怎么使用的?
clims = str2num(get(handles.edit_clims,'String'));
z_score = get(handles.radiobutton_z_score,'Value'); %注意这两个怎么使用的,只是返回有或无?
heatmap = get(handles.checkbox_heatmap,'Value');
bin = str2double(get(handles.edit_bin,'String')); % % bin=1s?
interval = 1/str2num(get(handles.TB_SampleRate,'String')); % interval=1s
if bin<interval % interval=bin
bin=interval;
set(handles.edit_bin,'String',num2str(interval)); %为何一定要设成相同的值,而且bin一定要大于等于interval。
end
trialnumtemp = trialnum;
for i=1:trialnum %=8
if upindex(i) < basal_time %减去了*100 %*100 CHANGED BY ZZG
upindex(i)=0; %相当于一个索引个数的指数,把event出现前的数目变成0,只是为了防止做psth时-2前面值不存在,或者为负值。
trialnumtemp = trialnumtemp-1;
end
end
upindex(upindex==0)=[]; %???归零吗?
trialnum=trialnumtemp; %???归零吗?
for i =1:trialnum
if upindex(i)+odor_time>length %减去了*100 ( CHANGED BY ZZG)
upindex(i)=0; %相当于一个索引个数的指数,把event出现前的数目变成0,只是为了防止做psth时+10前面值不存在,或者为负值。
trialnumtemp = trialnumtemp-1;
end
end
trialnum=trialnumtemp;
upindex(upindex==0)=[];
set(handles.edit_sti1, 'String', num2str(trialnum)); %表示停留在的event个数?
values = handles.wave;
%???直接将上面handles.wave的值赋予,最重要的values开始使用 在这个步骤可以让values得到多个值,或者让这个函数循环多次。
num = floor(bin/interval); %???=1??四舍五入,假如bin/interval=2.3,则直接为2.
M = mod(size(values,1),num); % mod(x,y), for x~=y and y~=0, has the same sign as y.余数
values = [values;zeros(num-M,1)]; % %????
values = mean(reshape(values',num,[]),1)'; %????,取这个值的平均值
interval = bin; %???interval = 1,这几部的作用就是有2值时,但是画图时只能画一个值,所以必须用一个值,需要取平均值。
figure;subplot(2,1,1);
trigger1_times = trigger_times_pretreatment(upindex,trial_from,sti1_number,handles.edit_sti1); %得到trigger1_times,需要输入upindex,trial_from,sti1_number,handles.edit_sti1四个值, %%%这一步所有变换时间,尤其是event的值要乘以1(upindex不用了)
[psth1,psth1_mean,psth1_sem] = psth_wave2(trigger1_times,interval,values,basal_time,odor_time,control_time(1),control_time(2),offset,z_score); %psth作图方法 %得到psth,需要输入trigger1_times,interval(0.01),values(频率),basal_time(2),odor_time(10),control_time(-2),control_time(0),offset,z_score十个值
% read ori_csv file
folder_name = 'D:\zzg processing data\MUA\OpSignal-MATLAB-20160712\samplerate=1\'; %%
input_csv = 'psth_DATAunit.csv'; %%
psth_DATAunit=csvread([folder_name, input_csv]);
% input setup
%最主要要把psth1_mean,psth1_sem得到,然后把得到的值利用后面的drawErrorLine画出。能否自己定义一个函数 psthdata
the_title = get(handles.edit_file,'String'); %标题
basal_time=psth_DATAunit(1,2);
interval=psth_DATAunit(1,2);
odor_time=interval=psth_DATAunit(1,3);
times = -basal_time:interval:odor_time-interval; %时间是从-2到9???,但是间隔是1
psth1=psth_DATAunit;psth1(3,:)=[];
psth1_mean=mean(psth1);
psth1_sem=std(psth1)/(size(psth1,2)-1)^0.5; %size(psth1,2)表示返回的列数
drawErrorLine(times,psth1_mean,psth1_sem,'purple',0.5); %误差线作图方法,输入时间,平均值,SEM,zise标注, %%%%%%%%这个才是画图的最主要工具 %
hold on;
%title(the_title); %不需要这个名字,换成
%xlabel('Time (s)');
if z_score==1
ylabel('z-score'); %更换标题 z-score
else
ylabel('Firing possbility'); %更换标题
end
PSTH1=psth1;%用于画heatmap
subplot(2,1,2);%figure; %原先有figure,之后删除
% read ori_csv file
folder_name = 'D:\zzg processing data\MUA\OpSignal-MATLAB-20160712\samplerate=1\'; %%
input_csv = 'psth_DATAemg.csv'; %%
psth_DATAunit=csvread([folder_name, input_csv]);
% input setup
%最主要要把psth1_mean,psth1_sem得到,然后把得到的值利用后面的drawErrorLine画出。能否自己定义一个函数 psthdata
the_title = get(handles.edit_file,'String'); %标题
basal_time=psth_DATAunit(1,2);
interval=psth_DATAunit(1,2);
odor_time=interval=psth_DATAunit(1,3);
times = -basal_time:interval:odor_time-interval; %时间是从-2到9???,但是间隔是1
psth1=psth_DATAunit;psth1(3,:)=[];
psth1_mean=mean(psth1);
psth1_sem=std(psth1)/(size(psth1,2)-1)^0.5; %size(psth1,2)表示返回的列数
drawErrorLine(times,psth1_mean,psth1_sem,'cyan',0.5); %误差线作图方法,输入时间,平均值,SEM,青色标注, %%%%%%%%这个才是画图的最主要工具 %
hold on;
%title(the_title); %不需要这个名字,换成
%xlabel('Time (s)');
if z_score==1
ylabel('z-score'); %更换标题 z-score
else
ylabel('EMG'); %更换标题
end
PSTH2=psth1;%用于画heatmap
psth1=PSTH1;
if heatmap
fig1 = figure;
subplot(2,1,1);hold on;
thres = 10; %更换 thres = 10;
heatmapPlot(psth1,interval,basal_time,21:120,1,1:size(psth1,1),0.1,fig1,); %heatmapPlot作图方法 需要输入psth1(图的值),interval(0.01),basal_time(-2),21:120(???),1,1:size(psth1,1),0.1,fig1,clims=empty
end
%return;
psth1=PSTH2;
if heatmap
%fig1 = figure;
subplot(2,1,2);
thres = 10; %更换 thres = 10;
heatmapPlot(psth1,interval,basal_time,21:120,1,1:size(psth1,1),0.1,fig1,); %heatmapPlot作图方法 需要输入psth1(图的值),interval(0.01),basal_time(-2),21:120(???),1,1:size(psth1,1),0.1,fig1,clims
end
xlabel('Time (s)');
return;
function edit_trial_from_Callback(hObject, eventdata, handles)
% hObject handle to edit_trial_from (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_trial_from as text
% str2double(get(hObject,'String')) returns contents of edit_trial_from as a double
% --- Executes during object creation, after setting all properties.
function edit_trial_from_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_trial_from (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
function edit_sti1_Callback(hObject, eventdata, handles)
% hObject handle to edit_sti1 (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_sti1 as text
% str2double(get(hObject,'String')) returns contents of edit_sti1 as a double
% --- Executes during object creation, after setting all properties.
function edit_sti1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_sti1 (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
function edit_post_sti_time_Callback(hObject, eventdata, handles)
% hObject handle to edit_post_sti_time (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_post_sti_time as text
% str2double(get(hObject,'String')) returns contents of edit_post_sti_time as a double
% --- Executes during object creation, after setting all properties.
function edit_post_sti_time_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_post_sti_time (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
function edit_control_time_Callback(hObject, eventdata, handles)
% hObject handle to edit_control_time (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_control_time as text
% str2double(get(hObject,'String')) returns contents of edit_control_time as a double
% --- Executes during object creation, after setting all properties.
function edit_control_time_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_control_time (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
function edit_sampling_rate_Callback(hObject, eventdata, handles)
% hObject handle to edit_sampling_rate (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_sampling_rate as text
% str2double(get(hObject,'String')) returns contents of edit_sampling_rate as a double
% --- Executes during object creation, after setting all properties.
function edit_sampling_rate_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_sampling_rate (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
function edit_pre_sti_time_Callback(hObject, eventdata, handles)
% hObject handle to edit_pre_sti_time (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_pre_sti_time as text
% str2double(get(hObject,'String')) returns contents of edit_pre_sti_time as a double
% --- Executes during object creation, after setting all properties.
function edit_pre_sti_time_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_pre_sti_time (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
function edit11_Callback(hObject, eventdata, handles)
% hObject handle to edit11 (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 edit11 as text
% str2double(get(hObject,'String')) returns contents of edit11 as a double
% --- Executes during object creation, after setting all properties.
function edit11_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit11 (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
% --- Executes on button press in radiobutton1.
function radiobutton1_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton1 (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 radiobutton1
% --- Executes on button press in radiobutton_z_score.
function radiobutton_z_score_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton_z_score (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 radiobutton_z_score
set(handles.radiobutton_z_score,'Value',1);
set(handles.radiobutton_deltaF,'Value',0);
function edit_offset_Callback(hObject, eventdata, handles)
% hObject handle to edit_offset (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_offset as text
% str2double(get(hObject,'String')) returns contents of edit_offset as a double
% --- Executes during object creation, after setting all properties.
function edit_offset_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_offset (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
function edit_clims_Callback(hObject, eventdata, handles)
% hObject handle to edit_clims (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_clims as text
% str2double(get(hObject,'String')) returns contents of edit_clims as a double
% --- Executes during object creation, after setting all properties.
function edit_clims_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_clims (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
% --- Executes on button press in checkbox_heatmap.
function checkbox_heatmap_Callback(hObject, eventdata, handles)
% hObject handle to checkbox_heatmap (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 checkbox_heatmap
% --- Executes on selection change in popupmenu_sort.
function popupmenu_sort_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu_sort (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 popupmenu_sort contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu_sort
% --- Executes during object creation, after setting all properties.
function popupmenu_sort_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu_sort (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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
function edit_SD_Callback(hObject, eventdata, handles)
% hObject handle to edit_SD (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_SD as text
% str2double(get(hObject,'String')) returns contents of edit_SD as a double
% --- Executes during object creation, after setting all properties.
function edit_SD_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_SD (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
function edit15_Callback(hObject, eventdata, handles)
% hObject handle to edit_offset (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_offset as text
% str2double(get(hObject,'String')) returns contents of edit_offset as a double
% --- Executes during object creation, after setting all properties.
function edit15_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_offset (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
% --- Executes on button press in radiobutton_deltaF.
function radiobutton_deltaF_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton_deltaF (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 radiobutton_deltaF
set(handles.radiobutton_deltaF,'Value',1);
set(handles.radiobutton_z_score,'Value',0);
function edit16_Callback(hObject, eventdata, handles)
% hObject handle to edit_bin (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_bin as text
% str2double(get(hObject,'String')) returns contents of edit_bin as a double
% --- Executes during object creation, after setting all properties.
function edit16_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_bin (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
function TB_SampleRate_Callback(hObject, eventdata, handles)
% hObject handle to TB_SampleRate (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 TB_SampleRate as text
% str2double(get(hObject,'String')) returns contents of TB_SampleRate as a double
% --- Executes during object creation, after setting all properties.
function TB_SampleRate_CreateFcn(hObject, eventdata, handles)
% hObject handle to TB_SampleRate (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
function edit_controltime_Callback(hObject, eventdata, handles)
% hObject handle to edit_controltime (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_controltime as text
% str2double(get(hObject,'String')) returns contents of edit_controltime as a double
% --- Executes during object creation, after setting all properties.
function edit_controltime_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_controltime (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
function edit_evaluationtime_Callback(hObject, eventdata, handles)
% hObject handle to edit_evaluationtime (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_evaluationtime as text
% str2double(get(hObject,'String')) returns contents of edit_evaluationtime as a double
% --- Executes during object creation, after setting all properties.
function edit_evaluationtime_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_evaluationtime (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
% --- Executes on button press in pushbutton_plot.
function pushbutton_plot_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_plot (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
offset = str2double(get(handles.edit_offset,'String'));
z_score = get(handles.radiobutton_z_score,'Value');
controltime=str2num(get(handles.edit_controltime,'String'));
evaluationtime=str2num(get(handles.edit_evaluationtime,'String'));
interval = 1/str2num(get(handles.TB_SampleRate,'String')); % interval
bin = str2double(get(handles.edit_bin,'String'));
if bin<interval
bin=interval;
set(handles.edit_bin,'String',num2str(interval));
end
values = handles.wave;
num = floor(bin/interval);
M = mod(size(values,1),num);
values = [values;zeros(num-M,1)];
values = mean(reshape(values',num,[]),1)';
interval = bin;
controldata=values(round(controltime(1)/interval):round(controltime(2)/interval));
if isempty(evaluationtime)
evaluationdata=values;
else
evaluationdata=values(round(evaluationtime(1)/interval):round(evaluationtime(2)/interval));
end
figure;
if z_score==1
plot(interval*(1:1:length(evaluationdata)),(evaluationdata-mean(controldata))/std(controldata));
xlabel('Time (s)');
ylabel('z-score');
else
plot(interval*(1:1:length(evaluationdata)),(evaluationdata-mean(controldata))/(mean(controldata)-offset));
xlabel('Time (s)');
ylabel('F/Hz');%CHANGED BY ZZG
end
% --- Executes on selection change in pm_cue.
function pm_cue_Callback(hObject, eventdata, handles)
% hObject handle to pm_cue (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 pm_cue contents as cell array
% contents{get(hObject,'Value')} returns selected item from pm_cue
if isfield(handles,'length')
cell=[];
switch get(hObject,'value')
case 1
for i=1:handles.length-1
if handles.data1(i)==0 && handles.data1(i+1)==1
cell(i+1) =1;
else
cell(i+1) =0;
end
end
case 2
for i=1:handles.length-1
if handles.data2(i)==0 && handles.data2(i+1)==1
cell(i+1) =1;
else
cell(i+1) =0;
end
end
case 3
for i=1:handles.length-1
if handles.data3(i)==0 && handles.data3(i+1)==1
cell(i+1) =1;
else
cell(i+1) =0;
end
end
end
upindex=find(cell==1);
handles.upindex=upindex;
trialnum = size(upindex);
handles.trialnum = trialnum(2);
set(handles.edit_sti1, 'String', num2str(handles.trialnum));
end
guidata(hObject,handles);
% --- Executes during object creation, after setting all properties.
function pm_cue_CreateFcn(hObject, eventdata, handles)
% hObject handle to pm_cue (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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