-
Notifications
You must be signed in to change notification settings - Fork 2
/
calc_net_grad_vals_Schef.m
88 lines (75 loc) · 4.04 KB
/
calc_net_grad_vals_Schef.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
% derive gradient values for each network at each scale
%addpath(genpath('/cbica/projects/pinesParcels/multiscale/scripts/derive_parcels/Toolbox'));
ProjectFolder = '/project/imco/baller/processed_data/yeo_network_data/eb_analyses';
% get gradients
% 2/5/21 - change this to group-level coupling*Age or coupling*Sex maps. These are in gifti format, but get converted to 10242-length vectors anwyays.
%pgl = gifti([ProjectFolder '/Gradients.lh.fsaverage5.func.gii']);
%pgr = gifti([ProjectFolder '/Gradients.rh.fsaverage5.func.gii']);
pgl = ''
pgr = ''
% extract unimodal-transmodal gradient
grad_lh = pgl.cdata(:,1);
grad_rh = pgr.cdata(:,1);
% get group atlases from here
atlasdir='/project/imco/baller/processed_data/yeo_network_data/CBIG/stable_projects/brain_parcellation/Schaefer2018_LocalGlobal/Parcellations/FreeSurfer5.3/fsaverage5/label/';
% load in schaef annotations (from CBIG)
[v,schaef200L,ct2L]=read_annotation([atlasdir 'lh.Schaefer2018_200Parcels_7Networks_order.annot']);
[v,schaef400L,ct4L]=read_annotation([atlasdir 'lh.Schaefer2018_400Parcels_7Networks_order.annot']);
[v,schaef200R,ct2R]=read_annotation([atlasdir 'rh.Schaefer2018_200Parcels_7Networks_order.annot']);
[v,schaef400R,ct4R]=read_annotation([atlasdir 'rh.Schaefer2018_400Parcels_7Networks_order.annot']);
% initialize blank struct for names and PG vals
% 2/5/21 - change to capture each system instead of each parcel
LH200=cell(length(ct2L.struct_names),2);
LH400=cell(length(ct4L.struct_names),2);
RH200=cell(length(ct2R.struct_names),2);
RH400=cell(length(ct4R.struct_names),2);
% initialize blank vertex list to map parcellated PG values onto
LH200V=zeros(10242,1);
LH400V=zeros(10242,1);
RH200V=zeros(10242,1);
RH400V=zeros(10242,1);
% get avg. PG1 val for each ROI in schaef 200 (Simult. hemis)
% 2/5/21 - currently loops over every unique parcel, will need to be changed to for every unique parcel.
for N=1:length(unique(schaef200L))
% fifth row is identifying number to get vertices in this ROI from
% 2/5/21 - this calls the 5th column of ctl - colortable. Column 5 is parcel membership, BUT, you will want system membership. Change column accordingly.
ROIverts_l=find(schaef200L==(ct2L.table(N,5)));
ROIverts_r=find(schaef200R==(ct2R.table(N,5)));
% mean pg val in these vertices
meanpg1val_l=mean(grad_lh(ROIverts_l));
meanpg1val_r=mean(grad_rh(ROIverts_r));
% Add PG vals to table
LH200(N,1)=ct2L.struct_names(N)
RH200(N,1)=ct2R.struct_names(N)
LH200(N,2)=num2cell(meanpg1val_l)
RH200(N,2)=num2cell(meanpg1val_r)
% and vis verts
LH200V(ROIverts_l)=meanpg1val_l;
RH200V(ROIverts_r)=meanpg1val_r;
end
% get avg. PG1 val for each ROI in schaef 400 (Simult. hemis)
for N=1:length(unique(schaef400L))
% fifth row is identifying number to get vertices in this ROI from
ROIverts_l=find(schaef400L==(ct4L.table(N,5)));
ROIverts_r=find(schaef400R==(ct4R.table(N,5)));
% mean pg val in these vertices
meanpg1val_l=mean(grad_lh(ROIverts_l));
meanpg1val_r=mean(grad_rh(ROIverts_r));
% Add PG vals to table
LH400(N,1)=ct4L.struct_names(N)
RH400(N,1)=ct4R.struct_names(N)
LH400(N,2)=num2cell(meanpg1val_l)
RH400(N,2)=num2cell(meanpg1val_r)
% and vis verts
LH400V(ROIverts_l)=meanpg1val_l;
RH400V(ROIverts_r)=meanpg1val_r;
end
writetable(cell2table(LH200),'/project/imco/baller/results/yeo_schaef/SchaefLH200_transmodality7.csv');
writetable(cell2table(RH200),'/project/imco/baller/results/yeo_schaef/SchaefRH200_transmodality7.csv');
writetable(cell2table(LH400),'/project/imco/baller/results/yeo_schaef/SchaefLH400_transmodality7.csv');
writetable(cell2table(RH400),'/project/imco/baller/results/yeo_schaef/SchaefRH400_transmodality7.csv');
%% write out vectors of schaef parcellated values
save('/project/imco/baller/results/yeo_schaef/viz/Schaef200_TM_L.mat','LH200V');
save('/project/imco/baller/results/yeo_schaef/viz/Schaef200_TM_R.mat','RH200V');
save('/project/imco/baller/results/yeo_schaef/viz/Schaef400_TM_L.mat','LH400V');
save('/project/imco/baller/results/yeo_schaef/viz/Schaef400_TM_R.mat','RH400V');