-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCRSMap.m
1179 lines (1018 loc) · 48.4 KB
/
CRSMap.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
//
// CRSMap.m
// CRSMap
//
// Copyright 2006. All rights reserved.
//
#import "CRS.h"
#import "CRSMap.h"
#import "CRSSummaryController.h"
#import "CRSBehaviorController.h"
#import "CRSSpikeController.h"
#import "CRSXTController.h"
#import "UtilityFunctions.h"
#import "CRSStimuli.h"
#import "CRSMapStimTable.h"
#define kRewardBit 0x0001
// Behavioral parameters
NSString *CRSAcquireMSKey = @"CRSAcquireMS";
NSString *CRSAlphaTargetDetectionTaskKey = @"CRSAlphaTargetDetectionTask";
NSString *CRSBlockLimitKey = @"CRSBlockLimit";
NSString *CRSBreakPunishMSKey = @"CRSBreakPunishMS";
NSString *CRSChangeScaleKey = @"CRSChangeScale";
NSString *CRSCatchTrialPCKey = @"CRSCatchTrialPC";
NSString *CRSCatchTrialMaxPCKey = @"CRSCatchTrialMaxPC";
NSString *CRSCueMSKey = @"CRSCueMS";
NSString *CRSDoSoundsKey = @"CRSDoSounds";
NSString *CRSEyeFilterWeightKey = @"CRSEyeFilterWeight";
NSString *CRSFixateKey = @"CRSFixate";
NSString *CRSFixateMSKey = @"CRSFixateMS";
NSString *CRSFixateOnlyKey = @"CRSFixateOnly";
NSString *CRSFixGraceMSKey = @"CRSFixGraceMS";
NSString *CRSFixJitterPCKey = @"CRSFixJitterPC";
NSString *CRSFixWindowWidthDegKey = @"CRSFixWindowWidthDeg";
NSString *CRSInstructionTrialsKey = @"CRSInstructionTrials";
NSString *CRSIntertrialMSKey = @"CRSIntertrialMS";
NSString *CRSInvalidRewardFactorKey = @"CRSInvalidRewardFactor";
NSString *CRSMinTargetMSKey = @"CRSMinTargetMS";
NSString *CRSMaxTargetMSKey = @"CRSMaxTargetMS";
NSString *CRSMeanTargetMSKey = @"CRSMeanTargetMS";
NSString *CRSNontargetContrastPCKey = @"CRSNontargetContrastPC";
NSString *CRSRespSpotSizeDegKey = @"CRSRespSpotSizeDeg";
NSString *CRSRespTimeMSKey = @"CRSRespTimeMS";
NSString *CRSRespWindowWidthDegKey = @"CRSRespWindowWidthDeg";
NSString *CRSRewardMSKey = @"CRSRewardMS";
NSString *CRSMinRewardMSKey = @"CRSMinRewardMS";
NSString *CRSRandTaskGaborDirectionKey = @"CRSRandTaskGaborDirection";
NSString *CRSRewardScheduleKey = @"CRSRewardSchedule";
NSString *CRSSaccadeTimeMSKey = @"CRSSaccadeTimeMS";
NSString *CRSStimRepsPerBlockKey = @"CRSStimRepsPerBlock";
NSString *CRSStimDistributionKey = @"CRSStimDistribution";
NSString *CRSTaskStatusKey = @"CRSTaskStatus";
NSString *CRSTooFastMSKey = @"CRSTooFastMS";
// Stimulus Parameters
NSString *CRSInterstimJitterPCKey = @"CRSInterstimJitterPC";
NSString *CRSInterstimMSKey = @"CRSInterstimMS";
NSString *CRSMapInterstimDurationMSKey = @"CRSMapInterstimDurationMS";
NSString *CRSMappingBlocksKey = @"CRSMappingBlocks";
NSString *CRSMapStimDurationMSKey = @"CRSMapStimDurationMS";
NSString *CRSStimDurationMSKey = @"CRSStimDurationMS";
NSString *CRSStimJitterPCKey = @"CRSStimJitterPC";
NSString *CRSOrientationChangesKey = @"CRSOrientationChanges";
NSString *CRSMaxDirChangeDegKey = @"CRSMaxDirChangeDeg";
NSString *CRSMinDirChangeDegKey = @"CRSMinDirChangeDeg";
NSString *CRSChangeRemainKey = @"CRSChangeRemain";
NSString *CRSChangeArrayKey = @"CRSChangeArray";
NSString *CRSStimTablesKey = @"CRSStimTables";
NSString *CRSStimTableCountsKey = @"CRSStimTableCounts";
NSString *CRSMapStimContrastPCKey = @"CRSMapStimContrastPC";
NSString *CRSMapStimRadiusSigmaRatioKey = @"CRSMapStimRadiusSigmaRatio";
NSString *CRSTargetAlphaKey = @"CRSTargetAlpha";
NSString *CRSTargetRadiusKey = @"CRSTargetRadius";
// [Vinay] - have replaced the L and R keys with C,R,S keys
//NSString *CRSHideLeftKey = @"CRSHideLeft";
//NSString *CRSHideRightKey = @"CRSHideRight";
//NSString *CRSHideLeftDigitalKey = @"CRSHideLeftDigital";
//NSString *CRSHideRightDigitalKey = @"CRSHideRightDigital";
NSString *CRSHideCentreKey = @"CRSHideCentre";
NSString *CRSHideRingKey = @"CRSHideRing";
NSString *CRSHideSurroundKey = @"CRSHideSurround";
NSString *CRSHideCentreDigitalKey = @"CRSHideCentreDigital";
NSString *CRSHideRingDigitalKey = @"CRSHideRingDigital";
NSString *CRSHideSurroundDigitalKey = @"CRSHideSurroundDigital";
// [Vinay] - till here
NSString *CRSConvertToGratingKey = @"CRSConvertToGrating";
NSString *CRSUseSingleITC18Key = @"CRSUseSingleITC18";
NSString *CRSUseFewDigitalCodesKey = @"CRSUseFewDigitalCodes";
NSString *CRSHideTaskGaborKey = @"CRSHideTaskGabor";
NSString *CRSIncludeCatchTrialsinDoneListKey = @"CRSIncludeCatchTrialsinDoneList";
NSString *CRSMapTemporalModulationKey = @"CRSMapTemporalModulation";
// Visual Stimulus Parameters
NSString *CRSSpatialPhaseDegKey = @"CRSSpatialPhaseDeg"; // [Vinay] - This was commented. I have uncommented it
NSString *CRSTemporalFreqHzKey = @"CRSTemporalFreqHz"; // [Vinay] - This was commented. I have uncommented it
// [Vinay] - added the following for protocol related keys
NSString *CRSMatchCentreSurroundKey = @"CRSMatchCentreSurround"; // [Vinay] - whenever one wants to match the centre and surround properties
/*
NSString *CRSRingProtocolKey = @"CRSRingProtocol";
NSString *CRSContrastRingProtocolKey = @"CRSContrastRingProtocol";
NSString *CRSDualContrastProtocolKey = @"CRSDualContrastProtocol";
NSString *CRSDualOrientationProtocolKey = @"CRSDualOrientationProtocol";
NSString *CRSDualPhaseProtocolKey = @"CRSDualPhaseProtocol";
*/ // [Vinay] - have commented these, since there aren't required
// [Vinay] - Exploring defining the protocol selection as a pop down menu, so that each is selected exclusively
NSString *CRSProtocolNumberKey = @"CRSProtocolNumber";
// [Vinay] Adding other matching options now
NSString *CRSMatchCentreRingKey = @"CRSMatchCentreRing";
NSString *CRSMatchRingSurroundKey = @"CRSMatchRingSurround";
// [Vinay] Adding an option of showing an image centrally
NSString *CRSFixImageKey = @"CRSFixImage";
// [Vinay] - to decide the mapping method for radius
NSString *CRSMapRadiusMappingCentreKey = @"CRSMapRadiusMappingCentre";
NSString *CRSMapRadiusMappingRingKey = @"CRSMapRadiusMappingRing";
NSString *CRSMapRadiusMappingSurroundKey = @"CRSMapRadiusMappingSurround";
// [Vinay] - to decide the mapping method for contrast
NSString *CRSMapContrastMappingCentreKey = @"CRSMapContrastMappingCentre";
NSString *CRSMapContrastMappingRingKey = @"CRSMapContrastMappingRing";
NSString *CRSMapContrastMappingSurroundKey = @"CRSMapContrastMappingSurround";
// [Vinay] - to decide the mapping method for SF
NSString *CRSMapSFMappingCentreKey = @"CRSMapSFMappingCentre";
NSString *CRSMapSFMappingRingKey = @"CRSMapSFMappingRing";
NSString *CRSMapSFMappingSurroundKey = @"CRSMapSFMappingSurround";
// [Vinay] - to decide the mapping method for TF
NSString *CRSMapTFMappingCentreKey = @"CRSMapTFMappingCentre";
NSString *CRSMapTFMappingRingKey = @"CRSMapTFMappingRing";
NSString *CRSMapTFMappingSurroundKey = @"CRSMapTFMappingSurround";
// [Vinay] - to opt color stimuli
NSString *CRSConvertToColorKey = @"CRSConvertToColor";
// [Vinay] - till here
// Keys for change array
NSString *CRSChangeKey = @"change";
NSString *CRSValidRepsKey = @"validReps";
NSString *CRSInvalidRepsKey = @"invalidReps";
NSString *keyPaths[] = {@"values.CRSBlockLimit", @"values.CRSRespTimeMS",
@"values.CRSStimTableCounts", @"values.CRSStimTables",
@"values.CRSStimDurationMS", @"values.CRSMapStimDurationMS", @"values.CRSMapInterstimDurationMS",
@"values.CRSInterstimMS", @"values.CRSOrientationChanges", @"values.CRSMappingBlocks",
@"values.CRSMinDirChangeDeg", @"values.CRSMaxDirChangeDeg", @"values.CRSStimRepsPerBlock",
@"values.CRSMinTargetMS", @"values.CRSMaxTargetMS", @"values.CRSChangeArray",
@"values.CRSChangeScale", @"values.CRSMeanTargetMS", @"values.CRSFixateMS",
@"values.CRSMapStimRadiusSigmaRatio",@"values.CRSHideTaskGabor",@"values.CRSHideCentre",@"values.CRSHideRing",@"values.CRSHideSurround",
@"values.CRSMatchCentreSurround",@"values.CRSMatchCentreRing",@"values.CRSMatchRingSurround",@"values.CRSFixImage",
@"values.CRSEyeFilterWeight",
nil}; // [Vinay] - have added the last 2 lines before nil - related to matching C and S and the protocol
// [Vinay] - Later removed. Added @"values.CRSMatchCentreRing",@"values.CRSMatchRingSurround",
//"values.CRSMatchCentreRing",@"values.CRSMatchRingSurround",@"values.CRSRingProtocol",@"values.CRSContrastRingProtocol",@"values.CRSDualContrastProtocol",@"values.CRSDualOrientationProtocol",@"values.CRSDualPhaseProtocol",
// and kept only @"values.CRSMatchCentreSurround"
// and replaced Left and right keys - @"values.CRSHideLeft",@"values.CRSHideRight" - with @"values.CRSHideCentre",@"values.CRSHideRing",@"values.CRSHideSurround",
// Added - @"values.CRSFixImage",
LLScheduleController *scheduler = nil;
CRSStimuli *stimuli = nil;
CRSDigitalOut *digitalOut = nil;
LLDataDef gaborStructDef[] = kLLGaborEventDesc;
LLDataDef fixWindowStructDef[] = kLLEyeWindowEventDesc;
LLDataDef blockStatusDef[] = {
{@"long", @"changes", 1, offsetof(BlockStatus, changes)},
{@"float", @"orientationChangeDeg", kMaxOriChanges, offsetof(BlockStatus, orientationChangeDeg)},
{@"long", @"validReps", kMaxOriChanges, offsetof(BlockStatus, validReps)},
{@"long", @"validRepsDone", kMaxOriChanges, offsetof(BlockStatus, validRepsDone)},
{@"long", @"invalidReps", kMaxOriChanges, offsetof(BlockStatus, invalidReps)},
{@"long", @"invalidRepsDone", kMaxOriChanges, offsetof(BlockStatus, invalidRepsDone)},
{@"long", @"instructDone", 1, offsetof(BlockStatus, instructDone)},
{@"long", @"instructTrials", 1, offsetof(BlockStatus, instructTrials)},
{@"long", @"sidesDone", 1, offsetof(BlockStatus, sidesDone)},
{@"long", @"blockLimit", 1, offsetof(BlockStatus, blockLimit)},
{@"long", @"blocksDone", 1, offsetof(BlockStatus, blocksDone)},
{nil}};
LLDataDef mappingBlockStatusDef[] = {
{@"long", @"stimDone", 1, offsetof(MappingBlockStatus, stimDone)},
{@"long", @"stimLimit", 1, offsetof(MappingBlockStatus, stimLimit)},
{@"long", @"blocksDone", 1, offsetof(MappingBlockStatus, blocksDone)},
{@"long", @"blockLimit", 1, offsetof(MappingBlockStatus, blockLimit)},
{nil}};
LLDataDef stimDescDef[] = {
{@"long", @"gaborIndex", 1, offsetof(StimDesc, gaborIndex)},
{@"long", @"sequenceIndex", 1, offsetof(StimDesc, sequenceIndex)},
{@"long", @"stimOnFrame", 1, offsetof(StimDesc, stimOnFrame)},
{@"long", @"stimOffFrame", 1, offsetof(StimDesc, stimOffFrame)},
{@"short", @"stimType", 1, offsetof(StimDesc, stimType)},
{@"float", @"orientationChangeDeg", 1, offsetof(StimDesc, orientationChangeDeg)},
{@"float", @"contrastPC", 1, offsetof(StimDesc, contrastPC)},
{@"float", @"azimuthDeg", 1, offsetof(StimDesc, azimuthDeg)},
{@"float", @"elevationDeg", 1, offsetof(StimDesc, elevationDeg)},
{@"float", @"sigmaDeg", 1, offsetof(StimDesc, sigmaDeg)},
{@"float", @"radiusDeg", 1, offsetof(StimDesc, radiusDeg)}, // [Vinay] - for the added parameter
{@"float", @"spatialFreqCPD", 1, offsetof(StimDesc, spatialFreqCPD)},
{@"float", @"directionDeg", 1, offsetof(StimDesc, directionDeg)},
{@"float", @"temporalFreqHz", 1, offsetof(StimDesc, temporalFreqHz)},
{@"float", @"spatialPhaseDeg", 1, offsetof(StimDesc, spatialPhaseDeg)}, // [Vinay] - for the added parameter
{@"long", @"azimuthIndex", 1, offsetof(StimDesc, azimuthIndex)},
{@"long", @"elevationIndex", 1, offsetof(StimDesc, elevationIndex)},
{@"long", @"sigmaIndex", 1, offsetof(StimDesc, sigmaIndex)},
{@"long", @"spatialFreqIndex", 1, offsetof(StimDesc, spatialFreqIndex)},
{@"long", @"directionIndex", 1, offsetof(StimDesc, directionIndex)},
{@"long", @"contrastIndex", 1, offsetof(StimDesc, contrastIndex)},
{@"long", @"temporalFreqIndex", 1, offsetof(StimDesc, temporalFreqIndex)},
{@"long", @"temporalModulation", 1, offsetof(StimDesc, temporalModulation)},
{@"long", @"radiusIndex", 1, offsetof(StimDesc, radiusIndex)}, // [Vinay] - for the added parameter
{@"long", @"spatialPhaseIndex", 1, offsetof(StimDesc, spatialPhaseIndex)}, // [Vinay] - for the added parameter
{nil}};
LLDataDef trialDescDef[] = {
{@"boolean",@"instructTrial", 1, offsetof(TrialDesc, instructTrial)},
{@"boolean",@"catchTrial", 1, offsetof(TrialDesc, catchTrial)},
{@"long", @"numStim", 1, offsetof(TrialDesc, numStim)},
{@"long", @"targetIndex", 1, offsetof(TrialDesc, targetIndex)},
{@"long", @"targetOnTimeMS", 1, offsetof(TrialDesc, targetOnTimeMS)},
{@"long", @"orientationChangeIndex", 1, offsetof(TrialDesc, orientationChangeIndex)},
{@"float", @"orientationChangeDeg", 1, offsetof(TrialDesc, orientationChangeDeg)},
{nil}};
LLDataDef behaviorSettingDef[] = {
{@"long", @"blocks", 1, offsetof(BehaviorSetting, blocks)},
{@"long", @"intertrialMS", 1, offsetof(BehaviorSetting, intertrialMS)},
{@"long", @"acquireMS", 1, offsetof(BehaviorSetting, acquireMS)},
{@"long", @"fixGraceMS", 1, offsetof(BehaviorSetting, fixGraceMS)},
{@"long", @"fixateMS", 1, offsetof(BehaviorSetting, fixateMS)},
{@"long", @"fixateJitterPC", 1, offsetof(BehaviorSetting, fixateJitterPC)},
{@"long", @"responseTimeMS", 1, offsetof(BehaviorSetting, responseTimeMS)},
{@"long", @"tooFastMS", 1, offsetof(BehaviorSetting, tooFastMS)},
{@"long", @"minSaccadeDurMS", 1, offsetof(BehaviorSetting, minSaccadeDurMS)},
{@"long", @"breakPunishMS", 1, offsetof(BehaviorSetting, breakPunishMS)},
{@"long", @"rewardSchedule", 1, offsetof(BehaviorSetting, rewardSchedule)},
{@"long", @"rewardMS", 1, offsetof(BehaviorSetting, rewardMS)},
{@"float", @"fixWinWidthDeg", 1, offsetof(BehaviorSetting, fixWinWidthDeg)},
{@"float", @"respWinWidthDeg", 1, offsetof(BehaviorSetting, respWinWidthDeg)},
{nil}};
LLDataDef stimSettingDef[] = {
{@"long", @"stimDurationMS", 1, offsetof(StimSetting, stimDurationMS)},
{@"long", @"stimDurJitterPC", 1, offsetof(StimSetting, stimDurJitterPC)},
{@"long", @"interStimMS", 1, offsetof(StimSetting, interStimMS)},
{@"long", @"interStimJitterPC", 1, offsetof(StimSetting, interStimJitterPC)},
{@"long", @"stimLeadMS", 1, offsetof(StimSetting, stimLeadMS)},
{@"float", @"stimSpeedHz", 1, offsetof(StimSetting, stimSpeedHz)},
{@"long", @"stimDistribution", 1, offsetof(StimSetting, stimDistribution)},
{@"long", @"minTargetOnTimeMS", 1, offsetof(StimSetting, minTargetOnTimeMS)},
{@"long", @"meanTargetOnTimeMS", 1, offsetof(StimSetting, meanTargetOnTimeMS)},
{@"long", @"maxTargetOnTimeMS", 1, offsetof(StimSetting, maxTargetOnTimeMS)},
{@"float", @"eccentricityDeg", 1, offsetof(StimSetting, eccentricityDeg)},
{@"float", @"polarAngleDeg", 1, offsetof(StimSetting, polarAngleDeg)},
{@"float", @"driftDirectionDeg", 1, offsetof(StimSetting, driftDirectionDeg)},
{@"float", @"contrastPC", 1, offsetof(StimSetting, contrastPC)},
{@"short", @"numberOfSurrounds", 1, offsetof(StimSetting, numberOfSurrounds)}, // [Vinay] - what's this?. check!
{@"long", @"changeScale", 1, offsetof(StimSetting, changeScale)},
{@"long", @"orientationChanges", 1, offsetof(StimSetting, orientationChanges)},
{@"float", @"maxChangeDeg", 1, offsetof(StimSetting, maxChangeDeg)},
{@"float", @"minChangeDeg", 1, offsetof(StimSetting, minChangeDeg)},
{@"long", @"changeRemains", 1, offsetof(StimSetting, changeRemains)},
{nil}};
LLDataDef mapParamsDef[] = {
{@"long", @"n", 1, offsetof(MapParams, n)},
{@"float", @"minValue", 1, offsetof(MapParams, minValue)},
{@"float", @"maxValue", 1, offsetof(MapParams, maxValue)},
{nil}};
LLDataDef mapSettingsDef[] = {
{@"struct", @"azimuthDeg", 1, offsetof(MapSettings, azimuthDeg), sizeof(MapParams), mapParamsDef},
{@"struct", @"elevationDeg", 1, offsetof(MapSettings, elevationDeg), sizeof(MapParams), mapParamsDef},
{@"struct", @"directionDeg", 1, offsetof(MapSettings, directionDeg), sizeof(MapParams), mapParamsDef},
{@"struct", @"spatialFreqCPD", 1, offsetof(MapSettings, spatialFreqCPD), sizeof(MapParams), mapParamsDef},
{@"struct", @"sigmaDeg", 1, offsetof(MapSettings, sigmaDeg), sizeof(MapParams), mapParamsDef},
{@"struct", @"contrastPC", 1, offsetof(MapSettings, contrastPC), sizeof(MapParams), mapParamsDef},
{@"struct", @"temporalFreqHz", 1, offsetof(MapSettings, temporalFreqHz), sizeof(MapParams), mapParamsDef},
{@"struct", @"radiusDeg", 1, offsetof(MapSettings, radiusDeg), sizeof(MapParams), mapParamsDef}, // [Vinay] - for the added parameter
{@"struct", @"spatialPhaseDeg", 1, offsetof(MapSettings, spatialPhaseDeg), sizeof(MapParams), mapParamsDef}, // [Vinay] - for the added parameter
{nil}};
//DataAssignment eyeXDataAssignment = {@"eyeXData", @"Synthetic", 0, 5.0};
//DataAssignment eyeYDataAssignment = {@"eyeYData", @"Synthetic", 1, 5.0};
DataAssignment eyeRXDataAssignment = {@"eyeRXData", @"Synthetic", 2, 5.0};
DataAssignment eyeRYDataAssignment = {@"eyeRYData", @"Synthetic", 3, 5.0};
DataAssignment eyeRPDataAssignment = {@"eyeRPData", @"Synthetic", 4, 5.0};
DataAssignment eyeLXDataAssignment = {@"eyeLXData", @"Synthetic", 5, 5.0};
DataAssignment eyeLYDataAssignment = {@"eyeLYData", @"Synthetic", 6, 5.0};
DataAssignment eyeLPDataAssignment = {@"eyeLPData", @"Synthetic", 7, 5.0};
DataAssignment spike0Assignment = {@"spike0", @"Synthetic", 2, 1};
DataAssignment spike1Assignment = {@"spike1", @"Synthetic", 3, 1};
DataAssignment VBLDataAssignment = {@"VBLData", @"Synthetic", 1, 1};
EventDefinition CRSEvents[] = {
// recorded at start of file, these need to be announced using announceEvents() in UtilityFunctions.m
{@"taskGabor", sizeof(Gabor), {@"struct", @"taskGabor", 1, 0, sizeof(Gabor), gaborStructDef}},
{@"mappingGabor0", sizeof(Gabor), {@"struct", @"mappingGabor0", 1, 0, sizeof(Gabor), gaborStructDef}},
{@"mappingGabor1", sizeof(Gabor), {@"struct", @"mappingGabor1", 1, 0, sizeof(Gabor), gaborStructDef}},
{@"mappingGabor2", sizeof(Gabor), {@"struct", @"mappingGabor2", 1, 0, sizeof(Gabor), gaborStructDef}}, // [Vinay] - for the centre gabor
{@"behaviorSetting", sizeof(BehaviorSetting),{@"struct", @"behaviorSetting", 1, 0, sizeof(BehaviorSetting), behaviorSettingDef}},
{@"stimSetting", sizeof(StimSetting), {@"struct", @"stimSetting", 1, 0, sizeof(StimSetting), stimSettingDef}},
{@"map0Settings", sizeof(MapSettings), {@"struct", @"mapSettings", 1, 0, sizeof(MapSettings), mapSettingsDef}},
{@"map1Settings", sizeof(MapSettings), {@"struct", @"mapSettings", 1, 0, sizeof(MapSettings), mapSettingsDef}},
{@"map2Settings", sizeof(MapSettings), {@"struct", @"mapSettings", 1, 0, sizeof(MapSettings), mapSettingsDef}}, // [Vinay] - for the centre gabor
{@"eccentricityDeg", sizeof(float), {@"float"}},
{@"polarAngleDeg", sizeof(float), {@"float"}},
{@"protocolNumber", sizeof(long), {@"long"}},//[Vinay] - to record the protocolNumber
// timing parameters
{@"stimDurationMS", sizeof(long), {@"long"}},
{@"interstimMS", sizeof(long), {@"long"}},
{@"mapStimDurationMS", sizeof(long), {@"long"}},
{@"mapInterstimDurationMS", sizeof(long), {@"long"}},
{@"stimLeadMS", sizeof(long), {@"long"}},
{@"responseTimeMS", sizeof(long), {@"long"}},
{@"fixateMS", sizeof(long), {@"long"}},
{@"tooFastTimeMS", sizeof(long), {@"long"}},
{@"blockStatus", sizeof(BlockStatus), {@"struct", @"blockStatus", 1, 0, sizeof(BlockStatus), blockStatusDef}},
{@"mappingBlockStatus", sizeof(MappingBlockStatus), {@"struct", @"mappingBlockStatus", 1, 0, sizeof(MappingBlockStatus), mappingBlockStatusDef}},
{@"meanTargetTimeMS", sizeof(long), {@"long"}},
{@"minTargetTimeMS", sizeof(long), {@"long"}},
{@"maxTargetTimeMS", sizeof(long), {@"long"}},
// declared at start of each trial
{@"trial", sizeof(TrialDesc), {@"struct", @"trial", 1, 0, sizeof(TrialDesc), trialDescDef}},
{@"responseWindow", sizeof(FixWindowData), {@"struct", @"responseWindowData", 1, 0, sizeof(FixWindowData), fixWindowStructDef}},
// marking the course of each trial
{@"preStimuli", 0, {@"no data"}},
{@"stimulus", sizeof(StimDesc), {@"struct", @"stimDesc", 1, 0, sizeof(StimDesc), stimDescDef}},
{@"stimulusOffTime", 0, {@"no data"}},
{@"stimulusOnTime", 0, {@"no data"}},
{@"postStimuli", 0, {@"no data"}},
{@"saccade", 0, {@"no data"}},
{@"tooFast", 0, {@"no data"}},
{@"react", 0, {@"no data"}},
{@"fixGrace", 0, {@"no data"}},
{@"myTrialEnd", sizeof(long), {@"long"}},
{@"taskMode", sizeof(long), {@"long"}},
{@"reset", sizeof(long), {@"long"}},
};
BlockStatus blockStatus;
MappingBlockStatus mappingBlockStatus;
BOOL brokeDuringStim;
LLTaskPlugIn *task = nil;
long trialCounter;
@implementation CRSMap
+ (NSInteger)version;
{
return kLLPluginVersion;
}
// Start the method that will collect data from the event buffer
- (void)activate;
{
long longValue;
NSMenu *mainMenu;
if (active) {
return;
}
// Insert Actions and Settings menus into menu bar
mainMenu = [NSApp mainMenu];
[mainMenu insertItem:actionsMenuItem atIndex:([mainMenu indexOfItemWithTitle:@"Tasks"] + 1)];
[mainMenu insertItem:settingsMenuItem atIndex:([mainMenu indexOfItemWithTitle:@"Tasks"] + 1)];
// Make sure that the task status is in the right state
[taskStatus setMode:kTaskIdle];
[taskStatus setDataFileOpen:NO];
// Erase the stimulus display
[stimuli erase];
mapStimTable0 = [[CRSMapStimTable alloc] initWithIndex:0];
mapStimTable1 = [[CRSMapStimTable alloc] initWithIndex:1];
mapStimTable2 = [[CRSMapStimTable alloc] initWithIndex:2]; // [Vinay] - for centre gabor
// Create on-line display windows
[[controlPanel window] orderFront:self];
behaviorController = [[CRSBehaviorController alloc] init];
[dataDoc addObserver:behaviorController];
spikeController = [[CRSSpikeController alloc] init];
[dataDoc addObserver:spikeController];
eyeXYController = [[CRSEyeXYController alloc] init];
[dataDoc addObserver:eyeXYController];
summaryController = [[CRSSummaryController alloc] init];
[dataDoc addObserver:summaryController];
xtController = [[CRSXTController alloc] init];
[dataDoc addObserver:xtController];
// Set up data events (after setting up windows to receive them)
[dataDoc defineEvents:[LLStandardDataEvents eventsWithDataDefs] count:[LLStandardDataEvents countOfEventsWithDataDefs]];
[dataDoc defineEvents:CRSEvents count:(sizeof(CRSEvents) / sizeof(EventDefinition))];
announceEvents();
longValue = 0;
[[task dataDoc] putEvent:@"reset" withData:&longValue];
// Set up the data collector to handle our data types
[dataController assignSampleData:eyeRXDataAssignment];
[dataController assignSampleData:eyeRYDataAssignment];
[dataController assignSampleData:eyeRPDataAssignment];
[dataController assignSampleData:eyeLXDataAssignment];
[dataController assignSampleData:eyeLYDataAssignment];
[dataController assignSampleData:eyeLPDataAssignment];
[dataController assignTimestampData:spike0Assignment];
[dataController assignTimestampData:spike1Assignment];
[dataController assignTimestampData:VBLDataAssignment];
[dataController assignDigitalInputDevice:@"Synthetic"];
[dataController assignDigitalOutputDevice:@"Synthetic"];
xFilter = [[LLFilterExp alloc] init];
[xFilter setStepWeight:(1.0 - [defaults floatForKey:CRSEyeFilterWeightKey])];
yFilter = [[LLFilterExp alloc] init];
[yFilter setStepWeight:(1.0 - [defaults floatForKey:CRSEyeFilterWeightKey])];
collectorTimer = [NSTimer scheduledTimerWithTimeInterval:0.004 target:self
selector:@selector(dataCollect:) userInfo:nil repeats:YES];
[dataDoc addObserver:stateSystem];
[stateSystem startWithCheckIntervalMS:5]; // Start the experiment state system
active = YES;
}
// The following function is called after the nib has finished loading. It is the correct
// place to initialize nib related components, such as menus.
- (void)awakeFromNib;
{
if (actionsMenuItem == nil) {
actionsMenuItem = [[NSMenuItem alloc] init];
[actionsMenu setTitle:@"Actions"];
[actionsMenuItem setSubmenu:actionsMenu];
[actionsMenuItem setEnabled:YES];
}
if (settingsMenuItem == nil) {
settingsMenuItem = [[NSMenuItem alloc] init];
[settingsMenu setTitle:@"Settings"];
[settingsMenuItem setSubmenu:settingsMenu];
[settingsMenuItem setEnabled:YES];
}
}
- (void)dataCollect:(NSTimer *)timer;
{
long spikeIndex, spikes;
short *spikePtr;
NSData *data;
TimestampData spikeData;
// if ((data = [dataController dataOfType:@"eyeXData"]) != nil) {
// [dataDoc putEvent:@"eyeXData" withData:(Ptr)[data bytes] lengthBytes:[data length]];
// currentEyeUnits.x = *(short *)([data bytes] + [data length] - sizeof(short));
// }
// if ((data = [dataController dataOfType:@"eyeYData"]) != nil) {
// [dataDoc putEvent:@"eyeYData" withData:(Ptr)[data bytes] lengthBytes:[data length]];
// currentEyeUnits.y = *(short *)([data bytes] + [data length] - sizeof(short));
// currentEyeDeg = [eyeCalibrator degPointFromUnitPoint:currentEyeUnits];
// }
if ((data = [dataController dataOfType:@"eyeLXData"]) != nil) {
data = [xFilter filteredValues:data];
[dataDoc putEvent:@"eyeLXData" withData:(Ptr)[data bytes] lengthBytes:[data length]];
currentEyesUnits[kLeftEye].x = *(short *)([data bytes] + [data length] - sizeof(short));
}
if ((data = [dataController dataOfType:@"eyeLYData"]) != nil) {
data = [yFilter filteredValues:data];
[dataDoc putEvent:@"eyeLYData" withData:(Ptr)[data bytes] lengthBytes:[data length]];
currentEyesUnits[kLeftEye].y = *(short *)([data bytes] + [data length] - sizeof(short));
currentEyesDeg[kLeftEye] = [eyeCalibrator degPointFromUnitPoint: currentEyesUnits[kLeftEye] forEye:kLeftEye];
}
if ((data = [dataController dataOfType:@"eyeLPData"]) != nil) {
[dataDoc putEvent:@"eyeLPData" withData:(Ptr)[data bytes] lengthBytes:[data length]];
}
if ((data = [dataController dataOfType:@"eyeRXData"]) != nil) {
data = [xFilter filteredValues:data];
[dataDoc putEvent:@"eyeRXData" withData:(Ptr)[data bytes] lengthBytes:[data length]];
currentEyesUnits[kRightEye].x = *(short *)([data bytes] + [data length] - sizeof(short));
}
if ((data = [dataController dataOfType:@"eyeRYData"]) != nil) {
data = [yFilter filteredValues:data];
[dataDoc putEvent:@"eyeRYData" withData:(Ptr)[data bytes] lengthBytes:[data length]];
currentEyesUnits[kRightEye].y = *(short *)([data bytes] + [data length] - sizeof(short));
currentEyesDeg[kRightEye] = [eyeCalibrator degPointFromUnitPoint: currentEyesUnits[kRightEye] forEye:kRightEye]; }
if ((data = [dataController dataOfType:@"eyeRPData"]) != nil) {
[dataDoc putEvent:@"eyeRPData" withData:(Ptr)[data bytes] lengthBytes:[data length]];
}
if ((data = [dataController dataOfType:@"VBLData"]) != nil) {
[dataDoc putEvent:@"VBLData" withData:(Ptr)[data bytes] lengthBytes:[data length]];
}
if ((data = [dataController dataOfType:@"spike0"]) != nil) {
spikeData.channel = 0;
spikes = [data length] / sizeof(short);
spikePtr = (short *)[data bytes];
for (spikeIndex = 0; spikeIndex < spikes; spikeIndex++) {
spikeData.time = *spikePtr++;
[dataDoc putEvent:@"spike" withData:(Ptr)&spikeData];
}
}
if ((data = [dataController dataOfType:@"spike1"]) != nil) {
spikeData.channel = 1;
spikes = [data length] / sizeof(short);
spikePtr = (short *)[data bytes];
for (spikeIndex = 0; spikeIndex < spikes; spikeIndex++) {
spikeData.time = *spikePtr++;
[dataDoc putEvent:@"spike" withData:(Ptr)&spikeData];
}
}
}
// Stop data collection and shut down the plug in
- (void)deactivate:(id)sender;
{
if (!active) {
return;
}
[dataController setDataEnabled:[NSNumber numberWithBool:NO]];
[stateSystem stop];
[collectorTimer invalidate];
[xFilter release];
[yFilter release];
[dataDoc removeObserver:stateSystem];
[dataDoc removeObserver:behaviorController];
[dataDoc removeObserver:spikeController];
[dataDoc removeObserver:eyeXYController];
[dataDoc removeObserver:summaryController];
[dataDoc removeObserver:xtController];
[dataDoc clearEventDefinitions];
// Remove Actions and Settings menus from menu bar
[[NSApp mainMenu] removeItem:settingsMenuItem];
[[NSApp mainMenu] removeItem:actionsMenuItem];
// Release all the display windows
[behaviorController close];
[behaviorController release];
[spikeController close];
[spikeController release];
[eyeXYController deactivate]; // requires a special call
[eyeXYController release];
[summaryController close];
[summaryController release];
[xtController close];
[xtController release];
[[controlPanel window] close];
active = NO;
}
- (void)dealloc;
{
long index;
while ([stateSystem running]) {}; // wait for state system to stop, then release it
for (index = 0; keyPaths[index] != nil; index++) {
[[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:keyPaths[index]];
}
[[NSNotificationCenter defaultCenter] removeObserver:self];
[[task dataDoc] removeObserver:stateSystem];
[stateSystem release];
[actionsMenuItem release];
[settingsMenuItem release];
[scheduler release];
[stimuli release];
[mapStimTable0 release];
[mapStimTable1 release];
[mapStimTable2 release]; // [Vinay] - for centre gabor
[digitalOut release];
[controlPanel release];
[taskStatus release];
[topLevelObjects release];
[super dealloc];
}
- (void)doControls:(NSNotification *)notification;
{
if ([[notification name] isEqualToString:LLTaskModeButtonKey]) {
[self doRunStop:self];
}
else if ([[notification name] isEqualToString:LLJuiceButtonKey]) {
[self doJuice:self];
}
if ([[notification name] isEqualToString:LLResetButtonKey]) {
[self doReset:self];
}
}
- (IBAction)doFixSettings:(id)sender;
{
[stimuli doFixSettings];
}
- (IBAction)doJuice:(id)sender;
{
long juiceMS, rewardSchedule;
long minTargetMS, maxTargetMS;
long minRewardMS, maxRewardMS;
long targetOnTimeMS;
float alpha, beta;
BOOL useSingleITC18;
NSSound *juiceSound;
if ([sender respondsToSelector:@selector(juiceMS)]) {
juiceMS = (long)[sender performSelector:@selector(juiceMS)];
}
else {
juiceMS = [[task defaults] integerForKey:CRSRewardMSKey];
}
rewardSchedule = [[task defaults] integerForKey:CRSRewardScheduleKey];
if (rewardSchedule == kRewardVariable) {
minTargetMS = [[task defaults] integerForKey:CRSMinTargetMSKey];
maxTargetMS = [[task defaults] integerForKey:CRSMaxTargetMSKey];
minRewardMS = [[task defaults] integerForKey:CRSMinRewardMSKey];;
maxRewardMS = juiceMS * 2 - minRewardMS;
alpha = (float)(minRewardMS - maxRewardMS) / (float)(minTargetMS - maxTargetMS);
beta = minRewardMS - alpha * minTargetMS;
targetOnTimeMS = trial.targetOnTimeMS;
juiceMS = alpha * targetOnTimeMS + beta;
juiceMS = abs(juiceMS);
}
useSingleITC18 = [[task defaults] boolForKey:CRSUseSingleITC18Key];
if (useSingleITC18) {
[[task dataController] digitalOutputBits:(0xffff-kRewardBit)]; // Works as long as kRewardBit is either 0x0001 or 0x0000
}
else {
[[task dataController] digitalOutputBitsOff:kRewardBit];
}
[scheduler schedule:@selector(doJuiceOff) toTarget:self withObject:nil delayMS:juiceMS];
if ([[task defaults] boolForKey:CRSDoSoundsKey]) {
juiceSound = [NSSound soundNamed:@"Correct"];
if ([juiceSound isPlaying]) { // won't play again if it's still playing
[juiceSound stop];
}
[juiceSound play]; // play juice sound
}
}
- (void)doJuiceOff;
{
BOOL useSingleITC18;
useSingleITC18 = [[task defaults] boolForKey:CRSUseSingleITC18Key];
if (useSingleITC18) {
[[task dataController] digitalOutputBits:(0xfffe | kRewardBit)]; // Works as long as kRewardBit is either 0x0001 or 0x0000
}
else {
[[task dataController] digitalOutputBitsOn:kRewardBit];
}
}
- (IBAction)doReset:(id)sender;
{
requestReset();
}
- (IBAction)doRFMap:(id)sender;
{
[host performSelector:@selector(switchToTaskWithName:) withObject:@"RFMap"];
}
- (IBAction)doRunStop:(id)sender;
{
long newMode;
// [Vinay] - adding lines to read the protocol name and then send it via digital code whenever one hits the 'Run' button and starts the experiment
//int protocolNumber = [[task defaults] integerForKey:@"CRSProtocolNumber"]; // This variable reads the value of the protocol number
// NSString *protocolName; // to store the name
// [ Vinay] - till here
switch ([taskStatus mode]) {
case kTaskIdle:
newMode = kTaskRunning;
//[digitalOut outputEventName:@"protocolNumber" withData:(long)(protocolNumber)]; //[Vinay] - send the protocol name via digital code
break;
case kTaskRunning:
newMode = kTaskStopping;
break;
case kTaskStopping:
default:
newMode = kTaskIdle;
break;
}
[self setMode:newMode];
}
- (IBAction)doTaskGaborSettings:(id)sender;
{
[stimuli doGabor0Settings];
}
// After our -init is called, the host will provide essential pointers such as
// defaults, stimWindow, eyeCalibrator, etc. Only aMSer those are initialized, the
// following method will be called. We therefore defer most of our initialization here
- (void)initializationDidFinish;
{
long index;
NSString *userDefaultsValuesPath;
NSDictionary *userDefaultsValuesDict;
extern long argRand;
task = self;
// Register our default settings. This should be done first thing, before the
// nib is loaded, because items in the nib are linked to defaults
userDefaultsValuesPath = [[NSBundle bundleForClass:[self class]]
pathForResource:@"UserDefaults" ofType:@"plist"];
userDefaultsValuesDict = [NSDictionary dictionaryWithContentsOfFile:userDefaultsValuesPath];
[[task defaults] registerDefaults:userDefaultsValuesDict];
[NSValueTransformer
setValueTransformer:[[[LLFactorToOctaveStepTransformer alloc] init] autorelease]
forName:@"FactorToOctaveStepTransformer"];
[NSValueTransformer
setValueTransformer:[[[CRSRoundToStimCycle alloc] init] autorelease]
forName:@"RoundToStimCycle"];
// Set up to respond to changes to the values
for (index = 0; keyPaths[index] != nil; index++) {
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:keyPaths[index]
options:NSKeyValueObservingOptionNew context:nil];
}
// Set up the task mode object. We need to do this before loading the nib,
// because some items in the nib are bound to the task mode. We also need
// to set the mode, because the value in defaults will be the last entry made
// which is typically kTaskEnding.
taskStatus = [[LLTaskStatus alloc] init];
stimuli = [[CRSStimuli alloc] init];
digitalOut = [[CRSDigitalOut alloc] init];
// Load the items in the nib
[[NSBundle bundleForClass:[self class]] loadNibNamed:@"CRSMap" owner:self topLevelObjects:&topLevelObjects];
[topLevelObjects retain];
// Initialize other task objects
scheduler = [[LLScheduleController alloc] init];
stateSystem = [[CRSStateSystem alloc] init];
// Set up control panel and observer for control panel
controlPanel = [[LLControlPanel alloc] init];
[controlPanel setWindowFrameAutosaveName:@"CRSControlPanel"];
[[controlPanel window] setFrameUsingName:@"CRSControlPanel"];
[[controlPanel window] setTitle:@"CRSMap"];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(doControls:) name:nil object:controlPanel];
// initilize arg for randUnitInterval()
srand(time(nil));
argRand = -1 * abs(rand());
}
- (long)mode;
{
return [taskStatus mode];
}
- (NSString *)name;
{
return @"CRSMap";
}
// The release notes for 10.3 say that the options for addObserver are ignore
// (http://developer.apple.com/releasenotes/Cocoa/AppKit.html). This means that the change dictionary
// will not contain the new values of the change. For now it must be read directly from the model
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context;
{
static BOOL tested = NO;
NSString *key;
id newValue;
long longValue;
MapSettings settings;
if (!tested) {
newValue = [change objectForKey:NSKeyValueChangeNewKey];
if (![[newValue className] isEqualTo:@"NSNull"]) {
NSLog(@"NSKeyValueChangeNewKey is not NSNull, JHRM needs to change how values are accessed");
}
tested = YES;
}
key = [keyPath pathExtension];
if ([key isEqualTo:CRSStimTablesKey] || [key isEqualTo:CRSStimTableCountsKey]) {
/*
[mapStimTable0 updateBlockParameters];
settings = [mapStimTable0 mapSettings];
[dataDoc putEvent:@"map0Settings" withData:&settings];
[mapStimTable1 updateBlockParameters];
settings = [mapStimTable1 mapSettings];
[dataDoc putEvent:@"map1Settings" withData:&settings];
//[Vinay] - For gabor2
[mapStimTable2 updateBlockParameters];
settings = [mapStimTable2 mapSettings];
[dataDoc putEvent:@"map1Settings" withData:&settings];
// [Vinay] - till here
requestReset();
*/
[mapStimTable0 updateBlockParameters:0]; // [Vinay] - added arguement '0'
settings = [mapStimTable0 mapSettings];
[dataDoc putEvent:@"map0Settings" withData:&settings];
[mapStimTable1 updateBlockParameters:1]; // [Vinay] - added arguement '1'
settings = [mapStimTable1 mapSettings];
[dataDoc putEvent:@"map1Settings" withData:&settings];
//----------------------------------------------------------- [Vinay] for centre gabor
[mapStimTable2 updateBlockParameters:2]; // [Vinay] - added arguement '2'
settings = [mapStimTable2 mapSettings];
[dataDoc putEvent:@"map2Settings" withData:&settings];
//-----------------------------------------------------
requestReset();
}
else if ([key isEqualTo:CRSRespTimeMSKey]) {
longValue = [defaults integerForKey:CRSRespTimeMSKey];
[dataDoc putEvent:@"responseTimeMS" withData:&longValue];
}
else if ([key isEqualTo:CRSMapStimDurationMSKey]) {
longValue = [defaults integerForKey:CRSMapStimDurationMSKey];
[dataDoc putEvent:@"mapStimDurationMS" withData:&longValue];
requestReset();
}
else if ([key isEqualTo:CRSMapInterstimDurationMSKey]) {
longValue = [defaults integerForKey:CRSMapInterstimDurationMSKey];
[dataDoc putEvent:@"mapInterstimDurationMS" withData:&longValue];
requestReset();
}
else if ([key isEqualTo:CRSStimDurationMSKey]) {
longValue = [defaults integerForKey:CRSStimDurationMSKey];
[dataDoc putEvent:@"stimDurationMS" withData:&longValue];
if ([[task defaults] integerForKey:CRSStimDistributionKey] == kExponential) {
updateCatchTrialPC();
}
requestReset();
}
else if ([key isEqualTo:CRSMeanTargetMSKey]) {
longValue = [defaults integerForKey:CRSMeanTargetMSKey];
[dataDoc putEvent:@"meanTargetTimeMS" withData:&longValue];
if ([[task defaults] integerForKey:CRSStimDistributionKey] == kExponential) {
updateCatchTrialPC();
}
// requestReset();
}
else if ([key isEqualTo:CRSMaxTargetMSKey]) {
longValue = [defaults integerForKey:CRSMaxTargetMSKey];
[dataDoc putEvent:@"maxTargetTimeMS" withData:&longValue];
if ([[task defaults] integerForKey:CRSStimDistributionKey] == kUniform) {
longValue = [defaults integerForKey:CRSMinTargetMSKey] +
([defaults integerForKey:CRSMaxTargetMSKey] - [defaults integerForKey:CRSMinTargetMSKey]) / 2.0;
// [[task defaults] setInteger: longValue forKey: CRSMeanTargetMSKey];
}
else updateCatchTrialPC();
requestReset();
}
else if ([key isEqualTo:CRSMinTargetMSKey]) {
longValue = [defaults integerForKey:CRSMinTargetMSKey];
[dataDoc putEvent:@"minTargetTimeMS" withData:&longValue];
if ([[task defaults] integerForKey:CRSStimDistributionKey] == kUniform) {
longValue = [defaults integerForKey:CRSMinTargetMSKey] +
([defaults integerForKey:CRSMaxTargetMSKey] - [defaults integerForKey:CRSMinTargetMSKey]) / 2.0;
// [[task defaults] setInteger: longValue forKey: CRSMeanTargetMSKey];
}
else updateCatchTrialPC();
requestReset();
}
else if ([key isEqualTo:CRSInterstimMSKey]) {
longValue = [defaults integerForKey:CRSInterstimMSKey];
[dataDoc putEvent:@"interstimMS" withData:&longValue];
if ([[task defaults] integerForKey:CRSStimDistributionKey] == kExponential) {
updateCatchTrialPC();
}
requestReset();
}
else if ([key isEqualTo:CRSOrientationChangesKey] || [key isEqualTo:CRSMaxDirChangeDegKey] ||
[key isEqualTo:CRSMinDirChangeDegKey] || [key isEqualTo:CRSChangeScaleKey]) {
[self updateChangeTable];
}
else if ([key isEqualTo:CRSChangeArrayKey]) {
updateBlockStatus();
[[task dataDoc] putEvent:@"blockStatus" withData:&blockStatus];
}
else if ([key isEqualTo:CRSMappingBlocksKey]) {
mappingBlockStatus.blockLimit = [[task defaults] integerForKey:CRSMappingBlocksKey];
[[task dataDoc] putEvent:@"mappingBlockStatus" withData:&mappingBlockStatus];
}
else if ([key isEqualTo:CRSFixateMSKey]) {
longValue = [defaults integerForKey:CRSFixateMSKey];
[[task dataDoc] putEvent:@"fixateMS" withData:&longValue];
}
else if ([key isEqualTo:CRSStimRepsPerBlockKey]) {
longValue = [defaults integerForKey:CRSOrientationChangesKey];
[dataDoc putEvent:@"stimRepsPerBlock" withData:&longValue];
}
else if ([key isEqualTo:CRSMapStimContrastPCKey]) {
[stimuli clearStimLists:&trial];
//[stimuli makeStimLists:&trial];
}
else if ([key isEqualTo:CRSHideTaskGaborKey]) {
[[task defaults] setBool:YES forKey:CRSIncludeCatchTrialsinDoneListKey];
[[task defaults] setInteger:100 forKey:CRSCatchTrialPCKey];
}
/* // [Vinay] - commented and replaced the following loops
else if ([key isEqualTo:CRSHideLeftKey]) {
[[task defaults] setBool:YES forKey:CRSHideLeftDigitalKey];
}
else if ([key isEqualTo:CRSHideRightKey]) {
[[task defaults] setBool:YES forKey:CRSHideRightDigitalKey];
}
*/
/*
else if ([key isEqualTo:CRSMapStimContrastPCKey]) {
[stimuli clearStimLists:&trial];
//[stimuli makeStimLists:&trial];
}*/
// [Vinay] - Have replaced the Left and Right Digital code keys with C, R, S Digital code control keys
else if ([key isEqualTo:CRSHideCentreKey]) {
[[task defaults] setBool:YES forKey:CRSHideCentreDigitalKey];
}
else if ([key isEqualTo:CRSHideRingKey]) {
[[task defaults] setBool:YES forKey:CRSHideRingDigitalKey];
}
else if ([key isEqualTo:CRSHideSurroundKey]) {
[[task defaults] setBool:YES forKey:CRSHideSurroundDigitalKey];
}
// [Vinay] - have added the follow lines. And commented all later since they aren't required. In fact they cause an error - NSLock error because whenever the key is set, you try to again set it thus leading to an uncontrolled runaway situation
/*
else if ([key isEqualTo:CRSMatchCentreSurroundKey]) {
[[task defaults] setBool:YES forKey:CRSMatchCentreSurroundKey];
}
*/
/*
else if ([key isEqualTo:CRSRingProtocolKey]) {