-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwrite.markups.fcsv.R
35 lines (31 loc) · 1.3 KB
/
write.markups.fcsv.R
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
write.markups.fcsv = function(pts=NULL, outfile=NULL){
temp = "# Markups fiducial file version = 4.13\n# CoordinateSystem = LPS\n# columns = id,x,y,z,ow,ox,oy,oz,vis,sel,lock,label,desc,associatedNodeID\n"
if (length(rownames(pts))==0) {
for (i in 1:nrow(pts))
temp = paste0(temp, '\n',
paste(paste0("vtkMRMLMarkupsFiducialNode_", i-1),
pts[i,1],
pts[i,2],
pts[i,3],
paste(rep(0,3), collapse=','),
paste(rep(1,4), collapse=','),
paste0("F-", i),
paste(rep("",2), collapse=','),
sep=','))
cat (temp, file = outfile)
} else {
labels=rownames(pts)
for (i in 1:nrow(pts))
temp = paste0(temp, '\n',
paste(paste0("vtkMRMLMarkupsFiducialNode_", i-1),
pts[i,1],
pts[i,2],
pts[i,3],
paste(rep(0,3), collapse=','),
paste(rep(1,4), collapse=','),
paste(labels[i]),
paste(rep("",2), collapse=','),
sep=','))
cat (temp, file = outfile)
}
}