-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplotBDST_sideOfSpace.m
205 lines (161 loc) · 6.89 KB
/
plotBDST_sideOfSpace.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
function plotBDST_sideOfSpace(thisVarStr,data,conditionNames,outDir,axisVal_y)
%% Print BDST data (and Plot), for side of space
fprintf('Printing Crawford BDST Input for SIDE OF SPACE \nVariable:\n%s \n================\n', thisVarStr)
%% gather each condition data
for c = 1:4
currConditionName = conditionNames{c};
controlMean(:,c) = mean(data.targetMean(2:end,:,c));
controlStd(:,c) = std(data.targetMean(2:end,:,c));
patientScores(:,c) = data.targetMean(1,:,c);
nC(:,c) = size(patientScores,2);
%get each control's mean for plotting
allControls{c} = data.targetMean(2:end,:,c);
end
Ncontrols = size(allControls{1},1); %assuming all targets/conditions same!
%% Now collapse Left/Right Space!!
for c = 1:4
controlMean2(1,c) = mean(controlMean(1:3,c)); %left
controlMean2(2,c) = controlMean(4,c); %foveal
controlMean2(3,c) = mean(controlMean(5:7,c)); %right
controlStd2(1,c) = mean(controlStd(1:3,c)); %left
controlStd2(2,c) = controlStd(4,c); %foveal
controlStd2(3,c) = mean(controlStd(5:7,c)); %right
patientScores2(1,c) = mean(patientScores(1:3,c)); %left
patientScores2(2,c) = patientScores(4,c); %foveal
patientScores2(3,c) = mean(patientScores(5:7,c)); %right
for controls = 1:length(allControls{c})
allControls2{c}(controls,1) = mean(allControls{c}(controls,1:3)); %left
allControls2{c}(controls,2) = allControls{c}(controls,4); %foveal
allControls2{c}(controls,3) = mean(allControls{c}(controls,5:7)); %right
end
end
controlMean = controlMean2;
controlStd = controlStd2;
patientScores = patientScores2;
allControls = allControls2;
%Important -
%setup so good condition first (e.g. RH or Free Vision) to then subtract bad condition
%(e.g. LH or Per Vision). Thus, plotBDST(taskY - TaskX) means that a positive
%score shows the degree of impairment at LH or at Per Vision
listHand = {'RH','LH'};
listVision = {'FREE','PER'};
%% --- Compare Vision First: free vs per ---%
currHand = [];
currVision = [];
taskX = [];
taskY = [];
rr = [];
for hand = 1:2
currHand = listHand{hand};
fprintf('Comparing Free vs Peripheral for Hand: %s\n===========\n',currHand)
taskX.idx = contain([currHand,listVision{1}],conditionNames);
taskY.idx = contain([currHand,listVision{2}],conditionNames);
taskX.controlMean = controlMean(:,taskX.idx);
taskX.controlStd = controlStd(:,taskX.idx);
taskX.patientScores = patientScores(:,taskX.idx);
taskX.allControls = cell2mat(allControls(:,taskX.idx));
taskY.controlMean = controlMean(:,taskY.idx);
taskY.controlStd = controlStd(:,taskY.idx);
taskY.patientScores = patientScores(:,taskY.idx);
taskY.allControls = cell2mat(allControls(:,taskY.idx));
%%correlation (pearson r) between control performance in taskX & taskY
for t = 1:length(taskX.patientScores)
[r,~] = corrcoef(taskX.allControls(:,t),taskY.allControls(:,t));
rr(t) = r(1,2);
end
%Print info for Crawford.exe
fprintf('TaskX = %s Task Y = %s\n---------\n',listVision{1},listVision{2})
for t = 1:length(taskX.patientScores)
fprintf('Current Target: %s\n----------\n',num2str(t))
fprintf('Control Mean TaskX: %s\n',num2str(taskX.controlMean(t)))
fprintf('Control Std TaskX: %s\n',num2str(taskX.controlStd(t)))
fprintf('Control Mean TaskY: %s\n',num2str(taskY.controlMean(t)))
fprintf('Control Std TaskY: %s\n',num2str(taskY.controlStd(t)))
fprintf('Control Corr(TaskX,TaskY): %s\n',num2str(rr(t)))
fprintf('Control Group N: %s\n',num2str(Ncontrols))
fprintf('Patient Score TaskX: %s\n',num2str(taskX.patientScores(t)))
fprintf('Patient Score TaskY: %s\n',num2str(taskY.patientScores(t)))
fprintf('----------\n')
end
%% plot
plotBDST(taskX,taskY,Ncontrols)
pause(0.5)
%% other plot formatting
titleStr = ['CompareVision-PeripheralSubtractFree-',currHand];
xlabel(['Field of View']);
ylabel(thisVarStr)
xlim([0 length(taskX.patientScores)+1]); set(gca,'XTick',[0:1:length(taskX.patientScores)+1]);
ylim(axisVal_y)
xticklabels({[],'Left','Foveal','Right'});
set(gca,'box','off','color','none','TickDir','out','fontsize',25);
title(titleStr);
%% save plot
outDir2 = fullfile(outDir,'sideOfSpace_BDST');
if ~exist(outDir2)
mkdir(outDir2)
end
outName = fullfile(outDir2,[thisVarStr,titleStr]);
cmdStr = sprintf('export_fig %s.jpg',outName)
eval(cmdStr);
end
%% --- Now Compare Hand : LH vs RH ---%
%strreplace hand/vision
currHand = [];
currVision = [];
taskX = [];
taskY = [];
rr = [];
for vision = 1:2
currVision = listVision{vision};
fprintf('Comparing LH vs RH for Vision: %s\n===========\n',currVision)
taskX.idx = contain([listHand{1},currVision],conditionNames);
taskY.idx = contain([listHand{2},currVision],conditionNames);
taskX.controlMean = controlMean(:,taskX.idx);
taskX.controlStd = controlStd(:,taskX.idx);
taskX.patientScores = patientScores(:,taskX.idx);
taskX.allControls = cell2mat(allControls(:,taskX.idx));
taskY.controlMean = controlMean(:,taskY.idx);
taskY.controlStd = controlStd(:,taskY.idx);
taskY.patientScores = patientScores(:,taskY.idx);
taskY.allControls = cell2mat(allControls(:,taskY.idx));
%%correlation (pearson r) between control performance in taskX & taskY
for t = 1:length(taskX.patientScores)
[r,~] = corrcoef(taskX.allControls(:,t),taskY.allControls(:,t));
rr(t) = r(1,2);
end
%Print info for Crawford.exe
fprintf('TaskX = %s Task Y = %s\n---------\n',listVision{1},listVision{2})
for t = 1:length(taskX.patientScores)
fprintf('Current Target: %s\n----------\n',num2str(t))
fprintf('Control Mean TaskX: %s\n',num2str(taskX.controlMean(t)))
fprintf('Control Std TaskX: %s\n',num2str(taskX.controlStd(t)))
fprintf('Control Mean TaskY: %s\n',num2str(taskY.controlMean(t)))
fprintf('Control Std TaskY: %s\n',num2str(taskY.controlStd(t)))
fprintf('Control Corr(TaskX,TaskY): %s\n',num2str(rr(t)))
fprintf('Control Group N: %s\n',num2str(Ncontrols))
fprintf('Patient Score TaskX: %s\n',num2str(taskX.patientScores(t)))
fprintf('Patient Score TaskY: %s\n',num2str(taskY.patientScores(t)))
fprintf('----------\n')
end
%% plot
plotBDST(taskX,taskY,Ncontrols)
pause(0.5)
%% other plot formatting
titleStr = ['CompareHand-LHSubtractRH-',currVision];
xlabel(['Field of View']);
ylabel(thisVarStr)
xlim([0 length(taskX.patientScores)+1]); set(gca,'XTick',[0:1:length(taskX.patientScores)+1]);
ylim(axisVal_y)
xticklabels({[],'Left','Foveal','Right'});
set(gca,'box','off','color','none','TickDir','out','fontsize',25);
title(titleStr);
%% save plot
outDir2 = fullfile(outDir,'sideOfSpace_BDST');
if ~exist(outDir2)
mkdir(outDir2)
end
outName = fullfile(outDir2,[thisVarStr,titleStr]);
cmdStr = sprintf('export_fig %s.jpg',outName)
eval(cmdStr);
end
end