-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgenCmtkScript.py
More file actions
39 lines (31 loc) · 1.12 KB
/
genCmtkScript.py
File metadata and controls
39 lines (31 loc) · 1.12 KB
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
def genCmtkScript(path, params):
'''Generate and save the script.'''
template = '''#!/bin/bash
# deformable registration
cmtk_path="%s"
dir="%s"
outputDir=$dir
fixed=$dir"/%s"
floating=$dir"/%s"
reformatImage=$dir"/%s"
outFloatingReformated=$dir"/(in_3d_log_masked)_into_(ex_3d_cropped)_deformable.nii"
outFinal=$dir"/(in_3d)_into_(ex_3d_cropped)_deformable.nii"
outXform=$dir"/warp_output_transform"
mkdir $outXform
options=""
options=$options" --write-reformatted "$outFloatingReformated
options=$options" --output-intermediate"
options=$options" --omit-original-data"
options=$options" --sampling 1"
options=$options" --outlist "$outXform
options=$options" --rigidity-weight 0.01"
export CMTK_WRITE_UNCOMPRESSED=1
echo "$cmtk_path"/warp.exe $options $fixed $floating
"$cmtk_path"/warp.exe $options $fixed $floating
echo "$cmtk_path"/reformatx -o $outFinal --floating $reformatImage $fixed $outXform
"$cmtk_path"/reformatx -o $outFinal --floating $reformatImage $fixed $outXform
'''
cmd = template % params
with open(path, 'w') as f:
f.write(cmd)
return True