-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrefTFAnalysisCombinedv4.m
8074 lines (6704 loc) · 403 KB
/
refTFAnalysisCombinedv4.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
% Time-frequency analysis for different reference techniques
% Single, Bipolar, Average, CSD
% Vinay Shirhatti 16 Sep 2014
%
% modified from refTFAnalysisGeneric in GammaStimDicontinuityProject
% 27 March 2015
%==========================================================================
function refTFAnalysisCombinedv4(subjectName,expDate,protocolName,folderSourceString,gridType,loadProtocolNumber)
if ~exist('folderSourceString','var') folderSourceString='/media/store/'; end
if ~exist('gridType','var') gridType='EEG'; end
if ~exist('loadProtocolNumber','var') loadProtocolNumber = 11; end % Vinay - anything greater than 10 will read the protocolNumber from the saved data
%========================Define folder paths===============================
folderName = fullfile(folderSourceString,'data',subjectName,gridType,expDate,protocolName);
% Get folders
folderExtract = fullfile(folderName,'extractedData');
folderSegment = fullfile(folderName,'segmentedData');
folderLFP = fullfile(folderSegment,'LFP');
folderSpikes = fullfile(folderSegment,'Spikes');
folderBipolar = fullfile(folderLFP,'bipolar');
folderAverage = folderLFP;
folderCSD = fullfile(folderLFP,'csd');
%-----
% load LFP Information
[analogChannelsStored,timeVals,~,analogInputNums] = loadlfpInfo(folderLFP);
[neuralChannelsStored,SourceUnitIDs] = loadspikeInfo(folderSpikes);
% Get Combinations
[~,aValsUnique,eValsUnique,sValsUnique,fValsUnique,oValsUnique,cValsUnique,tValsUnique,rValsUnique,pValsUnique] = loadParameterCombinations(folderExtract);
% Get properties of the Stimulus
% stimResults = loadStimResults(folderExtract);
% Vinay - read the variable loadProtocolNumber as protocolNumber if it is
% less than 11. Otherwise it will be loaded from stimResults. This is so
% that one can directly pass the protocolNumber in case it is not recorded
% in stimResults
if strncmp(protocolName,'CRS',3)
if (loadProtocolNumber < 11)
protocolNumber = loadProtocolNumber;
else
protocolNumber = getProtocolNumber(folderExtract);
end
else
protocolNumber = 11;
end
% Vinay - get the particular gabors that were displayed in the protocol.
gaborsDisplayed = getGaborsDisplayed(folderExtract);
disp(['Gabors displayed in this protocol:' num2str(gaborsDisplayed)]);
% Vinay - if all the gabors were not displayed then assign some default
% value to the null gabor's parameters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Display main options
% fonts
fontSizeSmall = 10; fontSizeMedium = 12; fontSizeLarge = 16; fontSizeTiny = 8; fontSizeSuperTiny = 6;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Make Panels
panelHeight = 0.3; panelStartHeight = 0.68;
staticPanelWidth = 0.22; staticStartPos = 0.025; % [Vinay] - changed width 0.25 to 0.22
dynamicPanelWidth = 0.23; dynamicStartPos = 0.245; % [Vinay] - changed width 0.25 to 0.23
timingPanelWidth = 0.20; timingStartPos = 0.475; % [Vinay] - changed width 0.25 to 0.20
plotOptionsPanelWidth = 0.15; plotOptionsStartPos = 0.675; % [Vinay] - changed width 0.2 to 0.15
selectParamPanelWidth = 0.15; selectParamStartPos = 0.825; % [Vinay] - adding a panel to select parameters
backgroundColor = 'w';
% Vinay - define a flag for notching the line noise
notchData = 0;
% [Vinay] - define a flag to take bipolar (i.e. diff) signals: V1-V2
useBipolar = 0; % (time domain) electrode1 - electrode2
useDiff = 0; % (freq domain) spectrum1 -spectrum2
% [Vinay]- define a flag to plot SEM for the ERP plots
plotSEM = 1;
% [Vinay] - define a flag to save MP data if it is set
saveMPFlag = 1;
% [Vinay] - define a flag to save HHT data if it is set
saveHHTFlag = 1;
% [Vinay] - define a flag to use badTrials for each electrode separately
useAllBadTrials = 1;
% [Vinay] - define a flag to use intersection of good trials across
% electrodes or else to use individual electrodewise good trials
intersectTrials = 0;
% [Vinay] - set this flag if bipolar data is stored
existsBipolarData = 0;
% [Vinay] - set this flag if log of every trials is to be taken before
% averaging (for TF plots)
takeLogTrial = 0;
% [Vinay] - set this if the bipolar pairs are made using complimentary
% contralateral electrodes and not the nearest neighbour
contralateralNeighbour = 1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%% Dynamic panel %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
dynamicHeight = 0.06; dynamicGap=0.015; dynamicTextWidth = 0.6;
hDynamicPanel = uipanel('Title','Parameters','fontSize', fontSizeLarge, ...
'Unit','Normalized','Position',[dynamicStartPos panelStartHeight dynamicPanelWidth panelHeight]);
% Analog channel
[analogChannelStringList,analogChannelStringArray] = getAnalogStringFromValues(analogChannelsStored,analogInputNums);
uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'Position',[0 1-(dynamicHeight+dynamicGap) dynamicTextWidth dynamicHeight],...
'Style','text','String','Analog Channel (1:2)','FontSize',fontSizeTiny);
hAnalogChannel = uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[dynamicTextWidth 1-(dynamicHeight+dynamicGap) (0.5*(1-dynamicTextWidth)) dynamicHeight], ...
'Style','popup','String',analogChannelStringList,'FontSize',fontSizeTiny);
% [Vinay] - adding analog channel 2 for chosing bipolar signals V1-V2
hAnalogChannel2 = uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[(dynamicTextWidth+(0.5*(1-dynamicTextWidth))) 1-(dynamicHeight+dynamicGap) (0.5*(1-dynamicTextWidth)) dynamicHeight], ...
'Style','popup','String',(['none|' analogChannelStringList]),'FontSize',fontSizeTiny,'Callback',{@bipolar_Callback});
% Neural channel
uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'Position',[0 1-2*(dynamicHeight+dynamicGap) dynamicTextWidth dynamicHeight],...
'Style','text','String','Neural Channel','FontSize',fontSizeTiny);
if ~isempty(neuralChannelsStored)
neuralChannelString = getNeuralStringFromValues(neuralChannelsStored,SourceUnitIDs);
hNeuralChannel = uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[dynamicTextWidth 1-2*(dynamicHeight+dynamicGap) 1-dynamicTextWidth dynamicHeight], ...
'Style','popup','String',neuralChannelString,'FontSize',fontSizeTiny);
else
hNeuralChannel = uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'Position', [dynamicTextWidth 1-2*(dynamicHeight+dynamicGap) 1-dynamicTextWidth dynamicHeight], ...
'Style','text','String','Not found','FontSize',fontSizeTiny);
end
if strncmp(protocolName,'GRF',3)
% Sigma
sigmaString = getStringFromValuesGRF(sValsUnique,1);
uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'Position',[0 1-3*(dynamicHeight+dynamicGap) dynamicTextWidth dynamicHeight], ...
'Style','text','String','Sigma (Deg)','FontSize',fontSizeTiny);
hSigma = uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[dynamicTextWidth 1-3*(dynamicHeight+dynamicGap) 1-dynamicTextWidth dynamicHeight], ...
'Style','popup','String',sigmaString,'FontSize',fontSizeTiny);
% Spatial Frequency
spatialFreqString = getStringFromValuesGRF(fValsUnique,1);
uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'Position',[0 1-4*(dynamicHeight+dynamicGap) dynamicTextWidth dynamicHeight], ...
'Style','text','String','Spatial Freq (CPD)','FontSize',fontSizeTiny);
hSpatialFreq = uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[dynamicTextWidth 1-4*(dynamicHeight+dynamicGap) 1-dynamicTextWidth dynamicHeight], ...
'Style','popup','String',spatialFreqString,'FontSize',fontSizeTiny);
% Orientation
orientationString = getStringFromValuesGRF(oValsUnique,1);
uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'Position',[0 1-5*(dynamicHeight+dynamicGap) dynamicTextWidth dynamicHeight], ...
'Style','text','String','Orientation (Deg)','FontSize',fontSizeTiny);
hOrientation = uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[dynamicTextWidth 1-5*(dynamicHeight+dynamicGap) 1-dynamicTextWidth dynamicHeight], ...
'Style','popup','String',orientationString,'FontSize',fontSizeTiny);
% Contrast
contrastString = getStringFromValuesGRF(cValsUnique,1);
uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'Position',[0 1-6*(dynamicHeight+dynamicGap) dynamicTextWidth dynamicHeight], ...
'Style','text','String','Contrast (%)','FontSize',fontSizeTiny);
hContrast = uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[dynamicTextWidth 1-6*(dynamicHeight+dynamicGap) 1-dynamicTextWidth dynamicHeight], ...
'Style','popup','String',contrastString,'FontSize',fontSizeTiny);
% Temporal Frequency
temporalFreqString = getStringFromValuesGRF(tValsUnique,1);
uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'Position',[0 1-7*(dynamicHeight+dynamicGap) dynamicTextWidth dynamicHeight], ...
'Style','text','String','Temporal Freq (Hz)','FontSize',fontSizeTiny);
hTemporalFreq = uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[dynamicTextWidth 1-7*(dynamicHeight+dynamicGap) 1-dynamicTextWidth dynamicHeight], ...
'Style','popup','String',temporalFreqString,'FontSize',fontSizeTiny);
% Azimuth
azimuthString = getStringFromValuesGRF(aValsUnique,1);
uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'Position',[0 1-8*(dynamicHeight+dynamicGap) dynamicTextWidth dynamicHeight],...
'Style','text','String','Azimuth (Deg)','FontSize',fontSizeTiny);
hAzimuth = uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[dynamicTextWidth 1-8*(dynamicHeight+dynamicGap) 1-dynamicTextWidth dynamicHeight], ...
'Style','popup','String',azimuthString,'FontSize',fontSizeTiny);
% Elevation
elevationString = getStringFromValuesGRF(eValsUnique,1);
uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'Position',[0 1-9*(dynamicHeight+dynamicGap) dynamicTextWidth dynamicHeight], ...
'Style','text','String','Elevation (Deg)','FontSize',fontSizeTiny);
hElevation = uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position',...
[dynamicTextWidth 1-9*(dynamicHeight+dynamicGap) 1-dynamicTextWidth dynamicHeight], ...
'Style','popup','String',elevationString,'FontSize',fontSizeTiny);
%======================================================================
% Select the two parameters whose values are to be varied across
% plots/dimensions
%======================================================================
parametersString = 'NA|azimuth|elevation|sigma|spatialFreq|orientation|contrast|temporalFreq';
uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'Position',[0 1-10*(dynamicHeight+dynamicGap) dynamicTextWidth dynamicHeight], ...
'Style','text','String','vary1','FontSize',fontSizeMedium);
hParam7 = uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[dynamicTextWidth 1-10*(dynamicHeight+dynamicGap) 1-dynamicTextWidth dynamicHeight], ...
'Style','popup','String',parametersString,'FontSize',fontSizeTiny,'Callback',{@resetVaryParams_Callback});
uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'Position',[0 1-12*(dynamicHeight+dynamicGap) dynamicTextWidth dynamicHeight], ...
'Style','text','String','vary2','FontSize',fontSizeMedium);
hParam8 = uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[dynamicTextWidth 1-12*(dynamicHeight+dynamicGap) 1-dynamicTextWidth dynamicHeight], ...
'Style','popup','String',parametersString,'FontSize',fontSizeTiny,'Callback',{@resetVaryParams_Callback});
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% Plot grid button
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
selectParamHeight = 0.1; selectParamWidth = 0.5; selectParamBoxWidth = 0.20; % [Vinay] - changed width from 0.25 to 0.20
textWidth = 0.4; selGWidth = 0.2; selPWidth = 0.4;
hSelectParamPanel = uipanel('Title','Plot Options, Parameters','fontSize', fontSizeMedium, ...
'Unit','Normalized','Position',[selectParamStartPos panelStartHeight selectParamPanelWidth panelHeight]);
% plot grid
uicontrol('Parent',hSelectParamPanel,'Unit','Normalized', ...
'Position',[0 1-selectParamHeight 1 selectParamHeight], ...
'Style','pushbutton','String','plot grid','FontSize',fontSizeMedium, ...
'Callback',{@plotGrid_Callback});
% titles to be shown on the plots
% title 1
title1ON = 1;
hTitle1 = uicontrol('Parent',hSelectParamPanel,'Unit','Normalized', ...
'Position',[0 1-2*selectParamHeight 0.3 selectParamHeight],...
'BackgroundColor', backgroundColor,...
'Style','checkbox','String','title 1','FontSize',fontSizeSuperTiny, 'Callback',{@selTitle1_Callback});
% title 1
title2ON = 1;
hTitle2 = uicontrol('Parent',hSelectParamPanel,'Unit','Normalized', ...
'Position',[0.33 1-2*selectParamHeight 0.3 selectParamHeight],...
'BackgroundColor', backgroundColor,...
'Style','checkbox','String','title 2','FontSize',fontSizeSuperTiny, 'Callback',{@selTitle2_Callback});
nShow = 1;
hNumTrials = uicontrol('Parent',hSelectParamPanel,'Unit','Normalized', ...
'Position',[0.69 1-2*selectParamHeight 0.3 selectParamHeight],...
'BackgroundColor', backgroundColor,...
'Style','checkbox','String','n','FontSize',fontSizeSuperTiny, 'Callback',{@selNumTrials_Callback});
ignoreTrials = 1;
hIgnoreTrials = uicontrol('Parent',hSelectParamPanel,'Unit','Normalized', ...
'Position',[0 1-3*selectParamHeight 0.35 selectParamHeight],...
'BackgroundColor', backgroundColor,...
'Style','checkbox','String','ignoreTrials','FontSize',fontSizeSuperTiny, 'Callback',{@ignoreTrials_Callback});
ignoreTrialNum = [];
hIgnoreTrialNum = uicontrol('Parent',hSelectParamPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, ...
'Position',[0.4 1-3*selectParamHeight 0.55 selectParamHeight], ...
'Style','edit','String','','FontSize',fontSizeSuperTiny, 'Callback',{@ignoreTrialNum_Callback});
elseif strncmp(protocolName,'CRS',3)
%[Vinay] - create 3 columns corresponding to the parameters of the 3 gabors
%-Centre, Ring, Surround. Textwidth = 0.4, C,R,S popout - each 0.2 width
labelWidth = 0.4; crsWidth = 0.2; % [Vinay] - labelWidth + 3(crsWidth) = 1
uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'Position',[labelWidth 1-3*(dynamicHeight+dynamicGap) (3*crsWidth) dynamicHeight],...
'Style','text','String','Surround Ring Centre','FontSize',fontSizeTiny);
for gaborNum = 1:3
% Azimuth
azimuthString = getStringFromValues(aValsUnique,1, gaborNum);
uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'Position',[0 1-4*(dynamicHeight+dynamicGap) labelWidth dynamicHeight],...
'Style','text','String','Azimuth (Deg)','FontSize',fontSizeTiny);
hAzimuth(gaborNum) = uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[(labelWidth+(gaborNum-1)*crsWidth) 1-4*(dynamicHeight+dynamicGap) crsWidth dynamicHeight], ...
'Style','popup','String',azimuthString,'FontSize',fontSizeTiny);
% Elevation
elevationString = getStringFromValues(eValsUnique,1, gaborNum);
uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'Position',[0 1-5*(dynamicHeight+dynamicGap) labelWidth dynamicHeight], ...
'Style','text','String','Elevation (Deg)','FontSize',fontSizeTiny);
hElevation(gaborNum) = uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position',...
[(labelWidth+(gaborNum-1)*crsWidth) 1-5*(dynamicHeight+dynamicGap) crsWidth dynamicHeight], ...
'Style','popup','String',elevationString,'FontSize',fontSizeTiny);
% Sigma
sigmaString = getStringFromValues(sValsUnique,1, gaborNum);
uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'Position',[0 1-6*(dynamicHeight+dynamicGap) labelWidth dynamicHeight], ...
'Style','text','String','Sigma (Deg)','FontSize',fontSizeTiny);
hSigma(gaborNum) = uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[(labelWidth+(gaborNum-1)*crsWidth) 1-6*(dynamicHeight+dynamicGap) crsWidth dynamicHeight], ...
'Style','popup','String',sigmaString,'FontSize',fontSizeTiny);
% Spatial Frequency
spatialFreqString = getStringFromValues(fValsUnique,1, gaborNum);
uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'Position',[0 1-7*(dynamicHeight+dynamicGap) labelWidth dynamicHeight], ...
'Style','text','String','Spatial Freq (CPD)','FontSize',fontSizeTiny);
hSpatialFreq(gaborNum) = uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[(labelWidth+(gaborNum-1)*crsWidth) 1-7*(dynamicHeight+dynamicGap) crsWidth dynamicHeight], ...
'Style','popup','String',spatialFreqString,'FontSize',fontSizeTiny);
% Orientation
orientationString = getStringFromValues(oValsUnique,1, gaborNum);
uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'Position',[0 1-8*(dynamicHeight+dynamicGap) labelWidth dynamicHeight], ...
'Style','text','String','Orientation (Deg)','FontSize',fontSizeTiny);
hOrientation(gaborNum) = uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[(labelWidth+(gaborNum-1)*crsWidth) 1-8*(dynamicHeight+dynamicGap) crsWidth dynamicHeight], ...
'Style','popup','String',orientationString,'FontSize',fontSizeTiny);
% Contrast
contrastString = getStringFromValues(cValsUnique,1, gaborNum);
uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'Position',[0 1-9*(dynamicHeight+dynamicGap) labelWidth dynamicHeight], ...
'Style','text','String','Contrast (%)','FontSize',fontSizeTiny);
hContrast(gaborNum) = uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[(labelWidth+(gaborNum-1)*crsWidth) 1-9*(dynamicHeight+dynamicGap) crsWidth dynamicHeight], ...
'Style','popup','String',contrastString,'FontSize',fontSizeTiny);
% Temporal Frequency
temporalFreqString = getStringFromValues(tValsUnique,1, gaborNum);
uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'Position',[0 1-10*(dynamicHeight+dynamicGap) labelWidth dynamicHeight], ...
'Style','text','String','Temporal Freq (Hz)','FontSize',fontSizeTiny);
hTemporalFreq(gaborNum) = uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[(labelWidth+(gaborNum-1)*crsWidth) 1-10*(dynamicHeight+dynamicGap) crsWidth dynamicHeight], ...
'Style','popup','String',temporalFreqString,'FontSize',fontSizeTiny);
% [Vinay] - adding radius and spatial phase cells
% radius
radiusString = getStringFromValues(rValsUnique,1, gaborNum);
uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'Position',[0 1-11*(dynamicHeight+dynamicGap) labelWidth dynamicHeight], ...
'Style','text','String','Radius (deg)','FontSize',fontSizeTiny);
hRadius(gaborNum) = uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[(labelWidth+(gaborNum-1)*crsWidth) 1-11*(dynamicHeight+dynamicGap) crsWidth dynamicHeight], ...
'Style','popup','String',radiusString,'FontSize',fontSizeTiny);
% spatial phase
spatialPhaseString = getStringFromValues(pValsUnique,1, gaborNum);
uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'Position',[0 1-12*(dynamicHeight+dynamicGap) labelWidth dynamicHeight], ...
'Style','text','String','Spatial Phase (Deg)','FontSize',fontSizeTiny);
hSpatialPhase(gaborNum) = uicontrol('Parent',hDynamicPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[(labelWidth+(gaborNum-1)*crsWidth) 1-12*(dynamicHeight+dynamicGap) crsWidth dynamicHeight], ...
'Style','popup','String',spatialPhaseString,'FontSize',fontSizeTiny);
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%% Timing panel %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
timingHeight = 0.1; timingTextWidth = 0.5; timingBoxWidth = 0.20; % [Vinay] - changed width from 0.25 to 0.20
hTimingPanel = uipanel('Title','Timing','fontSize', fontSizeLarge, ...
'Unit','Normalized','Position',[timingStartPos panelStartHeight timingPanelWidth panelHeight]);
% Vinay - changed these values for EEG
signalRange = [-0.6 1.0];
fftRange = [0 150];
baseline = [-0.5 0];
stimPeriod = [0.25 0.75];
% Signal Range
uicontrol('Parent',hTimingPanel,'Unit','Normalized', ...
'Position',[0 1-timingHeight timingTextWidth timingHeight], ...
'Style','text','String','Parameter','FontSize',fontSizeMedium);
uicontrol('Parent',hTimingPanel,'Unit','Normalized', ...
'Position',[timingTextWidth 1-timingHeight timingBoxWidth timingHeight], ...
'Style','text','String','Min','FontSize',fontSizeMedium);
uicontrol('Parent',hTimingPanel,'Unit','Normalized', ...
'Position',[timingTextWidth+timingBoxWidth 1-timingHeight timingBoxWidth timingHeight], ...
'Style','text','String','Max','FontSize',fontSizeMedium);
% Stim Range
uicontrol('Parent',hTimingPanel,'Unit','Normalized', ...
'Position',[0 1-3*timingHeight timingTextWidth timingHeight], ...
'Style','text','String','Stim Range (s)','FontSize',fontSizeSmall);
hStimMin = uicontrol('Parent',hTimingPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, ...
'Position',[timingTextWidth 1-3*timingHeight timingBoxWidth timingHeight], ...
'Style','edit','String',num2str(signalRange(1)),'FontSize',fontSizeSmall);
hStimMax = uicontrol('Parent',hTimingPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, ...
'Position',[timingTextWidth+timingBoxWidth 1-3*timingHeight timingBoxWidth timingHeight], ...
'Style','edit','String',num2str(signalRange(2)),'FontSize',fontSizeSmall);
% FFT Range
uicontrol('Parent',hTimingPanel,'Unit','Normalized', ...
'Position',[0 1-5*timingHeight timingTextWidth timingHeight], ...
'Style','text','String','FFT Range (Hz)','FontSize',fontSizeSmall);
hFFTMin = uicontrol('Parent',hTimingPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, ...
'Position',[timingTextWidth 1-5*timingHeight timingBoxWidth timingHeight], ...
'Style','edit','String',num2str(fftRange(1)),'FontSize',fontSizeSmall);
hFFTMax = uicontrol('Parent',hTimingPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, ...
'Position',[timingTextWidth+timingBoxWidth 1-5*timingHeight timingBoxWidth timingHeight], ...
'Style','edit','String',num2str(fftRange(2)),'FontSize',fontSizeSmall);
% Baseline
uicontrol('Parent',hTimingPanel,'Unit','Normalized', ...
'Position',[0 1-6*timingHeight timingTextWidth timingHeight], ...
'Style','text','String','Basline (s)','FontSize',fontSizeSmall);
hBaselineMin = uicontrol('Parent',hTimingPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, ...
'Position',[timingTextWidth 1-6*timingHeight timingBoxWidth timingHeight], ...
'Style','edit','String',num2str(baseline(1)),'FontSize',fontSizeSmall);
hBaselineMax = uicontrol('Parent',hTimingPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, ...
'Position',[timingTextWidth+timingBoxWidth 1-6*timingHeight timingBoxWidth timingHeight], ...
'Style','edit','String',num2str(baseline(2)),'FontSize',fontSizeSmall);
% Stim Period
uicontrol('Parent',hTimingPanel,'Unit','Normalized', ...
'Position',[0 1-7*timingHeight timingTextWidth timingHeight], ...
'Style','text','String','Stim period (s)','FontSize',fontSizeSmall);
hStimPeriodMin = uicontrol('Parent',hTimingPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, ...
'Position',[timingTextWidth 1-7*timingHeight timingBoxWidth timingHeight], ...
'Style','edit','String',num2str(stimPeriod(1)),'FontSize',fontSizeSmall);
hStimPeriodMax = uicontrol('Parent',hTimingPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, ...
'Position',[timingTextWidth+timingBoxWidth 1-7*timingHeight timingBoxWidth timingHeight], ...
'Style','edit','String',num2str(stimPeriod(2)),'FontSize',fontSizeSmall);
% Y Range
uicontrol('Parent',hTimingPanel,'Unit','Normalized', ...
'Position',[0 1-8*timingHeight timingTextWidth timingHeight], ...
'Style','text','String','Y Range','FontSize',fontSizeSmall);
hYMin = uicontrol('Parent',hTimingPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, ...
'Position',[timingTextWidth 1-8*timingHeight timingBoxWidth timingHeight], ...
'Style','edit','String','0','FontSize',fontSizeSmall);
hYMax = uicontrol('Parent',hTimingPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, ...
'Position',[timingTextWidth+timingBoxWidth 1-8*timingHeight timingBoxWidth timingHeight], ...
'Style','edit','String','1','FontSize',fontSizeSmall);
% Band Power
fBandLow = 40; fBandHigh = 60;
uicontrol('Parent',hTimingPanel,'Unit','Normalized', ...
'Position',[0 1-9*timingHeight timingTextWidth timingHeight], ...
'Style','text','String','freqBand range','FontSize',fontSizeSmall);
hfBandLow = uicontrol('Parent',hTimingPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, ...
'Position',[timingTextWidth 1-9*timingHeight timingBoxWidth timingHeight], ...
'Style','edit','String',num2str(fBandLow),'FontSize',fontSizeSmall);
hfBandHigh = uicontrol('Parent',hTimingPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, ...
'Position',[timingTextWidth+timingBoxWidth 1-9*timingHeight timingBoxWidth timingHeight], ...
'Style','edit','String',num2str(fBandHigh),'FontSize',fontSizeSmall);
% STA length
staLen = [-0.05 0.05];
uicontrol('Parent',hTimingPanel,'Unit','Normalized', ...
'Position',[0 1-10*timingHeight timingTextWidth/2 timingHeight], ...
'Style','text','String','STA len (s)','FontSize',fontSizeTiny);
hSTAMin = uicontrol('Parent',hTimingPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, ...
'Position',[timingTextWidth/2 1-10*timingHeight timingBoxWidth timingHeight], ...
'Style','edit','String',num2str(staLen(1)),'FontSize',fontSizeTiny);
hSTAMax = uicontrol('Parent',hTimingPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, ...
'Position',[timingTextWidth/2+timingBoxWidth 1-10*timingHeight timingBoxWidth timingHeight], ...
'Style','edit','String',num2str(staLen(2)),'FontSize',fontSizeTiny);
hRemoveMeanSTA = uicontrol('Parent',hTimingPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, ...
'Position',[timingTextWidth/2+2*timingBoxWidth 1-10*timingHeight 3*timingBoxWidth/2 timingHeight], ...
'Style','togglebutton','String','remove mean STA','FontSize',fontSizeTiny);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%% Plot Options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
plotOptionsHeight = 0.1;
hPlotOptionsPanel = uipanel('Title','Plotting Options','fontSize', fontSizeLarge, ...
'Unit','Normalized','Position',[plotOptionsStartPos panelStartHeight plotOptionsPanelWidth panelHeight]);
% Chose color
[colorString, colorNames] = getColorString;
uicontrol('Parent',hPlotOptionsPanel,'Unit','Normalized', ...
'Position',[0 1-plotOptionsHeight 0.6 plotOptionsHeight], ...
'Style','text','String','Color','FontSize',fontSizeTiny);
hChooseColor = uicontrol('Parent',hPlotOptionsPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, ...
'Position',[0.6 1-plotOptionsHeight 0.4 plotOptionsHeight], ...
'Style','popup','String',colorString,'FontSize',fontSizeTiny);
% Vinay - adding an option to adjust lineWidth of plots
linewidths = [1,1.5,2,2.5,3];
linewidthString = '1|1.5|2|2.5|3|';
uicontrol('Parent',hPlotOptionsPanel,'Unit','Normalized', ...
'Position',[0 1-2*plotOptionsHeight 0.6 plotOptionsHeight], ...
'Style','text','String','lineWidth','FontSize',fontSizeTiny);
hChooseWidth = uicontrol('Parent',hPlotOptionsPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, ...
'Position',[0.6 1-2*plotOptionsHeight 0.4 plotOptionsHeight], ...
'Style','popup','String',linewidthString,'FontSize',fontSizeTiny);
% Analysis Type
analysisTypeString = 'ERP|FFT|delta FFT|Band Power|Firing Rate|Raster|STA|Get Plots|All LFP|All Spikes';
uicontrol('Parent',hPlotOptionsPanel,'Unit','Normalized', ...
'Position',[0 1-3*plotOptionsHeight 0.6 plotOptionsHeight], ...
'Style','text','String','Analysis Type','FontSize',fontSizeSmall);
hAnalysisType = uicontrol('Parent',hPlotOptionsPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[0.6 1-3*plotOptionsHeight 0.4 plotOptionsHeight], ...
'Style','popup','String',analysisTypeString,'FontSize',fontSizeSmall);
% Vinay - choose the plots to be included in the combined figure
drawStim = 1; drawERP = 0; drawFR = 0; drawTF = 0; drawTrends = 0;
hDrawStim = uicontrol('Parent',hPlotOptionsPanel,'Unit','Normalized', ...
'Position',[0 1-4*plotOptionsHeight 0.18 plotOptionsHeight],...
'BackgroundColor', backgroundColor,...
'Style','checkbox','String','Stim','FontSize',fontSizeSuperTiny, 'Callback',{@drawStim_Callback});
hDrawERP = uicontrol('Parent',hPlotOptionsPanel,'Unit','Normalized', ...
'Position',[0.2 1-4*plotOptionsHeight 0.18 plotOptionsHeight],...
'BackgroundColor', backgroundColor,...
'Style','checkbox','String','ERP','FontSize',fontSizeSuperTiny, 'Callback',{@drawERP_Callback});
hDrawFR = uicontrol('Parent',hPlotOptionsPanel,'Unit','Normalized', ...
'Position',[0.4 1-4*plotOptionsHeight 0.18 plotOptionsHeight],...
'BackgroundColor', backgroundColor,...
'Style','checkbox','String','FR','FontSize',fontSizeSuperTiny, 'Callback',{@drawFR_Callback});
hDrawTF = uicontrol('Parent',hPlotOptionsPanel,'Unit','Normalized', ...
'Position',[0.6 1-4*plotOptionsHeight 0.18 plotOptionsHeight],...
'BackgroundColor', backgroundColor,...
'Style','checkbox','String','TF','FontSize',fontSizeSuperTiny, 'Callback',{@drawTF_Callback});
hDrawTrends = uicontrol('Parent',hPlotOptionsPanel,'Unit','Normalized', ...
'Position',[0.8 1-4*plotOptionsHeight 0.18 plotOptionsHeight],...
'BackgroundColor', backgroundColor,...
'Style','checkbox','String','Trends','FontSize',fontSizeSuperTiny, 'Callback',{@drawTrends_Callback});
% Vinay - adding a toggle button to use notched data
hNotchData = uicontrol('Parent',hPlotOptionsPanel,'Unit','Normalized', ...
'Position',[0 5*plotOptionsHeight 1 plotOptionsHeight], ...
'Style','togglebutton','String','raw/lineNoiseRemoved','FontSize',fontSizeMedium, ...
'Callback',{@notch_Callback});
uicontrol('Parent',hPlotOptionsPanel,'Unit','Normalized', ...
'Position',[0 4*plotOptionsHeight 1 plotOptionsHeight], ...
'Style','pushbutton','String','cla','FontSize',fontSizeMedium, ...
'Callback',{@cla_Callback});
hHoldOn = uicontrol('Parent',hPlotOptionsPanel,'Unit','Normalized', ...
'Position',[0 3*plotOptionsHeight 1 plotOptionsHeight], ...
'Style','togglebutton','String','hold on','FontSize',fontSizeMedium, ...
'Callback',{@holdOn_Callback});
uicontrol('Parent',hPlotOptionsPanel,'Unit','Normalized', ...
'Position',[0 2*plotOptionsHeight 1 plotOptionsHeight], ...
'Style','pushbutton','String','rescale Y','FontSize',fontSizeMedium, ...
'Callback',{@rescaleY_Callback});
uicontrol('Parent',hPlotOptionsPanel,'Unit','Normalized', ...
'Position',[0 plotOptionsHeight 1 plotOptionsHeight], ...
'Style','pushbutton','String','rescale X','FontSize',fontSizeMedium, ...
'Callback',{@rescaleData_Callback});
uicontrol('Parent',hPlotOptionsPanel,'Unit','Normalized', ...
'Position',[0 0 1 plotOptionsHeight], ...
'Style','pushbutton','String','plot','FontSize',fontSizeMedium, ...
'Callback',{@plotData_Callback});
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% [Vinay] - adding a panel to select the parameters for the plots
% only for CRS
if strncmp(protocolName,'CRS',3)
selectParamHeight = 0.1; selectParamWidth = 0.5; selectParamBoxWidth = 0.20; % [Vinay] - changed width from 0.25 to 0.20
textWidth = 0.4; selGWidth = 0.2; selPWidth = 0.4;
hSelectParamPanel = uipanel('Title','Plot Options, Parameters','fontSize', fontSizeMedium, ...
'Unit','Normalized','Position',[selectParamStartPos panelStartHeight selectParamPanelWidth panelHeight]);
parametersString = 'NA|azimuth|elevation|sigma|spatialFreq|orientation|contrast|temporalFreq|radius|spatialPhase';
gaborString = 'NA|C|R|S';
% plot grid
uicontrol('Parent',hSelectParamPanel,'Unit','Normalized', ...
'Position',[0 1-selectParamHeight 1 selectParamHeight], ...
'Style','pushbutton','String','plot grid','FontSize',fontSizeMedium, ...
'Callback',{@plotGrid_Callback});
% titles to be shown on the plots
% title 1
title1ON = 1;
hTitle1 = uicontrol('Parent',hSelectParamPanel,'Unit','Normalized', ...
'Position',[0 1-2*selectParamHeight 0.45 selectParamHeight],...
'BackgroundColor', backgroundColor,...
'Style','checkbox','String','title 1','FontSize',fontSizeSuperTiny, 'Callback',{@selTitle1_Callback});
% title 1
title2ON = 1;
hTitle2 = uicontrol('Parent',hSelectParamPanel,'Unit','Normalized', ...
'Position',[0.5 1-2*selectParamHeight 0.45 selectParamHeight],...
'BackgroundColor', backgroundColor,...
'Style','checkbox','String','title 2','FontSize',fontSizeSuperTiny, 'Callback',{@selTitle2_Callback});
nShow = 1;
hNumTrials = uicontrol('Parent',hSelectParamPanel,'Unit','Normalized', ...
'Position',[0.69 1-2*selectParamHeight 0.3 selectParamHeight],...
'BackgroundColor', backgroundColor,...
'Style','checkbox','String','n','FontSize',fontSizeSuperTiny, 'Callback',{@selNumTrials_Callback});
ignoreTrials = 0;
hIgnoreTrials = uicontrol('Parent',hSelectParamPanel,'Unit','Normalized', ...
'Position',[0 1-3*selectParamHeight 0.45 selectParamHeight],...
'BackgroundColor', backgroundColor,...
'Style','checkbox','String','ignoreTrials','FontSize',fontSizeSuperTiny, 'Callback',{@ignoreTrials_Callback});
ignoreTrialNum = [];
hIgnoreTrialNum = uicontrol('Parent',hSelectParamPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, ...
'Position',[0.4 1-3*selectParamHeight 0.55 selectParamHeight], ...
'Style','edit','String','','FontSize',fontSizeSuperTiny, 'Callback',{@ignoreTrialNum_Callback});
%:::::::::::::::::::::::::::::::::::::::::::::::::::
% Parameters whose values vary across row and column
uicontrol('Parent',hSelectParamPanel,'Unit','Normalized', ...
'Position',[0 1-7*selectParamHeight textWidth selectParamHeight], ...
'Style','text','String','vary1','FontSize',fontSizeMedium);
hGabor7 = uicontrol('Parent',hSelectParamPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[textWidth 1-7*selectParamHeight selGWidth selectParamHeight], ...
'Style','popup','String',gaborString,'FontSize',fontSizeTiny,'Callback',{@resetVaryParams_Callback});
hParam7 = uicontrol('Parent',hSelectParamPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[(textWidth+selGWidth) 1-7*selectParamHeight selPWidth selectParamHeight], ...
'Style','popup','String',parametersString,'FontSize',fontSizeTiny,'Callback',{@resetVaryParams_Callback});
uicontrol('Parent',hSelectParamPanel,'Unit','Normalized', ...
'Position',[0 1-8*selectParamHeight textWidth selectParamHeight], ...
'Style','text','String','vary2','FontSize',fontSizeMedium);
hGabor8 = uicontrol('Parent',hSelectParamPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[textWidth 1-8*selectParamHeight selGWidth selectParamHeight], ...
'Style','popup','String',gaborString,'FontSize',fontSizeTiny,'Callback',{@resetVaryParams_Callback});
hParam8 = uicontrol('Parent',hSelectParamPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[(textWidth+selGWidth) 1-8*selectParamHeight selPWidth selectParamHeight], ...
'Style','popup','String',parametersString,'FontSize',fontSizeTiny,'Callback',{@resetVaryParams_Callback});
% check box - 'show default'. This will load default parameters as per the
% specific protocol being used
useDefParams = 0; % by default don't use the default parameters
hUseDefParams = uicontrol('Parent',hSelectParamPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[0.1 1-9*selectParamHeight 0.8 selectParamHeight], ...
'Style','checkbox','String','Show default parameters','FontSize',fontSizeTiny, 'Callback',{@useDefParams_Callback});
% display the specific protocol being used
protocolNameString = {'NoneProtocol';'RingProtocol';'ContrastRingProtocol';'DualContrastProtocol'; ...
'DualOrientationProtocol';'DualPhaseProtocol';'OrientationRingProtocol';'PhaseRingProtocol'; ...
'Drifting Ring Protocol';'CrossOrientationProtocol';'AnnulusRingProtocol'};
% protocolNumber = getProtocolNumber(folderExtract);
uicontrol('Parent',hSelectParamPanel,'Unit','Normalized', ...
'Position',[0.1 1-10*selectParamHeight 0.8 selectParamHeight], ...
'Style','text','String',protocolNameString(protocolNumber+1),'FontSize',fontSizeTiny,'FontWeight','bold');
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Get plots and message handles
% Get electrode array information
gridLayout = 1; % 64 electrodes
electrodeGridPos = [staticStartPos panelStartHeight staticPanelWidth panelHeight];
hElectrodes = showElectrodeLocations(electrodeGridPos,analogChannelsStored(get(hAnalogChannel,'val')), ...
colorNames(get(hChooseColor,'val')),[],1,0,gridType,subjectName,gridLayout);
% Set up the plot box and its dimensions
startXPos = staticStartPos; endXPos = 0.95; startYPos = 0.05; endYPos = 0.60;
centerGap = 0.05;
plotsWidthX = (endXPos-startXPos-centerGap);
plotsWidthY = (endYPos-startYPos-centerGap);
gap = 0.02; gapSmall = 0.002;
varyGridPos=[startXPos startYPos endXPos endYPos];
uicontrol('Unit','Normalized','Position',[0 0.975 1 0.025],...
'Style','text','String',[subjectName expDate protocolName],'FontSize',fontSizeLarge);
if strncmp(protocolName,'CRS',3)
% [Vinay] - load default parameters
set(hGabor7,'val',1); % 1 => NA
set(hGabor8,'val',1);
set(hParam7,'val',1); % 1 => NA
set(hParam8,'val',1);
adjFactor = 5;
gabor7 = adjFactor - get(hGabor7,'val');
gabor8 = adjFactor - get(hGabor8,'val');
param7 = get(hParam7, 'val');
param8 = get(hParam8, 'val');
hVaryParamPlot = getPlotHandles(length(getValsUnique(gabor7, param7)),length(getValsUnique(gabor8, param8)),varyGridPos,gapSmall);
elseif strncmp(protocolName,'GRF',3)
param7 = get(hParam7, 'val');
param8 = get(hParam8, 'val');
gabor7 = []; gabor8 = [];
hVaryParamPlot = getPlotHandles(length(getValsUniqueGRF(param7)),length(getValsUniqueGRF(param8)),varyGridPos,gapSmall);
end
%**************************************************************************
% [Vinay] - TIME-FREQUENCY ANALYSIS
% Plot the time-frequency distributions on a separate figure
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hTFfig = figure(2);
% Define variables/flags required in TF analysis with their default values
plotStyle = 1; % pcolor, imagesc, raw
spectrumType = 2; % raw, difference
cmin = -2; cmax = 12; % caxis limits
tfMethod = 1; % MTM, MP
% Default MTM params
mtmParams.Fs = 2000;
mtmParams.tapers=[2 3]; % [1 1] case is simply stft with dpss window
mtmParams.trialave=0;
mtmParams.err=0;
mtmParams.pad=-1;
movingWin = [0.4 0.01];
% Default MP parameters
numAtomsMP = 100;
% Default HHT parameters
Nstd = 0; % for emd case as default
NE = 1; % for emd case as default
gaussFtr = 7;
%__________________________________________________________________________
% The tf plots panel for the 6 chosen parameters
% ---------------tfPlotsPanel----------------------------------------------
%--------------------------------------------------------------------------
xGap = 0.01; yGap = 0.01;
tfPlotsHeight = 0.14; tfPlotsGap =0.02;
tfPanelWidth = 0.98; tfPanelHeight = 0.81;
hTFPlotsPanel = uipanel('Title','TF Plots','fontSize', fontSizeLarge, ...
'Unit','Normalized','Position',[xGap yGap tfPanelWidth tfPanelHeight]);
startXPos = 2*xGap; startYPos = 2*yGap; % start from left bottom corner
varyGridTFPos = [startXPos startYPos tfPanelWidth-2*xGap tfPanelHeight-5*yGap];
if strncmp(protocolName,'CRS',3)
hVaryParamTFPlot = getPlotHandles(length(getValsUnique(gabor7, param7)),length(getValsUnique(gabor8, param8)),varyGridTFPos,gapSmall);
elseif strncmp(protocolName,'GRF',3)
hVaryParamTFPlot = getPlotHandles(length(getValsUniqueGRF(param7)),length(getValsUniqueGRF(param8)),varyGridTFPos,gapSmall);
end
%__________________________________________________________________________
% Parameters selection panels for TF methods
% ---------------tfParamsPanel----------------------------------------------
%--------------------------------------------------------------------------
xGap = 0.002;
tfParamsHeight = 1-(tfPanelHeight + yGap); tfParamsGap = tfPlotsGap;
tfParamsWidth = 0.4 - xGap; tfParamsPanelHeight = tfParamsHeight+tfPlotsGap;
tfParamsPanelxStart = (1-tfParamsWidth);
tfParamsPanelyStart = (1-tfParamsPanelHeight);
% hTFParamsPanel = uipanel('Title','TF Parameters','fontSize', fontSizeLarge, ...
% 'Unit','Normalized','Position',[tfParamsPanelxStart tfParamsPanelyStart tfParamsWidth tfParamsPanelHeight]);
textWidth = 0.24;
textHeight = 0.18;
% ====================TF Params Panel=====================================
hTFParamsPanel = uipanel('Title','MTM, MP, HHT Parameters','fontSize', fontSizeMedium, ...
'Unit','Normalized','Position',[(tfParamsPanelxStart) (tfParamsPanelyStart) tfParamsWidth/2 tfParamsPanelHeight]);
% Parameters to divide the panel into rows and columns
xPanel1 = 0; xPanel2 = 0.5;
% Fs, sampling frequency
uicontrol('Parent',hTFParamsPanel,'Unit','Normalized', ...
'Position',[xPanel1 (1-textHeight) textWidth textHeight], ...
'Style','text','String','Fs','FontSize',fontSizeSmall);
hMTMFs = uicontrol('Parent',hTFParamsPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[(xPanel1+textWidth) (1-textHeight) textWidth textHeight], ...
'Style','edit','String',mtmParams.Fs,'FontSize',fontSizeTiny,'Callback',{@resetMTMParams_Callback}); % initialize with default Fs = 2000
%------------------MTM parameters-----------------------
% Tapers TW
uicontrol('Parent',hTFParamsPanel,'Unit','Normalized', ...
'Position',[xPanel1 (1-2*textHeight-tfParamsGap) textWidth textHeight], ...
'Style','text','String','TW','FontSize',fontSizeSmall);
hMTMTapersTW = uicontrol('Parent',hTFParamsPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[(xPanel1+textWidth) (1-2*textHeight-tfParamsGap) textWidth textHeight], ...
'Style','edit','String',mtmParams.tapers(1),'FontSize',fontSizeTiny,'Callback',{@resetMTMParams_Callback}); % initialize TW = 1
% Tapers 'k'
uicontrol('Parent',hTFParamsPanel,'Unit','Normalized', ...
'Position',[xPanel1 (1-3*textHeight-2*tfParamsGap) textWidth textHeight], ...
'Style','text','String','k','FontSize',fontSizeSmall);
hMTMTapersK = uicontrol('Parent',hTFParamsPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[(xPanel1+textWidth) (1-3*textHeight-2*tfParamsGap) textWidth textHeight], ...
'Style','edit','String',mtmParams.tapers(2),'FontSize',fontSizeTiny,'Callback',{@resetMTMParams_Callback}); % initialize k = 1
% Window length
uicontrol('Parent',hTFParamsPanel,'Unit','Normalized', ...
'Position',[xPanel1 (1-4*textHeight-3*tfParamsGap) textWidth textHeight], ...
'Style','text','String','wLen','FontSize',fontSizeSmall);
hMTMwLen = uicontrol('Parent',hTFParamsPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[(xPanel1+textWidth) (1-4*textHeight-3*tfParamsGap) textWidth textHeight], ...
'Style','edit','String',movingWin(1),'FontSize',fontSizeTiny,'Callback',{@resetMTMParams_Callback}); % initialize wLen = 0.1 s
% Window translation step
uicontrol('Parent',hTFParamsPanel,'Unit','Normalized', ...
'Position',[xPanel1 (1-5*textHeight-4*tfParamsGap) textWidth textHeight], ...
'Style','text','String','wStep','FontSize',fontSizeSmall);
hMTMwStep = uicontrol('Parent',hTFParamsPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[(xPanel1+textWidth) (1-5*textHeight-4*tfParamsGap) textWidth textHeight], ...
'Style','edit','String',movingWin(2),'FontSize',fontSizeTiny,'Callback',{@resetMTMParams_Callback}); % initialize wStep = 0.01 s
%----MP parameters-----
% number of atoms for reconstruction
uicontrol('Parent',hTFParamsPanel,'Unit','Normalized', ...
'Position',[xPanel2 (1-textHeight) textWidth textHeight], ...
'Style','text','String','numAtoms MP','FontSize',fontSizeSmall);
hMPnumAtoms = uicontrol('Parent',hTFParamsPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[(xPanel2+textWidth) (1-textHeight) textWidth textHeight], ...
'Style','edit','String',numAtomsMP,'FontSize',fontSizeTiny,'Callback',{@resetMPParams_Callback}); % initialize numAtoms = 100
% analyze baseline and stimulus epochs separately and compare
mpAnalyzeEpochs = 1;
hMPAnalyzeEpochs = uicontrol('Parent',hTFParamsPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, ...
'Position',[xPanel2 (1-2*textHeight) textWidth textHeight], ...
'Style','checkbox','String','analyzeEpochs','FontSize',fontSizeSuperTiny, 'Callback',{@resetMPParamsEpoch_Callback});
%----HHT parameters-----
uicontrol('Parent',hTFParamsPanel,'Unit','Normalized', ...
'Position',[xPanel2 (1-3*textHeight) 2*textWidth textHeight], ...
'Style','text','String','HHT parameters','FontSize',fontSizeSmall);
% Noise ratio
uicontrol('Parent',hTFParamsPanel,'Unit','Normalized', ...
'Position',[xPanel2 (1-4*textHeight) textWidth textHeight], ...
'Style','text','String','Noise ratio','FontSize',fontSizeTiny);
hHHTnstd = uicontrol('Parent',hTFParamsPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[(xPanel2+textWidth) (1-4*textHeight) textWidth textHeight], ...
'Style','edit','String',Nstd,'FontSize',fontSizeTiny,'Callback',{@resetHHTParams_Callback}); % initialize Nstd = 0
% Ensemble number
uicontrol('Parent',hTFParamsPanel,'Unit','Normalized', ...
'Position',[xPanel2 (1-5*textHeight) textWidth textHeight], ...
'Style','text','String','Ensemble number','FontSize',fontSizeTiny);
hHHTne = uicontrol('Parent',hTFParamsPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[(xPanel2+textWidth) (1-5*textHeight) textWidth textHeight], ...
'Style','edit','String',NE,'FontSize',fontSizeTiny,'Callback',{@resetHHTParams_Callback}); % initialize Nstd = 0
% Gaussian filtering
uicontrol('Parent',hTFParamsPanel,'Unit','Normalized', ...
'Position',[xPanel2 (1-6*textHeight) textWidth textHeight], ...
'Style','text','String','Gaussian filter','FontSize',fontSizeTiny);
hHHTgaussFtr = uicontrol('Parent',hTFParamsPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[(xPanel2+textWidth) (1-6*textHeight) textWidth textHeight], ...
'Style','edit','String',gaussFtr,'FontSize',fontSizeTiny,'Callback',{@resetHHTParams_Callback}); % initialize Nstd = 0
%========= Plotting settings ==============================
hTFPlotSettingsPanel = uipanel('Title','TF Plot settings','fontSize', fontSizeMedium, ...
'Unit','Normalized','Position',[(tfParamsPanelxStart+(tfParamsWidth/2)+xGap) (tfParamsPanelyStart) ((tfParamsWidth/2)-xGap) tfParamsPanelHeight]);
% pcolor or imagesc or raw
uicontrol('Parent',hTFPlotSettingsPanel,'Unit','Normalized', ...
'Position',[xPanel1 (1-textHeight) 2*textWidth textHeight], ...
'Style','text','String','Plot style','FontSize',fontSizeSmall);
hTFPlotStyle = uicontrol('Parent',hTFPlotSettingsPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[(xPanel1+2*textWidth) (1-textHeight) 2*textWidth textHeight], ...
'Style','pop','String','pcolor|imagesc|line','FontSize',fontSizeTiny,'Callback',{@resetTFSettings_Callback}); % initialize style = pcolor
% spectrum type: raw or difference (change from baseline)
uicontrol('Parent',hTFPlotSettingsPanel,'Unit','Normalized', ...
'Position',[xPanel1 (1-2*textHeight-tfParamsGap) 2*textWidth textHeight], ...
'Style','text','String','Spectrum type','FontSize',fontSizeSmall);
hTFSpectrumType = uicontrol('Parent',hTFPlotSettingsPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[(xPanel1+2*textWidth) (1-2*textHeight-tfParamsGap) 2*textWidth textHeight], ...
'Style','pop','String','raw|difference','FontSize',fontSizeTiny,'Callback',{@resetTFSettings_Callback}); % initialize style = pcolor
% color axis settings
uicontrol('Parent',hTFPlotSettingsPanel,'Unit','Normalized', ...
'Position',[xPanel1 (1-3*textHeight-2*tfParamsGap) textWidth textHeight], ...
'Style','text','String','cmin','FontSize',fontSizeSmall);
hTFcmin = uicontrol('Parent',hTFPlotSettingsPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[(xPanel1+textWidth) (1-3*textHeight-2*tfParamsGap) textWidth textHeight], ...
'Style','edit','String',cmin,'FontSize',fontSizeTiny,'Callback',{@rescaleCaxis_Callback}); % initialize cmin = -1
uicontrol('Parent',hTFPlotSettingsPanel,'Unit','Normalized', ...
'Position',[xPanel2 (1-3*textHeight-2*tfParamsGap) textWidth textHeight], ...
'Style','text','String','cmax','FontSize',fontSizeSmall);
hTFcmax = uicontrol('Parent',hTFPlotSettingsPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...
[(xPanel2+textWidth) (1-3*textHeight-2*tfParamsGap) textWidth textHeight], ...
'Style','edit','String',cmax,'FontSize',fontSizeTiny,'Callback',{@rescaleCaxis_Callback}); % initialize cmax = 3
% Method used
uicontrol('Parent',hTFPlotSettingsPanel,'Unit','Normalized', ...
'Position',[xPanel1 (1-5*textHeight-4*tfParamsGap) 2*textWidth 1.5*textHeight], ...
'Style','text','String','Method','FontSize',fontSizeMedium);
hTFPlotMethod = uicontrol('Parent',hTFPlotSettingsPanel,'Unit','Normalized', ...
'BackgroundColor', backgroundColor, 'Position', ...