-
Notifications
You must be signed in to change notification settings - Fork 0
/
f12_new_analysis_PD.m
228 lines (170 loc) · 5.28 KB
/
f12_new_analysis_PD.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
% we make the new analysis
s=load('sd.mat');
addpath('hmm_new');
% so clean up the following code a little bit -- then allow selection of N
% states - then allow determination of task, too.
cmat=[[230, 25, 75];...
[60, 180, 75];...
[255, 225, 25];...
[0, 130, 200];...
[245, 130, 48];...
[70, 240, 240];...
[240, 50, 230];...
[250, 190, 190];...
[0, 128, 128];...
[230, 190, 255];...
[170, 110, 40];...
[255, 250, 200];...
[128, 0, 0];...
[170, 255, 195];...
[0, 0, 128];...
[128, 128, 128];...
[255, 255, 255];...
[0, 0, 0]];
%
%
% all this to extract subs_to_use -- which subject we will use in this
%
%
%
% analysis (i.e., 'all').
% deal with the subjects...
slist=struct();
slist.mov1a = [1:21];
slist.mov2a = [1:16 18:21];
slist.resta = [1:21];
slist.mov1b = [2:5 7:14 16:20];
slist.restb = [2:5 7:14 16:20];
% incorporate bad subjects -- that are OVERALL bad:
bads = [4 13 15];
fns=fieldnames(slist);
for i=1:numel(fns)
for j=1:numel(bads)
slist.(fns{i})(slist.(fns{i})==bads(j))=[];
end
end
% then incorporate the occasioal bads:
slist.mov2a(slist.mov2a==11)=[];
slist.mov2a=sort([slist.mov2a 15]);
slist.resta(slist.resta==5)=[];
slist.resta(slist.restb==6)=[];
analyses = {...
{'mov1a'},'mov1a'; ... % only mov1
{'mov1b'},'mov1b'; ... % only mov2 day2
{'mov1a','mov1b'},'mov1a-1b'; ... % mov1 day and and day 2
{'resta'},'resta'; ... % only resta
{'restb'},'restb'; ... % only rest day 2
{'resta','restb'},'resta-b'; ... % rest a and rest day 2
{'mov1a','mov1b','resta','restb'},'all'; ... % all movie and rest day 1 aand day 2 but not repeats
};
load valid_inferences_all.mat
% pick any inference you wish to check here
this_inference=valid_inferences(1);
scan_names = analyses{7, 1};
analysis = analyses{7, 2};
% scan_names = {'mov1a','mov1b'};
% scan_names= {'mov1a'};
subs_to_use = [1:21]; % magic to make sure that IF you specified more than one functional task,
% subjects that do NOT have done them ALL are excluded.Otherwise
% hmm gets confused, I think.
nsubs=21;
for i=1:numel(scan_names)
subs_to_use = intersect(subs_to_use, slist.(scan_names{i}));
nsubs=numel(subs_to_use);
end
% grab the pupil Diameter
eph = load('../data/physiological/PD/s.mat');
eph_part = eph.s;
% EYE
% we go thourgh the states
all_pnts={};
t_pnts=[];
p_pnts=[];
npt_pnts=[];
my_s=s.sd(1).aroma.all.(sprintf('sm%d',this_inference));
for iState=1:10
pnts=[];
sd_pnts=[];
n_pnts=[];
% we go thorugh the subjects...
for iSub=1:numel(subs_to_use)
sub=subs_to_use(iSub);
part=my_s.(sprintf('s%d',sub));
% check mov1a
hrdata=[];
hmmdata=[];
% if isfield(part.mov1a,'eyedata')
% hrdata=[hrdata; part.mov1a.eyedata];
% hmmdata=[hmmdata; part.mov1a.hmmmat(:, iState)];
% end
% the variable name is hrdata; but it is PD data.
if isfield(eph_part.mov1b,sprintf('s%.3d',iSub))
hrdata=[hrdata; eph_part.mov1b.(sprintf('s%.3d',iSub))(6:end)];
hmmdata=[hmmdata; part.mov1b.hmmmat(:, iState)];
end
if sum(hmmdata) > 0 && numel(hrdata)>0
hrdata=hrdata-mean(hrdata);
pnts(end+1) = mean(hrdata(hmmdata==1));
sd_pnts(end+1) = std(hrdata(hmmdata==1));
% n_pnts(end+1) = numel(pnts);
end
end
npt_pnts(end+1)=numel(pnts);
all_pnts{end+1} = pnts;
[H,P,CI,STATS] = ttest(pnts);
% [P2,CI2,STATS2] = kruskalwallis(pnts);
t_pnts(end+1)=H;
p_pnts(end+1)=P;
% npt_pnts(end+1) = P2;
end
%
%
y = num2cell(1:numel(all_pnts));
x = cellfun(@(x, y) [x(:) y*ones(size(x(:)))], all_pnts, y, 'UniformOutput', 0); % adding labels to the cells
X = vertcat(x{:});
%
figure;
boxplot(X(:,1), X(:,2));
%
%
% anno_mat = load('/home/johan/mnt/hpcworking/projects/hmm-movie/rawdata/1_Data/Annotation/annobigmat.mat');
% am=anno_mat.bigmat(6:end,:);
% bigmat_labels={'language','changepoint','plottwist','faces +','n','-','scenes +','n','-'};
%
% am2=am(:, [4 6 7 9 1 2]);
% al2=bigmat_labels([4 6 7 9 1 2]);
subs_to_use=[2 3 7 8 9 10 11 12 14 16 17 18 19 20];
state_consistency = {};
for iState=1:10
c=[];
for iSub=1:numel(subs_to_use)
sub=subs_to_use(iSub);
part=my_s.(sprintf('s%d',sub));
c=[c part.mov1a.hmmmat(:, iState)];
end
inds_to_check1 = sum(c')>=13;
c=[];
for iSub=1:numel(subs_to_use)
sub=subs_to_use(iSub);
part=my_s.(sprintf('s%d',sub));
c=[c part.mov1b.hmmmat(:, iState)];
end
inds_to_check2 = sum(c')>=13;
if sum(inds_to_check1)>0 || sum(inds_to_check2)>0
state_consistency{iState} = logical(inds_to_check1) | logical(inds_to_check2);
end
end
% check if things are different where there is a highly salient episode in
% the movie
meanvals=[];
for i=1:10
meanvals(end+1) = mean(all_pnts{i});
end
s=sprintf('Deviation from Mean Value during brain state visits, values\n');
s=[s sprintf('%.4f\t',meanvals)];
s=[s sprintf('\n')];
s=[s sprintf('Deviation from Mean Value during brain state visits, p-values\n')];
s=[s sprintf('%.4f\t',p_pnts)];
s=[s sprintf('\n')];
s=[s sprintf('\n')];
fprintf(s);