66import argparse
77import re
88import subprocess
9- from pathlib import Path
109from multiprocessing .pool import Pool
10+ from pathlib import Path
1111
1212
1313def get_args ():
@@ -17,7 +17,7 @@ def get_args():
1717 default = Path ('.' ), help = "Path to defacing outputs directory." )
1818 parser .add_argument ('-n' , '--n-cpus' , type = int , default = 1 ,
1919 help = 'Number of parallel processes to run. '
20- 'Defaults to 1, meaning "serial processing" when not provided.' )
20+ 'Defaults to 1, meaning "serial processing" when not provided.' )
2121 return parser .parse_args ()
2222
2323
@@ -45,9 +45,14 @@ def generate_3d_renders(defaced_img, render_outdir):
4545 yaw , pitch , roll = rot [0 ], rot [1 ], rot [2 ]
4646 outfile = render_outdir .joinpath ('defaced_render_0' + str (idx ) + '.png' )
4747 if not outfile .exists ():
48- fsleyes_render_cmd = f"export TMP_DISPLAY=$DISPLAY; unset DISPLAY; fsleyes render --scene 3d -rot { yaw } { pitch } { roll } --outfile { outfile } { defaced_img } -dr 20 250 -in spline -bf 0.3 -r 100 -ns 500; export DISPLAY=$TMP_DISPLAY"
49- print (fsleyes_render_cmd )
50- run_command (fsleyes_render_cmd )
48+ if 'T2w' in render_outdir .parts :
49+ fsleyes_render_cmd = f"fsleyes render --scene 3d -rot { yaw } { pitch } { roll } --outfile { outfile } { defaced_img } -dr 80 1000 -in spline -cm render1 -bf 0.3 -r 100 -ns 500;"
50+ else :
51+ fsleyes_render_cmd = f"fsleyes render --scene 3d -rot { yaw } { pitch } { roll } --outfile { outfile } { defaced_img } -dr 20 250 -in spline -cm render1 -bf 0.3 -r 100 -ns 500;"
52+ cmd = f"export TMP_DISPLAY=$DISPLAY; unset DISPLAY; { fsleyes_render_cmd } export DISPLAY=$TMP_DISPLAY"
53+
54+ print (cmd )
55+ run_command (cmd )
5156 print (f"Has the render been created? { outfile .exists ()} " )
5257
5358
@@ -64,8 +69,8 @@ def main():
6469 print (f'Running in Parallel with { args .n_cpus } cores' )
6570 # initialize pool
6671 with Pool (processes = args .n_cpus ) as p :
67- p .starmap ( generate_3d_renders , zip ( defaced_imgs ,
68- [img .parent for img in defaced_imgs ] ) )
72+ p .starmap (generate_3d_renders , zip (defaced_imgs ,
73+ [img .parent for img in defaced_imgs ]) )
6974
7075 else :
7176 raise ValueError (f"Provided --n-cpus of { args .n_cpus } is not a valid number of CPUs." )
@@ -77,7 +82,7 @@ def main():
7782 print (f"Run the following command to start a VisualQC Deface session:\n \t { vqcdeface_cmd } \n " )
7883 with open (args .outdir / 'QC_prep' / 'defacing_qc_cmd' , 'w' ) as f :
7984 f .write (vqcdeface_cmd + '\n ' )
80-
85+
8186 print (f"All set to start visual inspection of defaced images!" )
8287
8388
0 commit comments