-
Notifications
You must be signed in to change notification settings - Fork 0
/
cameg_datapre_readsurf_m.m
123 lines (102 loc) · 2.81 KB
/
cameg_datapre_readsurf_m.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
function cameg_datapre_readsurf_m(idxp)
% ___________________________________________________________________________
% Connectivity analysis of MEG data (CA-MEG)
%
% Copyright 2016 Cincinnati Children's Hospital Medical Center
% Reference
%
%
% v1.0 Vahab Youssofzadeh 21/07/2016
% email: [email protected]
% ___________________________________________________________________________
disp('Reading surface data ...')
files = spm_select(1,'.mat','Select surface file');
load(files);
%%
load cameg_mrifile
load(files);
sMri.Voxsize = Voxsize;
sMri.SCS = SCS;
sMri.NCS = NCS;
for i=1:length(Atlas)
Atlasa{i} = Atlas(i).Name;
end
cell2table(Atlasa)
sel = input('Select an atlas consistant with the data file (e.g. 6)?');
At = Atlas(sel);
% ROI coordinates
for i = 1:length(At.Scouts)
A = At.Scouts(i).Seed;
% L{i,:} = At.Scouts(i).Region;
% L{i,:} = At.Scouts(i).Label;
newPosScs = Vertices(A,:);
newPosVox = round(cs_convert(sMri, 'scs', 'voxel', newPosScs));
newPosMNI(i,:) = round((1e3.*cs_convert(sMri, 'voxel', 'mni', newPosVox)),1);
end
newPosMNI = newPosMNI(idxp,:);
% Vertex color: modular information
m = ones(length(idxp),1);
% for i = 1:length(idxp)
% R = At.Scouts(idxp(i)).Region;
% if R(1) == 'L'
% m(i) = 4;
% else
% m(i) = 5;
% end
% end
m(1:length(idxp)/2) = 4;
m(length(idxp)/2+1:end) = 5;
% Left = 1:2:length(idxp);
% Right = 2:2:length(idxp);
% m(Left) = 4;
% m(Right) = 3;
% Vertex size: centrality, T-value, etc information
c = ones(length(idxp),1);
% Vertex label
L = zeros(length(idxp),1);
% load cameg_datafile
% tmp = char(A.Var1);
% B = num2str(1:length(idxp));
B = [];
for i = 1:length(idxp), B{i} = num2str(i); end
d = cell2char(B');
node = strcat(num2str([newPosMNI,m,c,L]),d);
node(:,end-4:end-2) = char(' ');
dlmwrite('node.node',node,'delimiter','');
save cameg_surffile files newPosMNI m c L d
disp('Surface file was imported!')
%% junk
% nnode = [num2cell([newPosMNI,m,c,L]),tmp];
% nnnode = nnode{:,:};
% node = table2struct(cell2table([num2cell([newPosMNI,m,c,L]),tmp]));
% B = char(tmp);
% fid=fopen('Node_AAL90.node','r');
% s = '';
% while ~feof(fid)
% line = fgetl(fid);
% if isempty(line), break, end
% s = strvcat(s,line);
% end
% s1 = s(1:length(idxp),:);
% s1(2,1:6) = newPosMNI(1,1);
%
% dlmwrite('test.node',s,'delimiter','');
%
%
% node = [newPosMNI,m,c,L];
% cell2struct
% xlswrite(node,node)
% dlmwrite(node.,M,'-append')
% % save filname.edge node -ascii
% % writetable(node,'node.txt');
% % dlmwrite('node.txt',node);
% % dlmwrite('node.node',node, ';');
%
%
% fid = fopen('edge.edge', 'w') ;
% fprintf(fid, '%s,', node{1,1:end-1}) ;6
% fprintf(fid, '%s\n', node{1,end}) ;
% fclose(fid) ;
% dlmwrite('node.node', node(2:end,:), '-append') ;
% dlmwrite('node.node',node,' ');
% dlmwrite('node.node', node, '-append') ;