-
Notifications
You must be signed in to change notification settings - Fork 0
/
import_new_nf_pilot_data_fMRI.m
210 lines (170 loc) · 6.8 KB
/
import_new_nf_pilot_data_fMRI.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
% import_new_nf_pilot_data
cd('~/'Google Drive'/skinner/'protocols '/Pecina_k/new_task_design/Behavioral/')
% subs = ls
% d = dir(pwd);
% isub = [d(:).isdir]; %# returns logical vector
% nameFolds = {d(isub).name}';
% %remove . and ..
% nameFolds(ismember(nameFolds,{'.','..','.git'})) = [];
%
% data = [];
% for sub = 1:length(nameFolds)
% curdir = char(nameFolds(sub));
% cd(curdir)
% l = (what(pwd));
% file = l.mat;
% b = load(char(file));
% b.RunDesign(:,1) = cellstr(num2str(sub));
% data = [data; b.RunDesign];
% cd('../')
% end
% b = cell2table(data);
% for sub = 1:
% cd('1');
data = readtable('SON1_MDF.csv');
% cd('../2');
% data = [data; readtable('2_V2_Run_01_20170118_153227.csv')];
% cd('../3');
% data = [data; readtable('3_V3_Run_01_20170118_155821.csv')];
% cd('../4');
% data = [data; readtable('7_V4_Run_01_20170120_133616.csv')];
% rename for brevity
b = data;
b.atrials = b.InfusionNum ==1;
b.btrials = b.InfusionNum ==2;
b.ctrials = b.InfusionNum ==3;
b.dtrials = b.InfusionNum ==4;
b.exp = (strcmp(b.WillImpRespText, 'Yes'));
b.exp = double(b.exp);
b.exp(strcmp(b.WillImpRespText, 'NaN')) = NaN;
b.improve = (strcmp(b.ImprovedRespText, 'Yes'));
b.improve = double(b.improve);
b.improve(strcmp(b.ImprovedRespText, 'NaN')) = NaN;
figure(2);clf;
plot(smooth(b.improve(b.atrials))); hold on;
plot(smooth(b.improve(b.btrials)))
plot(smooth(b.improve(b.ctrials)))
plot(smooth(b.improve(b.dtrials))); hold off
% plot learning curves for stim A for each subject
pts = unique(b.Participant);
ntrials = 128;
a_stim_ratings = NaN(length(pts),ntrials/4);
b_stim_ratings = NaN(length(pts),ntrials/4);
c_stim_ratings = NaN(length(pts),ntrials/4);
d_stim_ratings = NaN(length(pts),ntrials/4);
%% NB: this is actually ratings of improvement, not expectations
for sub = 1:length(pts)
a_stim_ratings(sub,:) = b.improve(strcmp(b.Participant,pts(sub)) & b.atrials);
b_stim_ratings(sub,:) = b.improve(strcmp(b.Participant,pts(sub)) & b.btrials);
c_stim_ratings(sub,:) = b.improve(strcmp(b.Participant,pts(sub)) & b.ctrials);
d_stim_ratings(sub,:) = b.improve(strcmp(b.Participant,pts(sub)) & b.dtrials);
end
figure(1);clf;
for sub = 1:3;
subplot(1,3,sub)
plot(smooth(a_stim_ratings(sub,:))'); axis([0 18 0 1])
hold on;
plot(smooth(b_stim_ratings(sub,:))')
plot(smooth(c_stim_ratings(sub,:))', '*-')
plot(smooth(d_stim_ratings(sub,:))', '*-')
hold off;
end
figure(2);clf;
subplot(1,4,1)
plot(smooth(a_stim_ratings(1,:))', 'b'); hold on; axis([0 18 0 1]); title('A')
plot(smooth(a_stim_ratings(2,:))', 'b')
plot(smooth(a_stim_ratings(3,:))', 'b')
plot(smooth(median((a_stim_ratings))), 'b', 'LineWidth', 5); hold off;
subplot(1,4,2)
plot(smooth(b_stim_ratings(1,:))', 'r'); hold on;axis([0 18 0 1]); title('B')
plot(smooth(b_stim_ratings(2,:))', 'r')
plot(smooth(b_stim_ratings(3,:))', 'r')
plot(smooth(median((b_stim_ratings))), 'r', 'LineWidth', 5); hold off;
subplot(1,4,3)
plot(smooth(c_stim_ratings(1,:))','g'); hold on; axis([0 18 0 1]); title('C')
plot(smooth(c_stim_ratings(2,:))', 'g')
plot(smooth(c_stim_ratings(3,:))','g')
plot(smooth(median((c_stim_ratings))), 'g', 'LineWidth', 5); hold off;
subplot(1,4,4)
plot(smooth(d_stim_ratings(1,:))'); hold on;axis([0 18 0 1]); title('D')
plot(smooth(d_stim_ratings(2,:))', 'm')
plot(smooth(d_stim_ratings(3,:))', 'm')
plot(smooth(median((d_stim_ratings))), 'm', 'LineWidth', 5); hold off;
% plot feedback ratings
a_feed_ratings = NaN(length(pts),ntrials/4);
b_feed_ratings = NaN(length(pts),ntrials/4);
c_feed_ratings = NaN(length(pts),ntrials/4);
d_feed_ratings = NaN(length(pts),ntrials/4);
%% NOW EXPECTANCY rtings
for sub = 1:length(pts)
a_feed_ratings(sub,:) = b.exp(strcmp(b.Participant,pts(sub)) & b.atrials);
b_feed_ratings(sub,:) = b.exp(strcmp(b.Participant,pts(sub)) & b.btrials);
c_feed_ratings(sub,:) = b.exp(strcmp(b.Participant,pts(sub)) & b.ctrials);
d_feed_ratings(sub,:) = b.exp(strcmp(b.Participant,pts(sub)) & b.dtrials);
end
figure(3);clf;
for sub = 1:3;
subplot(1,3,sub)
plot(smooth(a_feed_ratings(sub,:))')
hold on;
plot(smooth(b_feed_ratings(sub,:))')
plot(smooth(c_feed_ratings(sub,:))', '*-')
plot(smooth(d_feed_ratings(sub,:))', '*-')
hold off;
title('Feedback ratings')
end
figure(4);clf;
subplot(1,4,1)
plot(smooth(a_feed_ratings(1,:))', 'b'); hold on; axis([0 18 0 1])
plot(smooth(a_feed_ratings(2,:))', 'b')
plot(smooth(a_feed_ratings(3,:))', 'b')
plot(smooth(a_feed_ratings(4,:))', 'b')
plot(smooth(nanmean((a_feed_ratings))), 'b', 'LineWidth', 5); hold off;
subplot(1,4,2)
plot(smooth(b_feed_ratings(1,:))', 'r'); hold on;axis([0 18 0 1])
plot(smooth(b_feed_ratings(2,:))', 'r')
plot(smooth(b_feed_ratings(3,:))', 'r')
plot(smooth(b_feed_ratings(4,:))', 'r');
plot(smooth(nanmean((b_feed_ratings))), 'r', 'LineWidth', 5); hold off;
subplot(1,4,3)
plot(smooth(c_feed_ratings(1,:))', 'g'); hold on; axis([0 18 0 1])
plot(smooth(c_feed_ratings(2,:))', 'g')
plot(smooth(c_feed_ratings(3,:))', 'g')
plot(smooth(c_feed_ratings(4,:))', 'g');
plot(smooth(nanmean((c_feed_ratings))), 'g', 'LineWidth', 5); hold off;
subplot(1,4,4)
plot(smooth(d_feed_ratings(1,:))', 'm'); hold on;axis([0 18 0 1])
plot(smooth(d_feed_ratings(2,:))', 'm')
plot(smooth(d_feed_ratings(3,:))', 'm')
plot(smooth(d_feed_ratings(4,:))', 'm');
plot(smooth(nanmean((d_feed_ratings))), 'm', 'LineWidth', 5); hold off;
title('Feedback ratings: subplot = stimulus, line = subject')
figure(5)
subplot(1,2,1);
plot(smooth(nanmean((a_stim_ratings))), 'LineWidth', 5); hold on;
plot(smooth(nanmean((b_stim_ratings))), 'LineWidth', 5);
plot(smooth(nanmean((c_stim_ratings))),'LineWidth', 5);
plot(smooth(nanmean((d_stim_ratings))),'LineWidth', 5); hold off;
title('Mean expectancy ratings'); legend('drug A', 'drug B', 'cal. C', ' cal. D')
subplot(1,2,2);
plot(smooth(nanmean((a_feed_ratings))), 'LineWidth', 5); hold on;
plot(smooth(nanmean((b_feed_ratings))), 'LineWidth', 5);
plot(smooth(nanmean((c_feed_ratings))), 'LineWidth', 5);
plot(smooth(nanmean((d_feed_ratings))), 'LineWidth', 5); hold off;
title('Mean neuro-feedback ratings'); legend('drug A', 'drug B', 'cal. C', ' cal. D')
figure(6)
subplot(1,2,1);
plot((nanmean((a_stim_ratings))),'*:', 'LineWidth', 2); hold on;
plot((nanmean((b_stim_ratings))),'*:', 'LineWidth', 2);
plot((nanmean((c_stim_ratings))),'*:', 'LineWidth', 2);
plot((nanmean((d_stim_ratings))),'*:','LineWidth', 2); hold off;
title('Unsmoothed mean expectancy ratings'); legend('drug A', 'drug B', 'cal. C', ' cal. D')
subplot(1,2,2);
plot((nanmean((a_feed_ratings))),'*:', 'LineWidth', 2); hold on;
plot((nanmean((b_feed_ratings))), '*:', 'LineWidth', 2);
plot((nanmean((c_feed_ratings))), '*:','LineWidth', 2);
plot((nanmean((d_feed_ratings))), '*:','LineWidth', 2); hold off;
title('Unsmoothed mean neuro-feedback ratings'); legend('drug A', 'drug B', 'cal. C', ' cal. D')
% save data
cd('../')
writetable(b,'pilot_behav','FileType','text')