-
Notifications
You must be signed in to change notification settings - Fork 0
/
strint_train_step2.m
865 lines (746 loc) · 34.1 KB
/
strint_train_step2.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
% This loads in the .mat file generated in step 1
clear all
close all
% Select the subject file
str = computer;
if strcmp(str,'MACI64') == 1
cd('/Volumes/mnl/Data/Adaptation/structural_interference/Post_Step_1_train');
fname = uigetfile('*train*.mat');
else
cd('Z:\Data\Adaptation\structural_interference\Post_Step_1_train'); % Lab PCs
%cd('C:\Users\Alex\Desktop\IFDosing\Post_Step_1'); % Home PC
fname = uigetfile('*train*.mat');
end
load(fname);
subID = fname(1:18);
numTrials = size(sortData,1); % Number of Trials
fs = 1000; % Sample Rate (Hz)
delta_t = 1/fs; %Sample Period
% Conversion between global and local reference frame (this is due to all
% x,y hand positions being referenced in the global frame, whereas the
% targets in the target table are referenced in a local frame specified in
% Deterit-E
Tx = sortData(1,1).TARGET_TABLE.X_GLOBAL(1) - sortData(1,1).TARGET_TABLE.X(1);
Ty = sortData(1,1).TARGET_TABLE.Y_GLOBAL(1) - sortData(1,1).TARGET_TABLE.Y(1);
%visual baseline, kinesthetic baseline, exposure, and post-exposure
%trial numbers in the sequence
vbTrials = 1:16;
exTrials = 17:256;
peTrials = 257:272;
% Define the rotation amounts during baseline, ex, pe
theta(vbTrials) = 0; % rotation in degrees during exposure phase
theta(exTrials) = 0; % WARNING: THIS IS HARD CODED!!! Also, we are not analyzing any of the exposure trials since they are random!
theta(peTrials) = 0;
% Find the Cursor Position
% First, translate rotation point to global origin
% Then apply rotation, and translate back to target origin
cursorPosX = cell(numTrials,1);
cursorPosY = cell(numTrials,1);
handPosX = cell(numTrials,1);
handPosY = cell(numTrials,1);
for i = 1:numTrials
handPosX{i,1} = sortData(i).Right_HandX - sortData(1).TARGET_TABLE.X_GLOBAL(1)/100; % Translate to global origin
handPosY{i,1} = sortData(i).Right_HandY - sortData(1).TARGET_TABLE.Y_GLOBAL(1)/100;
cursorPosX{i,1} = handPosX{i,1}.*cosd(theta(i)) - handPosY{i,1}.*sind(theta(i)); % Reverse the rotation
cursorPosY{i,1} = handPosX{i,1}.*sind(theta(i)) + handPosY{i,1}.*cosd(theta(i));
cursorPosX{i,1} = cursorPosX{i,1} + sortData(1).TARGET_TABLE.X_GLOBAL(1)/100; % Translate back to target origin
cursorPosY{i,1} = cursorPosY{i,1} + sortData(1).TARGET_TABLE.Y_GLOBAL(1)/100;
end
% Find the "Up" and "Down" trials
upBool = zeros(numTrials,1);
for i = 1:numTrials
upBool(i) = sortData(i).TRIAL.TP == 1 || sortData(i).TRIAL.TP == 3;
end
upBool = upBool';
upTrials = find(upBool == 1); % Trial numbers of "up" targets
upTrials = upTrials';
downTrials = find(upBool == 0);
downTrials = downTrials';
numDataPoints = zeros(numTrials,1);
for i = 1:numTrials
numDataPoints(i) = size(sortData(i).Right_HandX,1); % Number of Data points in each trial
end
vel = cell(numTrials,1);
velPeak = zeros(numTrials,1);
indPeak = zeros(numTrials,1);
for i = 1:numTrials
%Calculate hand speed
vel{i,1} = sqrt(sortData(i,1).Right_HandXVel.^2 + sortData(i,1).Right_HandYVel.^2);
%Find Peak velocity
if wrong_trial(i) == 0
[velPeak(i), indPeak(i)] = max(vel{i,1}(onset(i):offset(i))); % Calculates peak v for movement only
indPeak(i) = indPeak(i) + onset(i); % reindexes to start of data collection
else
velPeak(i) = NaN; indPeak(i) = NaN;
end
end
velPeakTime = indPeak - onset;
%% Movement Time (MT)
%%%%%%%%%%%%%%%%%%%%%%%%%%% Movement Time %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MT = (offset - onset)/fs;
MT(wrong_trial==1) = NaN;
%% MT outlier analysis
data = outlier_t(MT(upTrials(1:8))); % Outlier for visual baseline
MT_c(upTrials(1:8)) = data;
data = outlier_t(MT(downTrials(1:8)));
MT_c(downTrials(1:8)) = data;
clear data;
% Exclude ALL trials of exposure from outlier scrubbing
MT_c(upTrials(9:128)) = MT(upTrials(9:128));
MT_c(downTrials(9:128)) = MT(downTrials(9:128));
% Exclude ALL of post-exposure from outlier scrubbing
MT_c(upTrials(129:136)) = MT(upTrials(129:136));
MT_c(downTrials(129:136)) = MT(downTrials(129:136));
% transpose and calculate standardized variable
MT_c = MT_c';
bkup_mean = nanmean(MT_c(upTrials(1:8)));
bkup_std = nanstd(MT_c(upTrials(1:8)));
MT_up_st = (MT_c(upTrials) - bkup_mean)/bkup_std;
bkdown_mean = nanmean(MT_c(downTrials(1:8)));
bkdown_std = nanstd(MT_c(downTrials(1:8)));
MT_down_st = (MT_c(downTrials) - bkdown_mean)/bkdown_std;
clear bkup_mean; clear bkup_std; clear bkdown_mean; clear bkdown_std;
%% Plotting Code for MT
figure
set(gcf,'Color','w','Position',[560 528 600 420])
hold on;
subplot('Position',[0.06 0.2 0.1 0.6]); hold on;
plot(upTrials(1:8),MT(upTrials(1:8)),'bo');
hold on
plot(upTrials(1:8),MT_c(upTrials(1:8)),'bx');
hold on
plot(downTrials(1:8),MT(downTrials(1:8)),'ro');
hold on
plot(downTrials(1:8),MT_c(downTrials(1:8)),'rx');
axis([0 16 0 6]); set(gca,'LineWidth',2,'XTick',[1 10 20],'YTick',0:1:6,'YTickLabel',0:1:6,'FontName','Arial','FontSize',10); ylabel('MT [s]'); title('vis-pre','fontsize',11);
hold on
subplot('Position',[0.23 0.2 0.4 0.6]); hold on;
plot(upTrials(9:28)-exTrials(1)+1,MT(upTrials(9:28)),'bo');
hold on
plot(upTrials(9:28)-exTrials(1)+1,MT_c(upTrials(9:28)),'bx');
hold on
plot(downTrials(9:28)-exTrials(1)+1,MT(downTrials(9:28)),'ro');
hold on
plot(downTrials(9:28)-exTrials(1)+1,MT_c(downTrials(9:28)),'rx');
axis([0 40 0 6]); set(gca,'LineWidth',2,'XTick',[1 20 70 120 140],'YTick',[],'YTickLabel',[],'FontName','Arial','FontSize',10); title(['exposure'], 'fontsize',11); xlabel('Trials','fontsize',11);
hold on
subplot('Position',[0.70 0.2 0.24 0.6]); hold on;
plot(upTrials(129:136)-peTrials(1)+1,MT(upTrials(129:136)),'bo');
hold on
plot(upTrials(129:136)-peTrials(1)+1,MT_c(upTrials(129:136)),'bx');
hold on
plot(downTrials(129:136)-peTrials(1)+1,MT(downTrials(129:136)),'ro');
hold on
plot(downTrials(129:136)-peTrials(1)+1,MT_c(downTrials(129:136)),'rx');
axis([0 16 0 6]); set(gca,'LineWidth',2,'XTick',[1 20 40],'YTick',[],'YTickLabel',[],'FontName','Arial','FontSize',10); title(['post-exposure'], 'fontsize',11); xlabel('Trials','fontsize',11);
title([subID(7:9), ' ', 'MT'])
%% IDE
%%%%%%%%%%%%%%%%%%%%%%% Initial Directional Error %%%%%%%%%%%%%%%%%%%%%%%%
% Defined as the angle between the vector from hand position at movement
% onset to target position and a vector pointing to the hand
% position at peak velocity from movement onset hand position
upTargetPos = [sortData(1,1).TARGET_TABLE.X(2) sortData(1,1).TARGET_TABLE.Y(2)];
downTargetPos = [sortData(1,1).TARGET_TABLE.X(3) sortData(1,1).TARGET_TABLE.Y(3)];
xPeak = zeros(numTrials,1);
yPeak = zeros(numTrials,1);
xStart = zeros(numTrials,1);
yStart = zeros(numTrials,1);
imd = zeros(numTrials,2); % initial movement direction (x,y)
itd = zeros(numTrials,2); % initial target direction (x,y)
ide = zeros(numTrials,1);
for i = 1:numTrials
if wrong_trial(i) == 0
% Hand Position at movement onset
xStart(i) = cursorPosX{i,1}(onset(i))*100-Tx; %in cm and workspace ref frame
yStart(i) = cursorPosY{i,1}(onset(i))*100-Ty;
% Hand Position at peak velocity
xPeak(i) = cursorPosX{i,1}(indPeak(i))*100-Tx; %in cm and workspace ref frame
yPeak(i) = cursorPosY{i,1}(indPeak(i))*100-Ty;
% Vector from start position to peak velocity position
imd(i,:) = [xPeak(i) - xStart(i) yPeak(i) - yStart(i)];
if yPeak(i) > 0
itd(i,:) = [upTargetPos(1) - xStart(i) upTargetPos(2) - yStart(i)];
elseif yPeak(i) < 0
itd(i,:) = [downTargetPos(1) - xStart(i) downTargetPos(2) - yStart(i)];
end
ide(i) = acosd(dot(itd(i,:),imd(i,:))./(norm(itd(i,:)).*norm(imd(i,:))));
% Make ide the the 1st and 3rd quad negative
if imd(i,1) > 0 && imd(i,2) > 0
ide(i) = -ide(i);
elseif imd(i,1) < 0 && imd(i,2) < 0
ide(i) = -ide(i);
end
else
xPeak(i) = NaN;
yPeak(i) = NaN;
xStart(i) = NaN;
yStart(i) = NaN;
imd(i,:) = NaN;
ide(i) = NaN;
end
end
%ide(exTrials) = ide(exTrials)-40;
%% ide outlier analysis
data = outlier_t(ide(upTrials(1:8)));
ide_c(upTrials(1:8)) = data;
data = outlier_t(ide(downTrials(1:8)));
ide_c(downTrials(1:8)) = data;
clear data;
% Exclude ALL trials of exposure from outlier scrubbing
ide_c(upTrials(9:128)) = ide(upTrials(9:128));
ide_c(downTrials(9:128)) = ide(downTrials(9:128));
% Exclude ALL of post-exposure from outlier scrubbing
ide_c(upTrials(129:136)) = ide(upTrials(129:136));
ide_c(downTrials(129:136)) = ide(downTrials(129:136));
% transpose and calculate standardized variable
ide_c = ide_c';
bkup_mean = nanmean(ide_c(upTrials(1:8)));
bkup_std = nanstd(ide_c(upTrials(1:8)));
ide_up_st = (ide_c(upTrials) - bkup_mean)/bkup_std;
bkdown_mean = nanmean(ide_c(downTrials(1:8)));
bkdown_std = nanstd(ide_c(downTrials(1:8)));
ide_down_st = (ide_c(downTrials) - bkdown_mean)/bkdown_std;
clear bkup_mean; clear bkup_std; clear bkdown_mean; clear bkdown_std;
%% Plotting Code for ide
figure
set(gcf,'Color','w','Position',[560 528 600 420])
hold on;
subplot('Position',[0.06 0.2 0.1 0.6]); hold on;
plot(upTrials(1:8),ide(upTrials(1:8)),'bo');
hold on
plot(upTrials(1:8),ide_c(upTrials(1:8)),'bx');
hold on
plot(downTrials(1:8),ide(downTrials(1:8)),'ro');
hold on
plot(downTrials(1:8),ide_c(downTrials(1:8)),'rx');
hold on
yline(0, '--k');
axis([0 16 -80 80]); set(gca,'LineWidth',2,'XTick',[1 10 20],'YTick',-80:20:80,'YTickLabel',-80:20:80,'FontName','Arial','FontSize',10); ylabel('ide [s]'); title('vis-pre','fontsize',11);
hold on
subplot('Position',[0.23 0.2 0.4 0.6]); hold on;
plot(upTrials(9:28)-exTrials(1)+1,ide(upTrials(9:28)),'bo');
hold on
plot(upTrials(9:28)-exTrials(1)+1,ide_c(upTrials(9:28)),'bx');
hold on
plot(downTrials(9:28)-exTrials(1)+1,ide(downTrials(9:28)),'ro');
hold on
plot(downTrials(9:28)-exTrials(1)+1,ide_c(downTrials(9:28)),'rx');
hold on
yline(0, '--k');
axis([0 40 -80 80]); set(gca,'LineWidth',2,'XTick',[1 20 40],'YTick',[],'YTickLabel',[],'FontName','Arial','FontSize',10); title(['exposure'], 'fontsize',11); xlabel('Trials','fontsize',11);
hold on
subplot('Position',[0.70 0.2 0.24 0.6]); hold on;
plot(upTrials(129:136)-peTrials(1)+1,ide(upTrials(129:136)),'bo');
hold on
plot(upTrials(129:136)-peTrials(1)+1,ide_c(upTrials(129:136)),'bx');
hold on
plot(downTrials(129:136)-peTrials(1)+1,ide(downTrials(129:136)),'ro');
hold on
plot(downTrials(129:136)-peTrials(1)+1,ide_c(downTrials(129:136)),'rx');
hold on
yline(0, '--k');
axis([0 16 -80 80]); set(gca,'LineWidth',2,'XTick',[1 16],'YTick',[],'YTickLabel',[],'FontName','Arial','FontSize',10); title(['post-exposure'], 'fontsize',11); xlabel('Trials','fontsize',11);
title([subID(7:9), ' ', 'ide'])
%% RMSE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% RMSE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Taken straight from kinsym2 step 2 files
rmse=zeros(numTrials,1); % allocate space for rmse
mov_int = zeros(numTrials,1);
for i=1:numTrials
if wrong_trial(i)==0
xx=cursorPosX{i,1}(onset(i):offset(i))*1000; % convert to mm
yy=cursorPosY{i,1}(onset(i):offset(i))*1000;
% spatial resampling of movement path
N= 2000; N1= length(xx); % Computes equally-spaced vector assuming 1000 samples
xc= 1/(N-1)*(0:N-1)*(xx(N1)-xx(1))+xx(1);
yc= 1/(N-1)*(0:N-1)*(yy(N1)-yy(1))+yy(1);
% integrates the movement length
mov_int(i)=sum(sqrt(diff(xx).^2+ diff(yy).^2));
di=(0:N-1)*mov_int(i)/(N-1);
d=[0; (cumsum(sqrt((diff(xx).^2)+ (diff(yy).^2))))];
% interpolates the movement path to make it equally spaced
x2i= interp1q(d,xx,di');
y2i= interp1q(d,yy,di');
x2i(N)=xc(N);
y2i(N)=yc(N);
optimal =[xc', yc'];
resampled_path =[x2i, y2i];
rmse(i) = sqrt(sum(sum((resampled_path - optimal).^2))/N);
else rmse(i)=NaN;
end
end
%% rmse outlier analysis
data = outlier_t(rmse(upTrials(1:8))); % Outlier for visual baseline
rmse_c(upTrials(1:8)) = data;
data = outlier_t(rmse(downTrials(1:8)));
rmse_c(downTrials(1:8)) = data;
clear data;
% Exclude ALL trials from outlier scrubbing
rmse_c(upTrials(9:128)) = rmse(upTrials(9:128));
rmse_c(downTrials(9:128)) = rmse(downTrials(9:128));
% Exclude ALL of post-exposure from outlier scrubbing
rmse_c(upTrials(129:136)) = rmse(upTrials(129:136));
rmse_c(downTrials(129:136)) = rmse(downTrials(129:136));
% transpose and calculate standardized variable
rmse_c = rmse_c';
bkup_mean = nanmean(rmse_c(upTrials(1:8)));
bkup_std = nanstd(rmse_c(upTrials(1:8)));
rmse_up_st = (rmse_c(upTrials) - bkup_mean)/bkup_std;
bkdown_mean = nanmean(rmse_c(downTrials(1:8)));
bkdown_std = nanstd(rmse_c(downTrials(1:8)));
rmse_down_st = (rmse_c(downTrials) - bkdown_mean)/bkdown_std;
clear bkup_mean; clear bkup_std; clear bkdown_mean; clear bkdown_std;
%% Plotting Code for rmse
figure
set(gcf,'Color','w','Position',[560 528 600 420])
hold on;
subplot('Position',[0.06 0.2 0.1 0.6]); hold on;
plot(upTrials(1:8),rmse(upTrials(1:8)),'bo');
hold on
plot(upTrials(1:8),rmse_c(upTrials(1:8)),'bx');
hold on
plot(downTrials(1:8),rmse(downTrials(1:8)),'ro');
hold on
plot(downTrials(1:8),rmse_c(downTrials(1:8)),'rx');
axis([0 16 0 60]); set(gca,'LineWidth',2,'XTick',[1 10 20],'YTick',0:10:60,'YTickLabel', 0:10:60,'FontName','Arial','FontSize',10); ylabel('rmse [mm]'); title('vis-pre','fontsize',11);
hold on
subplot('Position',[0.23 0.2 0.4 0.6]); hold on;
plot(upTrials(9:28)-exTrials(1)+1,rmse(upTrials(9:28)),'bo');
hold on
plot(upTrials(9:28)-exTrials(1)+1,rmse_c(upTrials(9:28)),'bx');
hold on
plot(downTrials(9:28)-exTrials(1)+1,rmse(downTrials(9:28)),'ro');
hold on
plot(downTrials(9:28)-exTrials(1)+1,rmse_c(downTrials(9:28)),'rx');
axis([0 40 0 60]); set(gca,'LineWidth',2,'XTick',[1 20 70 120 140],'YTick',[],'YTickLabel',[],'FontName','Arial','FontSize',10); title(['exposure'], 'fontsize',11); xlabel('Trials','fontsize',11);
hold on
subplot('Position',[0.70 0.2 0.24 0.6]); hold on;
plot(upTrials(129:136)-peTrials(1)+1,rmse(upTrials(129:136)),'bo');
hold on
plot(upTrials(129:136)-peTrials(1)+1,rmse_c(upTrials(129:136)),'bx');
hold on
plot(downTrials(129:136)-peTrials(1)+1,rmse(downTrials(129:136)),'ro');
hold on
plot(downTrials(129:136)-peTrials(1)+1,rmse_c(downTrials(129:136)),'rx');
axis([0 16 0 60]); set(gca,'LineWidth',2,'XTick',[1 20 40],'YTick',[],'YTickLabel',[],'FontName','Arial','FontSize',10); title(['post-exposure'], 'fontsize',11); xlabel('Trials','fontsize',11);
title([subID(7:9), ' ', 'rmse'])
%% Movement Length
%%%%%%%%%%%%%%%%%%%%%%% Movement Length %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
mov_int = zeros(numTrials,1);
for i = 1:numTrials
if wrong_trial(i) == 0
mov_int(i) = sum(sqrt(diff(cursorPosX{i,1}(onset(i):offset(i))).^2 + diff(cursorPosY{i,1}(onset(i):offset(i))).^2)) * 100; %movement length in cm
else
mov_int(i) = NaN;
end
end
%% mov_int outlier analysis
data = outlier_t(mov_int(upTrials(1:8))); % Outlier for visual baseline
mov_int_c(upTrials(1:8)) = data;
data = outlier_t(mov_int(downTrials(1:8)));
mov_int_c(downTrials(1:8)) = data;
clear data;
% Exclude ALL trials of exposure to outlier scrubbing
mov_int_c(upTrials(9:128)) = mov_int(upTrials(9:128));
mov_int_c(downTrials(9:128)) = mov_int(downTrials(9:128));
% Exclude ALL of post-exposure from outlier scrubbing
mov_int_c(upTrials(129:136)) = mov_int(upTrials(129:136));
mov_int_c(downTrials(129:136)) = mov_int(downTrials(129:136));
% transpose and calculate standardized variable
mov_int_c = mov_int_c';
bkup_mean = nanmean(mov_int_c(upTrials(1:8)));
bkup_std = nanstd(mov_int_c(upTrials(1:8)));
mov_int_up_st = (mov_int_c(upTrials) - bkup_mean)/bkup_std;
bkdown_mean = nanmean(mov_int_c(downTrials(1:8)));
bkdown_std = nanstd(mov_int_c(downTrials(1:8)));
mov_int_down_st = (mov_int_c(downTrials) - bkdown_mean)/bkdown_std;
clear bkup_mean; clear bkup_std; clear bkdown_mean; clear bkdown_std;
%% Plotting Code for mov_int
figure
set(gcf,'Color','w','Position',[560 528 600 420])
hold on;
subplot('Position',[0.06 0.2 0.1 0.6]); hold on;
plot(upTrials(1:8),mov_int(upTrials(1:8)),'bo');
hold on
plot(upTrials(1:8),mov_int_c(upTrials(1:8)),'bx');
hold on
plot(downTrials(1:8),mov_int(downTrials(1:8)),'ro');
hold on
plot(downTrials(1:8),mov_int_c(downTrials(1:8)),'rx');
hold on
yline(10, '--k');
axis([0 16 0 40]); set(gca,'LineWidth',2,'XTick',[1 10 20],'YTick',0:10:40,'YTickLabel', 0:10:40,'FontName','Arial','FontSize',10); ylabel('mov_int [cm]'); title('vis-pre','fontsize',11);
hold on
subplot('Position',[0.23 0.2 0.4 0.6]); hold on;
plot(upTrials(9:28)-exTrials(1)+1,mov_int(upTrials(9:28)),'bo');
hold on
plot(upTrials(9:28)-exTrials(1)+1,mov_int_c(upTrials(9:28)),'bx');
hold on
plot(downTrials(9:28)-exTrials(1)+1,mov_int(downTrials(9:28)),'ro');
hold on
plot(downTrials(9:28)-exTrials(1)+1,mov_int_c(downTrials(9:28)),'rx');
hold on
yline(10, '--k');
axis([0 40 0 40]); set(gca,'LineWidth',2,'XTick',[1 20 70 120 140],'YTick',[],'YTickLabel',[],'FontName','Arial','FontSize',10); title(['exposure'], 'fontsize',11); xlabel('Trials','fontsize',11);
hold on
subplot('Position',[0.70 0.2 0.24 0.6]); hold on;
plot(upTrials(129:136)-peTrials(1)+1,mov_int(upTrials(129:136)),'bo');
hold on
plot(upTrials(129:136)-peTrials(1)+1,mov_int_c(upTrials(129:136)),'bx');
hold on
plot(downTrials(129:136)-peTrials(1)+1,mov_int(downTrials(129:136)),'ro');
hold on
plot(downTrials(129:136)-peTrials(1)+1,mov_int_c(downTrials(129:136)),'rx');
hold on
yline(10, '--k');
axis([0 16 0 40]); set(gca,'LineWidth',2,'XTick',[1 20 40],'YTick',[],'YTickLabel',[],'FontName','Arial','FontSize',10); title(['post-exposure'], 'fontsize',11); xlabel('Trials','fontsize',11);
title([subID(7:9), ' ', 'mov_int'])
%% Normalized Jerk Score
%%%%%%%%%%%%%%%%%%%%%%% Normalized Jerk %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
acc_tan = cell(numTrials,1);
jerk = cell(numTrials,1);
jerk_square = cell(numTrials,1);
delta_1 = cell(numTrials,1);
jerk_int = zeros(numTrials,1);
norm_jerk = zeros(numTrials,1);
for i = 1:numTrials
if wrong_trial(i) == 0
acc_tan{i,1} = 100*sqrt((sortData(i).Right_HandXAcc).^2 + (sortData(i).Right_HandYAcc).^2); % in cm/s/s
jerk{i,1} = diff(acc_tan{i,1})/delta_t;
jerk_square{i,1} = jerk{i,1}.^2;
delta_1{i,1} = (0:1:(length(jerk_square{i,1}) - 1)) ./fs;
jerk_int(i) = trapz(delta_1{i,1},jerk_square{i,1});
norm_jerk(i) = sqrt(0.5 *jerk_int(i) * ((MT(i))^5)/ (mov_int(i)^2));
else
norm_jerk(i) = NaN;
end
end
%% norm_jerk outlier analysis
data = outlier_t(norm_jerk(upTrials(1:8))); % Outlier for visual baseline
norm_jerk_c(upTrials(1:8)) = data;
data = outlier_t(norm_jerk(downTrials(1:8)));
norm_jerk_c(downTrials(1:8)) = data;
clear data;
% Exclude ALL trials from outlier scrubbing
norm_jerk_c(upTrials(9:128)) = norm_jerk(upTrials(9:128));
norm_jerk_c(downTrials(9:128)) = norm_jerk(downTrials(9:128));
% Exclude ALL of post-exposure from outlier scrubbing
norm_jerk_c(upTrials(129:136)) = norm_jerk(upTrials(129:136));
norm_jerk_c(downTrials(129:136)) = norm_jerk(downTrials(129:136));
% transpose and calculate standardized variable
norm_jerk_c = norm_jerk_c';
bkup_mean = nanmean(norm_jerk_c(upTrials(1:8)));
bkup_std = nanstd(norm_jerk_c(upTrials(1:8)));
norm_jerk_up_st = (norm_jerk_c(upTrials) - bkup_mean)/bkup_std;
bkdown_mean = nanmean(norm_jerk_c(downTrials(1:8)));
bkdown_std = nanstd(norm_jerk_c(downTrials(1:8)));
norm_jerk_down_st = (norm_jerk_c(downTrials) - bkdown_mean)/bkdown_std;
clear bkup_mean; clear bkup_std; clear bkdown_mean; clear bkdown_std;
%% Plotting Code for norm_jerk
figure
set(gcf,'Color','w','Position',[560 528 600 420])
hold on;
subplot('Position',[0.06 0.2 0.1 0.6]); hold on;
plot(upTrials(1:8),norm_jerk(upTrials(1:8)),'bo');
hold on
plot(upTrials(1:8),norm_jerk_c(upTrials(1:8)),'bx');
hold on
plot(downTrials(1:8),norm_jerk(downTrials(1:8)),'ro');
hold on
plot(downTrials(1:8),norm_jerk_c(downTrials(1:8)),'rx');
axis([0 16 0 1000]); set(gca,'LineWidth',2,'XTick',[1 16],'YTick',0:100:1000,'YTickLabel', 0:100:1000,'FontName','Arial','FontSize',10); ylabel('norm jerk [?]'); title('vis-pre','fontsize',11);
hold on
subplot('Position',[0.23 0.2 0.4 0.6]); hold on;
plot(upTrials(9:28)-exTrials(1)+1,norm_jerk(upTrials(9:28)),'bo');
hold on
plot(upTrials(9:28)-exTrials(1)+1,norm_jerk_c(upTrials(9:28)),'bx');
hold on
plot(downTrials(9:28)-exTrials(1)+1,norm_jerk(downTrials(9:28)),'ro');
hold on
plot(downTrials(9:28)-exTrials(1)+1,norm_jerk_c(downTrials(9:28)),'rx');
axis([0 40 0 1000]); set(gca,'LineWidth',2,'XTick',[1 20 40],'YTick',[],'YTickLabel',[],'FontName','Arial','FontSize',10); title(['exposure'], 'fontsize',11); xlabel('Trials','fontsize',11);
hold on
subplot('Position',[0.70 0.2 0.24 0.6]); hold on;
plot(upTrials(129:136)-peTrials(1)+1,norm_jerk(upTrials(129:136)),'bo');
hold on
plot(upTrials(129:136)-peTrials(1)+1,norm_jerk_c(upTrials(129:136)),'bx');
hold on
plot(downTrials(129:136)-peTrials(1)+1,norm_jerk(downTrials(129:136)),'ro');
hold on
plot(downTrials(129:136)-peTrials(1)+1,norm_jerk_c(downTrials(129:136)),'rx');
axis([0 16 0 1000]); set(gca,'LineWidth',2,'XTick',[1 16],'YTick',[],'YTickLabel',[],'FontName','Arial','FontSize',10); title(['post-exposure'], 'fontsize',11); xlabel('Trials','fontsize',11);
title([subID(7:9), ' ', 'norm_jerk'])
%% Peak Velocity
velPeak = velPeak * 100; % Convert to cm/s
velPeak(wrong_trial == 1) = NaN;
%% Peak Velocity outlier calc
data = outlier_t(velPeak(upTrials(1:8))); % Outlier for visual baseline
velPeak_c(upTrials(1:8)) = data;
data = outlier_t(velPeak(downTrials(1:8)));
velPeak_c(downTrials(1:8)) = data;
clear data;
% Exclude ALL trials of exposure from outlier scrubbing
velPeak_c(upTrials(9:128)) = velPeak(upTrials(9:128));
velPeak_c(downTrials(9:128)) = velPeak(downTrials(9:128));
% Exclude ALL of post-exposure from outlier scrubbing
velPeak_c(upTrials(129:136)) = velPeak(upTrials(129:136));
velPeak_c(downTrials(129:136)) = velPeak(downTrials(129:136));
% transpose and calculate standardized variable
velPeak_c = velPeak_c';
bkup_mean = nanmean(velPeak_c(upTrials(1:8)));
bkup_std = nanstd(velPeak_c(upTrials(1:8)));
velPeak_up_st = (velPeak_c(upTrials) - bkup_mean)/bkup_std;
bkdown_mean = nanmean(velPeak_c(downTrials(1:8)));
bkdown_std = nanstd(velPeak_c(downTrials(1:8)));
velPeak_down_st = (velPeak_c(downTrials) - bkdown_mean)/bkdown_std;
clear bkup_mean; clear bkup_std; clear bkdown_mean; clear bkdown_std;
%% Plotting Code for velPeak
figure
set(gcf,'Color','w','Position',[560 528 600 420])
hold on;
subplot('Position',[0.06 0.2 0.1 0.6]); hold on;
plot(upTrials(1:8),velPeak(upTrials(1:8)),'bo');
hold on
plot(upTrials(1:8),velPeak_c(upTrials(1:8)),'bx');
hold on
plot(downTrials(1:8),velPeak(downTrials(1:8)),'ro');
hold on
plot(downTrials(1:8),velPeak_c(downTrials(1:8)),'rx');
axis([0 16 0 100]); set(gca,'LineWidth',2,'XTick',[1 16],'YTick',0:10:100,'YTickLabel', 0:10:100,'FontName','Arial','FontSize',10); ylabel('velPeak [cm/s]'); title('vis-pre','fontsize',11);
hold on
subplot('Position',[0.23 0.2 0.4 0.6]); hold on;
plot(upTrials(9:28)-exTrials(1)+1,velPeak(upTrials(9:28)),'bo');
hold on
plot(upTrials(9:28)-exTrials(1)+1,velPeak_c(upTrials(9:28)),'bx');
hold on
plot(downTrials(9:28)-exTrials(1)+1,velPeak(downTrials(9:28)),'ro');
hold on
plot(downTrials(9:28)-exTrials(1)+1,velPeak_c(downTrials(9:28)),'rx');
axis([0 40 0 100]); set(gca,'LineWidth',2,'XTick',[1 20 40],'YTick',[],'YTickLabel',[],'FontName','Arial','FontSize',10); title(['exposure'], 'fontsize',11); xlabel('Trials','fontsize',11);
hold on
subplot('Position',[0.70 0.2 0.24 0.6]); hold on;
plot(upTrials(129:136)-peTrials(1)+1,velPeak(upTrials(129:136)),'bo');
hold on
plot(upTrials(129:136)-peTrials(1)+1,velPeak_c(upTrials(129:136)),'bx');
hold on
plot(downTrials(129:136)-peTrials(1)+1,velPeak(downTrials(129:136)),'ro');
hold on
plot(downTrials(129:136)-peTrials(1)+1,velPeak_c(downTrials(129:136)),'rx');
axis([0 16 0 100]); set(gca,'LineWidth',2,'XTick',[1 16],'YTick',[],'YTickLabel',[],'FontName','Arial','FontSize',10); title(['post-exposure'], 'fontsize',11); xlabel('Trials','fontsize',11);
title([subID(7:9), ' ', 'velPeak'])
%% velPeakTime
velPeakTime(wrong_trial == 1) = NaN;
data = outlier_t(velPeakTime(upTrials(1:8))); % Outlier for visual baseline
velPeakTime_c(upTrials(1:8)) = data;
data = outlier_t(velPeakTime(downTrials(1:8)));
velPeakTime_c(downTrials(1:8)) = data;
clear data;
% Exclude ALL exposure trials from outlier scrubbing
velPeakTime_c(upTrials(9:128)) = velPeakTime(upTrials(9:128));
velPeakTime_c(downTrials(9:128)) = velPeakTime(downTrials(9:128));
% Exclude ALL of post-exposure from outlier scrubbing
velPeakTime_c(upTrials(129:136)) = velPeakTime(upTrials(129:136));
velPeakTime_c(downTrials(129:136)) = velPeakTime(downTrials(129:136));
% transpose and calculate standardized variable
velPeakTime_c = velPeakTime_c';
bkup_mean = nanmean(velPeakTime_c(upTrials(1:8)));
bkup_std = nanstd(velPeakTime_c(upTrials(1:8)));
velPeakTime_up_st = (velPeakTime_c(upTrials) - bkup_mean)/bkup_std;
bkdown_mean = nanmean(velPeakTime_c(downTrials(1:8)));
bkdown_std = nanstd(velPeakTime_c(downTrials(1:8)));
velPeakTime_down_st = (velPeakTime_c(downTrials) - bkdown_mean)/bkdown_std;
clear bkup_mean; clear bkup_std; clear bkdown_mean; clear bkdown_std;
%% Plotting Code for velPeakTime
figure
set(gcf,'Color','w','Position',[560 528 600 420])
hold on;
subplot('Position',[0.06 0.2 0.1 0.6]); hold on;
plot(upTrials(1:8),velPeakTime(upTrials(1:8)),'bo');
hold on
plot(upTrials(1:8),velPeakTime_c(upTrials(1:8)),'bx');
hold on
plot(downTrials(1:8),velPeakTime(downTrials(1:8)),'ro');
hold on
plot(downTrials(1:8),velPeakTime_c(downTrials(1:8)),'rx');
axis([0 16 50 500]); set(gca,'LineWidth',2,'XTick',[1 10 20],'YTick',50:50:500,'YTickLabel', 50:50:500,'FontName','Arial','FontSize',10); ylabel('velPeakTime [ms]'); title('vis-pre','fontsize',11);
hold on
subplot('Position',[0.23 0.2 0.4 0.6]); hold on;
plot(upTrials(9:28)-exTrials(1)+1,velPeakTime(upTrials(9:28)),'bo');
hold on
plot(upTrials(9:28)-exTrials(1)+1,velPeakTime_c(upTrials(9:28)),'bx');
hold on
plot(downTrials(9:28)-exTrials(1)+1,velPeakTime(downTrials(9:28)),'ro');
hold on
plot(downTrials(9:28)-exTrials(1)+1,velPeakTime_c(downTrials(9:28)),'rx');
axis([0 40 50 500]); set(gca,'LineWidth',2,'XTick',[1 20 70 120 140],'YTick',[],'YTickLabel',[],'FontName','Arial','FontSize',10); title(['exposure'], 'fontsize',11); xlabel('Trials','fontsize',11);
hold on
subplot('Position',[0.70 0.2 0.24 0.6]); hold on;
plot(upTrials(129:136)-peTrials(1)+1,velPeakTime(upTrials(129:136)),'bo');
hold on
plot(upTrials(129:136)-peTrials(1)+1,velPeakTime_c(upTrials(129:136)),'bx');
hold on
plot(downTrials(129:136)-peTrials(1)+1,velPeakTime(downTrials(129:136)),'ro');
hold on
plot(downTrials(129:136)-peTrials(1)+1,velPeakTime_c(downTrials(129:136)),'rx');
axis([0 16 50 500]); set(gca,'LineWidth',2,'XTick',[1 20 40],'YTick',[],'YTickLabel',[],'FontName','Arial','FontSize',10); title(['post-exposure'], 'fontsize',11); xlabel('Trials','fontsize',11);
title([subID(7:9), ' ', 'velPeakTime'])
%% Reaction Time (ms)
for i = 1:numTrials
if wrong_trial(i) == 0
RT(i) = onset(i) - sortData(i).EVENTS.TIMES(2)*1000; % Event Code 2 occurs when the targets turn on (measured relative to when hands are statioary in the home positions)
else
RT(i) = NaN;
end
end
RT(wrong_trial == 1) = NaN;
data = outlier_t(RT(upTrials(1:8))); % Outlier for visual baseline
RT_c(upTrials(1:8)) = data;
data = outlier_t(RT(downTrials(1:8)));
RT_c(downTrials(1:8)) = data;
clear data;
% Exclude ALL of exposure from from outlier scrubbing
RT_c(upTrials(9:128)) = RT(upTrials(9:128));
RT_c(downTrials(9:128)) = RT(downTrials(9:128));
% Exclude ALL of post-exposure from outlier scrubbing
RT_c(upTrials(129:136)) = RT(upTrials(129:136));
RT_c(downTrials(129:136)) = RT(downTrials(129:136));
% transpose and calculate standardized variable
RT_c = RT_c';
bkup_mean = nanmean(RT_c(upTrials(1:8)));
bkup_std = nanstd(RT_c(upTrials(1:8)));
RT_up_st = (RT_c(upTrials) - bkup_mean)/bkup_std;
bkdown_mean = nanmean(RT_c(downTrials(1:8)));
bkdown_std = nanstd(RT_c(downTrials(1:8)));
RT_down_st = (RT_c(downTrials) - bkdown_mean)/bkdown_std;
clear bkup_mean; clear bkup_std; clear bkdown_mean; clear bkdown_std;
RT = RT';
%% Plotting Code for RT
figure
set(gcf,'Color','w','Position',[560 528 600 420])
hold on;
subplot('Position',[0.06 0.2 0.1 0.6]); hold on;
plot(upTrials(1:8),RT(upTrials(1:8)),'bo');
hold on
plot(upTrials(1:8),RT_c(upTrials(1:8)),'bx');
hold on
plot(downTrials(1:8),RT(downTrials(1:8)),'ro');
hold on
plot(downTrials(1:8),RT_c(downTrials(1:8)),'rx');
axis([0 16 0 1000]); set(gca,'LineWidth',2,'XTick',[1 16],'YTick',0:100:1000,'YTickLabel', 0:100:1000,'FontName','Arial','FontSize',10); ylabel('RT [ms]'); title('vis-pre','fontsize',11);
hold on
subplot('Position',[0.23 0.2 0.4 0.6]); hold on;
plot(upTrials(9:28)-exTrials(1)+1,RT(upTrials(9:28)),'bo');
hold on
plot(upTrials(9:28)-exTrials(1)+1,RT_c(upTrials(9:28)),'bx');
hold on
plot(downTrials(9:28)-exTrials(1)+1,RT(downTrials(9:28)),'ro');
hold on
plot(downTrials(9:28)-exTrials(1)+1,RT_c(downTrials(9:28)),'rx');
axis([0 40 0 1000]); set(gca,'LineWidth',2,'XTick',[1 20 40],'YTick',[],'YTickLabel',[],'FontName','Arial','FontSize',10); title(['exposure'], 'fontsize',11); xlabel('Trials','fontsize',11);
hold on
subplot('Position',[0.70 0.2 0.24 0.6]); hold on;
plot(upTrials(129:136)-peTrials(1)+1,RT(upTrials(129:136)),'bo');
hold on
plot(upTrials(129:136)-peTrials(1)+1,RT_c(upTrials(129:136)),'bx');
hold on
plot(downTrials(129:136)-peTrials(1)+1,RT(downTrials(129:136)),'ro');
hold on
plot(downTrials(129:136)-peTrials(1)+1,RT_c(downTrials(129:136)),'rx');
axis([0 16 0 1000]); set(gca,'LineWidth',2,'XTick',[1 26],'YTick',[],'YTickLabel',[],'FontName','Arial','FontSize',10); title(['post-exposure'], 'fontsize',11); xlabel('Trials','fontsize',11);
title([subID(7:9), ' ', 'RT'])
%% Movement Path Plots
ang = 0:0.1:2.01*pi;
r_home = sortData(1).TARGET_TABLE.Visual_radius(1); % Home target size
r = sortData(1).TARGET_TABLE.Visual_radius(2); % Target target size
figure
subplot(2,3,1) % Baseline Handpaths
for i = 1:16
if wrong_trial(i) == 0
plot(cursorPosX{i,1}(onset(i):offset(i))*100 - Tx, cursorPosY{i,1}(onset(i):offset(i))*100 - Ty)
hold on
end
end
axis([-5 25 -15 15]); set(gca,'LineWidth',2,'XTick',[-5 10 25],'YTick',[-15 -10 0 10 15],'YTickLabel',[-15 -10 0 10 15],'FontName','Arial','FontSize',10); title('vis-pre','fontsize',11);
axis square
hold on
plot(sortData(1).TARGET_TABLE.X(1)+r_home*cos(ang),sortData(1).TARGET_TABLE.Y(1)+r_home*sin(ang),'Color',[255/255 117/255 56/255]) %home position
hold on
plot(sortData(1).TARGET_TABLE.X(2)+r*cos(ang),sortData(1).TARGET_TABLE.Y(2)+r*sin(ang),'r')
hold on
plot(sortData(1).TARGET_TABLE.X(3)+r*cos(ang),sortData(1).TARGET_TABLE.Y(3)+r*sin(ang),'r')
subplot(2,3,3) % Early Exposure (first 12)
for i = 17:28
if wrong_trial(i) == 0
plot(cursorPosX{i,1}(onset(i):offset(i))*100 - Tx, cursorPosY{i,1}(onset(i):offset(i))*100 - Ty)
hold on
end
end
axis([-5 25 -15 15]); set(gca,'LineWidth',2,'XTick',[-5 10 25],'YTick',[-15 -10 0 10 15],'YTickLabel',[-15 -10 0 10 15],'FontName','Arial','FontSize',10); title('Early Exposure','fontsize',11);
axis square
hold on
plot(sortData(1).TARGET_TABLE.X(1)+r_home*cos(ang),sortData(1).TARGET_TABLE.Y(1)+r_home*sin(ang),'Color',[255/255 117/255 56/255]) %home position
hold on
plot(sortData(1).TARGET_TABLE.X(2)+r*cos(ang),sortData(1).TARGET_TABLE.Y(2)+r*sin(ang),'r')
hold on
plot(sortData(1).TARGET_TABLE.X(3)+r*cos(ang),sortData(1).TARGET_TABLE.Y(3)+r*sin(ang),'r')
subplot(2,3,4) % Late Exposure (last 12)
for i = 45:56
if wrong_trial(i) == 0
plot(cursorPosX{i,1}(onset(i):offset(i))*100 - Tx, cursorPosY{i,1}(onset(i):offset(i))*100 - Ty)
hold on
end
end
axis([-5 25 -15 15]); set(gca,'LineWidth',2,'XTick',[-5 10 25],'YTick',[-15 -10 0 10 15],'YTickLabel',[-15 -10 0 10 15],'FontName','Arial','FontSize',10); title('Late Exposure','fontsize',11);
axis square
hold on
plot(sortData(1).TARGET_TABLE.X(1)+r_home*cos(ang),sortData(1).TARGET_TABLE.Y(1)+r_home*sin(ang),'Color',[255/255 117/255 56/255]) %home position
hold on
plot(sortData(1).TARGET_TABLE.X(2)+r*cos(ang),sortData(1).TARGET_TABLE.Y(2)+r*sin(ang),'r')
hold on
plot(sortData(1).TARGET_TABLE.X(3)+r*cos(ang),sortData(1).TARGET_TABLE.Y(3)+r*sin(ang),'r')
subplot(2,3,5) % Early Post-Exposure (first 8)
for i = 257:264
if wrong_trial(i) == 0
plot(cursorPosX{i,1}(onset(i):offset(i))*100 - Tx, cursorPosY{i,1}(onset(i):offset(i))*100 - Ty)
hold on
end
end
axis([-5 25 -15 15]); set(gca,'LineWidth',2,'XTick',[-5 10 25],'YTick',[-15 -10 0 10 15],'YTickLabel',[-15 -10 0 10 15],'FontName','Arial','FontSize',10); title('Early Post-Exposure','fontsize',11);
axis square
hold on
plot(sortData(1).TARGET_TABLE.X(1)+r_home*cos(ang),sortData(1).TARGET_TABLE.Y(1)+r_home*sin(ang),'Color',[255/255 117/255 56/255]) %home position
hold on
plot(sortData(1).TARGET_TABLE.X(2)+r*cos(ang),sortData(1).TARGET_TABLE.Y(2)+r*sin(ang),'r')
hold on
plot(sortData(1).TARGET_TABLE.X(3)+r*cos(ang),sortData(1).TARGET_TABLE.Y(3)+r*sin(ang),'r')
subplot(2,3,6) % Late Post-Exposure (last 8)
for i = 265:272
if wrong_trial(i) == 0
plot(cursorPosX{i,1}(onset(i):offset(i))*100 - Tx, cursorPosY{i,1}(onset(i):offset(i))*100 - Ty)
hold on
end
end
axis([-5 25 -15 15]); set(gca,'LineWidth',2,'XTick',[-5 10 25],'YTick',[-15 -10 0 10 15],'YTickLabel',[-15 -10 0 10 15],'FontName','Arial','FontSize',10); title([subID(7:9),' ','Late Post-Exposure'],'fontsize',11);
axis square
hold on
plot(sortData(1).TARGET_TABLE.X(1)+r_home*cos(ang),sortData(1).TARGET_TABLE.Y(1)+r_home*sin(ang),'Color',[255/255 117/255 56/255]) %home position
hold on
plot(sortData(1).TARGET_TABLE.X(2)+r*cos(ang),sortData(1).TARGET_TABLE.Y(2)+r*sin(ang),'r')
hold on
plot(sortData(1).TARGET_TABLE.X(3)+r*cos(ang),sortData(1).TARGET_TABLE.Y(3)+r*sin(ang),'r')
%% Data Export
%switch Directory
if strcmp(str,'MACI64') == 1
cd(['/Volumes/mnl/Data/Adaptation/structural_interference/Post_Step_2_train']);
else
cd(['Z:\Data\Adaptation\structural_interference\Post_Step_2_train']); % Lab PCs
end
save([subID(1:13) '_train_postStep2' '.mat'],'sortData','downTrials','upTrials','subID','onset','offset','wrong_trial',...
'ide', 'ide_c', 'ide_down_st', 'ide_up_st',...
'mov_int', 'mov_int_c', 'mov_int_down_st', 'mov_int_up_st',...
'MT', 'MT_c', 'MT_down_st', 'MT_up_st',...
'norm_jerk', 'norm_jerk_c', 'norm_jerk_down_st', 'norm_jerk_up_st',...
'rmse', 'rmse_c', 'rmse_down_st', 'rmse_up_st',...
'velPeak', 'velPeak_c', 'velPeak_down_st', 'velPeak_up_st',...
'velPeakTime', 'velPeakTime_c', 'velPeakTime_down_st', 'velPeakTime_up_st',...
'RT', 'RT_c', 'RT_down_st', 'RT_up_st')