@@ -73,7 +73,7 @@ def copy_over_sidecar(scan_filepath, input_anat_dir, output_anat_dir):
7373
7474
7575def reorganize_into_bids (input_dir , defacing_outputs , mapping_dict , no_clean ):
76- # make afni_intermediate_files for each session within anat dir
76+ # make workdir for each session within anat dir
7777 for anat_dir in defacing_outputs .rglob ('anat' ):
7878 sess_id = None
7979 # extract subject/session IDs
@@ -103,14 +103,14 @@ def reorganize_into_bids(input_dir, defacing_outputs, mapping_dict, no_clean):
103103 copy_over_sidecar (nii_filepath , input_dir / anat_dir .relative_to (defacing_outputs ), anat_dir )
104104
105105 # move QC images and afni intermediate files to a new directory
106- intermediate_files_dir = anat_dir / 'afni_intermediate_files '
106+ intermediate_files_dir = anat_dir / 'workdir '
107107 intermediate_files_dir .mkdir (parents = True , exist_ok = True )
108108 for dirpath in anat_dir .glob ('*' ):
109109 if dirpath .name .startswith ('workdir' ) or dirpath .name .endswith ('QC' ):
110110 shutil .move (dirpath , intermediate_files_dir )
111111
112- if not no_clean :
113- shutil .rmtree (intermediate_files_dir )
112+ # if not no_clean:
113+ # shutil.rmtree(intermediate_files_dir)
114114
115115
116116def generate_3d_renders (defaced_img , render_outdir ):
@@ -132,16 +132,16 @@ def create_defacing_id_list(qc_dir):
132132def vqcdeface_prep (input_dir , defacing_output_dir ):
133133 defacing_qc_dir = defacing_output_dir .parent / 'QC_prep' / 'defacing_QC'
134134 interested_files = [f for f in defacing_output_dir .rglob ('*.nii.gz' ) if
135- 'afni_intermediate_files ' not in str (f ).split ('/' )]
135+ 'workdir ' not in str (f ).split ('/' )]
136136 for defaced_img in interested_files :
137- # please kill me now ughhh
138137 entities = defaced_img .name .split ('.' )[0 ].split ('_' )
139138 vqcd_subj_dir = defacing_qc_dir / f"{ '/' .join (entities )} "
140139 vqcd_subj_dir .mkdir (parents = True , exist_ok = True )
141140
142141 defaced_link = vqcd_subj_dir / 'defaced.nii.gz'
143- if not defaced_link .exists (): defaced_link .symlink_to (defaced_img )
144- generate_3d_renders (defaced_img , vqcd_subj_dir )
142+ if not defaced_link .exists ():
143+ defaced_link .symlink_to (defaced_img )
144+ generate_3d_renders (defaced_img , vqcd_subj_dir )
145145
146146 img = list (input_dir .rglob (defaced_img .name ))[0 ]
147147 img_link = vqcd_subj_dir / 'orig.nii.gz'
@@ -190,7 +190,7 @@ def main():
190190 f .write ('\n ' .join (afni_refacer_failures )) # TODO Not very useful when running the pipeline in parallel
191191
192192 # unload fsl module and use fsleyes installed on conda env
193- run_command (f"TMP_DISPLAY=`echo $DISPLAY`; unset $ DISPLAY; module unload fsl" )
193+ run_command (f"export TMP_DISPLAY=`echo $DISPLAY`; unset DISPLAY; module unload fsl" )
194194
195195 # reorganizing the directory with defaced images into BIDS tree
196196 print (f"Reorganizing the directory with defaced images into BIDS tree...\n " )
0 commit comments