-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCode_Figure2.m
112 lines (94 loc) · 2.81 KB
/
Code_Figure2.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
clc; clear all;
%% CODE TO PLOT FIGURE 2
%
% Whole-brain multimodal neuroimaging model using serotonin receptor maps explain non-linear functional effects of LSD
% Deco,G., Cruzat,J., Cabral, J., Knudsen,G.M., Carhart-Harris,R.L., Whybrow,P.C.,
% Logothetis,N.K. & Kringelbach,M.L. (2018) Current Biology
%
% Illustration of the sliding-window, FCD and histogram.
% Written by Joana Cabral [email protected]
% October 2017, Barcelona-Spain
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Load BOLD signal from one subject
load LSDnew.mat tc_aal
subject=7;
scan=5; % 5 = Placebo, 2 = LSD
BOLD=tc_aal{subject,scan};
clear tc_aal
[N, Tmax]=size(BOLD);
TR=2;
% Bandpass filter settings
fnq=1/(2*TR); % Nyquist frequency
flp = .02; % lowpass frequency of filter
fhi = 0.1; % highpass
Wn=[flp/fnq fhi/fnq]; % butterworth bandpass non-dimensional frequency
k=2; % 2nd order butterworth filter
[bfilt,afilt]=butter(k,Wn); % construct the filter
BOLD_filt=zeros(size(BOLD));
%Get the BOLD phase using the Hilbert transform
for seed=1:N
ts=detrend(BOLD(seed,:)-mean(BOLD(seed,:)));
ts(ts>3*std(ts))=3*std(ts); % Remove strong artefacts
ts(ts<-3*std(ts))=-3*std(ts); % Remove strong artefacts
BOLD_filt(seed,:) =filtfilt(bfilt,afilt,ts); % Band pass filter
end
clear BOLD ts
% Define parameters for Dynamic FC analysis
slide=3;
window=30;
t_windows=1:slide:Tmax-window;
N_windows=length(t_windows);
FC=zeros(N_windows,N,N);
FCD=zeros(N_windows);
Isubdiag = find(tril(ones(N),-1)); % Indices of triangular lower part of matrix
Order=[1:2:N N:-2:2];
% Compute FC for each sliding window
for nw=1:N_windows
t=t_windows(nw);
FC(nw,:,:)=corrcoef((BOLD_filt(:,t:t+window))');
end
% Compute the FCD matrix
for nw1=1:N_windows
FC1=FC(nw1,:,:);
for nw2=nw1:N_windows
FC2=FC(nw2,:,:);
FCD(nw1,nw2)=corr2(FC1(Isubdiag),FC2(Isubdiag));
end
end
% PLOTS
figure
colormap(jet)
% Plot the filtered BOLD signal
subplot(3,5,1:3)
plot(1:TR:Tmax*TR,BOLD_filt')
box off
ylabel('BOLD signal')
xlabel('Time (s)')
set(gca,'XTick',50:50:400)
xlim([0 Tmax*TR])
% Plot some X FC matrices (equally spaced)
X=10;
for u=1:X
nw=round(u*N_windows/X);
subplot(3,X,X+u)
imagesc(squeeze(FC(nw,Order,Order)))
axis square
set(gca,'XTick',[])
set(gca,'YTick',[])
end
% Plot the FCD matrix
subplot(3,5,11)
imAlpha=triu(ones(N_windows),1);
imagesc(t_windows*TR,t_windows*TR,FCD,'AlphaData',imAlpha)
xlabel('Time X (s)')
ylabel('Time Y (s)')
title ('FCD')
axis square
colorbar
% Plot the FCD histogram
subplot(3,5,13)
histogram(FCD(imAlpha==1),50,'EdgeColor','w','Facecolor','b')
box off
xlabel('FCD values')
ylabel('Count')