-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStep-4_modify-landmark-files.py
43 lines (26 loc) · 1.24 KB
/
Step-4_modify-landmark-files.py
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
# This Step 4 adds the 300 number in the top of the landmark file as we have 300 landmark points
import os
import shutil
list_id = [1, 2, 3, 4, 7, 8, 9, 10]
for val_i in list_id:
id = val_i
r1_file = "test_nii/copd{}/copd{}_300_eBH_xyz_r1.txt".format(val_i,val_i)
r2_file = "test_nii/copd{}/copd{}_300_eBH_xyz_r2.txt".format(val_i,val_i)
with open(r2_file,'a') as secondfile:
secondfile.write("300\n")
# open both files
with open(r1_file,'r') as firstfile, open(r2_file,'a') as secondfile:
# read content from first file
for line in firstfile:
# write content to second file
secondfile.write(line)
r1_file = "test_nii/copd{}/copd{}_300_iBH_xyz_r1.txt".format(val_i,val_i)
r2_file = "test_nii/copd{}/copd{}_300_iBH_xyz_r2.txt".format(val_i,val_i)
with open(r2_file,'a') as secondfile:
secondfile.write("300\n")
# open both files
with open(r1_file,'r') as firstfile, open(r2_file,'a') as secondfile:
# read content from first file
for line in firstfile:
# write content to second file
secondfile.write(line)