-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpaint_creator_from_foci_fsaverage.m
54 lines (53 loc) · 1.73 KB
/
paint_creator_from_foci_fsaverage.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
function file_to_write =paint_creator_from_foci_fsaverage(subj,subject_path,elect_name,hemi)
if strcmp(hemi,'lh')
hemisp='left';
else
hemisp='right';
end
coordinates=zeros(size(nearest_node,2),3);
[node ver]=readsurface([subject_path '/surf/' hemi '.white']);
[node_pial ver]=readsurface([subject_path '/surf/' hemi '.pial']);
AA={'BeginHeader' ...
'Caret-Version 5.64' ...
'Date ' ...
'comment' ...
'encoding ASCII' ...
'pubmed_id '...
'EndHeader'...
'tag-version 1'...
'tag-number-of-nodes ' ...
'tag-number-of-columns 1'...
'tag-title'...
'tag-number-of-paint-names ' ...
'tag-column-name 0 ' ...
'tag-column-comment 0' ...
'tag-column-study-meta-data 0 ' ...
'tag-BEGIN-DATA' ...
'0 ???'};
AA{3}=['Date ' num2str(date) ];
AA{9}=['tag-number-of-nodes ' num2str(size(node,1))];
AA{12}=['tag-number-of-paint-names ' num2str(size(nearest_node,2)+1)];
AA{13}=['tag-column-name 0 ' subj '_' elect_name '_' hemi '_one_node'] ;
start_line=size(AA,2);
nodes=[(0:size(node,1)-1)' zeros(size(node,1),1)];
for i=1:size(nearest_node,2)
if i<10
number_nod=['0' num2str(i)];
else
number_nod= num2str(i);
end
if nearest_node(i)>0
nodes(nearest_node(i),2)=i;
coordinates(i,:)=node_pial(nearest_node(i),:);
AA{start_line+i}=[num2str(i) ' ' subj '_' elect_name '_' number_nod ];
else
AA{start_line+i}=[num2str(i) ' ' subj '_' elect_name '_' number_nod '_0_node'];
end
end
file_to_write=[hemi '.' elect_name '_focitype.paint'];
fid=fopen(file_to_write,'w');
for a_2=1:size(AA,2)
fprintf(fid,[ AA{a_2} '\n']); % to create header file for paint file
end
dlmwrite(file_to_write, nodes, '-append','roffset', 0, 'delimiter', ' ','precision', 6); % adding noddes data to file
fclose(fid);