-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjustForFun.m
154 lines (135 loc) · 6.08 KB
/
justForFun.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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% bootstrapped randomly selected references
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all; close all; clc
addpath('/Users/scott/Dropbox/MATLAB/Toolboxes/nifti_tools')
pet_files = dir('/Users/scott/Dropbox/Experiments/nideco/NIDECO/svca4_avc/data_pet/*_flip*' );
gmwm_files = dir('/Users/scott/Dropbox/Experiments/nideco/NIDECO/svca4_avc/gmwm/*_2pet*' );
brain_files = dir('/Users/scott/Dropbox/Experiments/nideco/NIDECO/svca4_avc/roiMasks/*_brainMask*' );
load('/Users/scott/Dropbox/Experiments/nideco/NIDECO/svca4_thals/svca4_thals.mat', 'svca4')
xt = svca4.PET_standardEndTimes; clear svca4;
Nrand = [.1 1];
Nboots = 2000;
Output = zeros(numel(Nrand),Nboots,31,length(pet_files));
for s = 1:length(pet_files)
subj = pet_files(s).name(1:6);
%%% load pet image %%%
PET_struct = load_nii(['/Users/scott/Dropbox/Experiments/nideco/NIDECO/svca4_avc/data_pet/' pet_files(s).name]);
PET = single(PET_struct.img);
%%% load brain mask %%%
% BRAIN_struct = load_nii(['/Users/scott/Dropbox/Experiments/nideco/NIDECO/svca4_avc/roiMasks/' brain_files(s).name]);
% BRAIN = single(BRAIN_struct.img);
% indBRAIN = find(BRAIN==1);
%%% load Grey mask %%%
GM_struct = load_nii(['/Users/scott/Dropbox/Experiments/nideco/NIDECO/svca4_avc/gmwm/' gmwm_files(s).name]);
GM = single(GM_struct.img);
indGM = find(GM==1);
for n = 1:numel(Nrand)
for b = 1:Nboots
randInds = randperm(numel(indGM),round(numel(indGM)*Nrand(n)/100));
for t=1:31
PET_t=PET(:,:,:,t);
TEMP = GM(indGM(randInds)).*PET_t(indGM(randInds));
GRAYt(t) = sum(TEMP(:));
end
GRAYt(:) = GRAYt(:)/numel(randInds);
Output(n,b,:,s) = GRAYt;
end
numVox(n,s) = numel(randInds);
end
% get the cerebellum reference for this subject
tacTable = readtable(['/Users/scott/Dropbox/Experiments/nideco/NIDECO/svca4_thals/TACs/' subj 'CB_GM.txt']);
cereb(:,s) = tacTable.TAC_kBq_cc_;
tacTable = readtable(['/Users/scott/Dropbox/Experiments/nideco/NIDECO/svca4_thals/TACs/' subj 'svcaRef_G0.00W1.00B1.00T1.00.txt']);
thal(:,s) = tacTable.TAC_kBq_cc_;
tacTable = readtable(['/Users/scott/Dropbox/Experiments/nideco/NIDECO/svca4_thals/TACs/' subj 'svcaRef_G0.05W0.05B0.05T0.05.txt']);
thal_q(:,s) = tacTable.TAC_kBq_cc_;
end
%% smallest number of voxels
close all
hf = figure;
xSi = 16;
ySi = 14;
linWidth = 2;
set(hf,'color','w',...
'PaperUnits','centimeters',...
'paperpositionmode','manual',...
'paperposition',[0 0 xSi ySi],...
'papersize',[xSi ySi])
fSize = 5;
mSize = 2.5;
lWidth = 0.8;
ys = .13;
gap = .07;
s = .05;
ax(1) = axes('Position',[0 0 1 1],'Visible','off');
ax(2) = axes('Position',[.105 ys*4+gap*4+s .5-.105 ys]);
ax(3) = axes('Position',[.5+gap ys*4+gap*4+s .5-.105 ys]);
ax(4) = axes('Position',[.105 ys*3+gap*3+s .5-.105 ys]);
ax(5) = axes('Position',[.5+gap ys*3+gap*3+s .5-.105 ys]);
ax(6) = axes('Position',[.105 ys*2+gap*2+s .5-.105 ys]);
ax(7) = axes('Position',[.5+gap ys*2+gap*2+s .5-.105 ys]);
ax(8) = axes('Position',[.105 ys+gap+s .5-.105 ys]);
ax(9) = axes('Position',[.5+gap ys+gap+s .5-.105 ys]);
ax(10) = axes('Position',[.105 s .5-.105 ys]);
ax(11) = axes('Position',[.5+gap s .5-.105 ys]);
for s = 1:length(pet_files)
x=s+1;
p(1,:) = plot(ax(x),xt,squeeze(Output(1,:,:,s)),'-k','LineWidth',lWidth);hold(ax(x),'on')
p2 = plot(ax(x),xt,cereb(:,s),'-g','LineWidth',lWidth);
p3 = plot(ax(x),xt,thal(:,s),'-c','LineWidth',lWidth);
p4 = plot(ax(x),xt,thal_q(:,s),'-r','LineWidth',lWidth);
xlim(ax(x),[0 3600])
ylabel(ax(x),'kBq/cc')
set(ax(x),'box','off')
%hl = legend(ax(x),[p2 p3 p4 p(1,1)],{'Cerebellum','svca_thal','svca_thal_q','Random'},'location','northoutside','orientation','horizontal','interpreter','none');
%set(hl,'box','off')
end
hl = legend(ax(2),[p2 p3 p4 p(1,1)],{'Cerebellum','svca_thal','svca_thal_q','Random'},'location','northoutside','orientation','horizontal','interpreter','none');
set(hl,'box','off')
set(findall(gcf,'type','axes'),'FontSize',fSize)
print(gcf,'-dpng', '-r300','/Users/scott/GoogleDrive/pet_avc/TheSVCAPaper/figures/Love_ForFunSmall.png')
%% smallest number of voxels
close all
hf = figure;
xSi = 16;
ySi = 14;
linWidth = 2;
set(hf,'color','w',...
'PaperUnits','centimeters',...
'paperpositionmode','manual',...
'paperposition',[0 0 xSi ySi],...
'papersize',[xSi ySi])
fSize = 5;
mSize = 2.5;
lWidth = 0.8;
ys = .13;
gap = .07;
s = .05;
ax(1) = axes('Position',[0 0 1 1],'Visible','off');
ax(2) = axes('Position',[.105 ys*4+gap*4+s .5-.105 ys]);
ax(3) = axes('Position',[.5+gap ys*4+gap*4+s .5-.105 ys]);
ax(4) = axes('Position',[.105 ys*3+gap*3+s .5-.105 ys]);
ax(5) = axes('Position',[.5+gap ys*3+gap*3+s .5-.105 ys]);
ax(6) = axes('Position',[.105 ys*2+gap*2+s .5-.105 ys]);
ax(7) = axes('Position',[.5+gap ys*2+gap*2+s .5-.105 ys]);
ax(8) = axes('Position',[.105 ys+gap+s .5-.105 ys]);
ax(9) = axes('Position',[.5+gap ys+gap+s .5-.105 ys]);
ax(10) = axes('Position',[.105 s .5-.105 ys]);
ax(11) = axes('Position',[.5+gap s .5-.105 ys]);
for s = 1:length(pet_files)
x=s+1;
p(1,:) = plot(ax(x),xt,squeeze(Output(end,:,:,s)),'-k','LineWidth',lWidth);hold(ax(x),'on')
p2 = plot(ax(x),xt,cereb(:,s),'-g','LineWidth',lWidth);
p3 = plot(ax(x),xt,thal(:,s),'-c','LineWidth',lWidth);
p4 = plot(ax(x),xt,thal_q(:,s),'-r','LineWidth',lWidth);
xlim(ax(x),[0 3600])
ylabel(ax(x),'kBq/cc')
set(ax(x),'box','off')
%hl = legend(ax(x),[p2 p3 p4 p(1,1)],{'Cerebellum','svca_thal','svca_thal_q','Random'},'location','northoutside','orientation','horizontal','interpreter','none');
%set(hl,'box','off')
end
hl = legend(ax(2),[p2 p3 p4 p(1,1)],{'Cerebellum','svca_thal','svca_thal_q','Random'},'location','northoutside','orientation','horizontal','interpreter','none');
set(hl,'box','off')
set(findall(gcf,'type','axes'),'FontSize',fSize)
print(gcf,'-dpng', '-r300','/Users/scott/GoogleDrive/pet_avc/TheSVCAPaper/figures/Love_ForFunLarge.png')