-
Notifications
You must be signed in to change notification settings - Fork 0
/
F_average_connectomnes_d28_d29.m
73 lines (56 loc) · 2.44 KB
/
F_average_connectomnes_d28_d29.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
%% Isotta Rigoni
% ~ EEG and Epilepsy Unit- Geneva HUG
%This script average connectomes between day 28 and day 29 (for each animal)
%as described in the third paragraph of the section "Statistical analyses"
% -------> change path at line 20
clear all
close all
clc
%% variable initialisation
%-----------------------------------------
day={'d28' 'd29'}; %time points of observation
subj=[12 13 15:20 22:33]; %animal ID
% %-----------------------------------------
BIDSfolder='H:\Isotta\DATA\ir_mice_project\RS\data2publish\derivatives';
task='task-rest';
% n_elec=30;
derivative_folder='wpli';
%% calculate
for s=1:length(subj)
%subject id
sub_id=subj(s);
for d=1:length(day)
%get network metric for each session: d0, d28 or d29
%session ID
ses_id=['ses-',char(day(d))];
% ------------ Load network data ----------------------------------
%load connectivity matrix
load(fullfile(BIDSfolder,derivative_folder,['sub-',sprintf('%02d',sub_id)],ses_id,'eeg',...
['sub-',sprintf('%02d',sub_id),'_',ses_id,'_',task,'.mat']));
%save metrics
wpli_avg_delta_2d(:,:,d)=wpli_avg_delta;
wpli_avg_lowTheta_2d(:,:,d)=wpli_avg_lowTheta;
wpli_avg_highTheta_2d(:,:,d)=wpli_avg_highTheta;
wpli_avg_beta_2d(:,:,d)=wpli_avg_beta;
wpli_avg_gamma_2d(:,:,d)=wpli_avg_gamma;
wpli_avg_2d(:,:,d)=wpli_avg;
clear wpli_avg_delta wpli_avg_lowTheta wpli_avg_highTheta wpli_avg_beta wpli_avg_gamma
end
wpli_avg_delta=squeeze(mean(wpli_avg_delta_2d,3));
wpli_avg_lowTheta=squeeze(mean(wpli_avg_lowTheta_2d,3));
wpli_avg_highTheta=squeeze(mean(wpli_avg_highTheta_2d,3));
wpli_avg_beta=squeeze(mean(wpli_avg_beta_2d,3));
wpli_avg_gamma=squeeze(mean(wpli_avg_gamma_2d,3));
wpli_avg=squeeze(mean(wpli_avg_2d,3));
%store results in derivatives
%define final name and folder
final_folder=fullfile(BIDSfolder,'wpli',['sub-',sprintf('%02d',sub_id)],'ses-d28-d29','eeg');
final_filename=['sub-',sprintf('%02d',sub_id),'_',ses_id,'_',task,''];
if ~exist(final_folder)
mkdir(final_folder)
end
%save in BIDS
save(fullfile(final_folder,final_filename),...
'wpli_avg','wpli_avg_delta','wpli_avg_lowTheta','wpli_avg_highTheta','wpli_avg_beta','wpli_avg_gamma','-v7.3')
clear wpli_avg_delta wpli_avg_lowTheta wpli_avg_highTheta wpli_avg_beta wpli_avg_gamma
end