Skip to content

Commit 9ad7f37

Browse files
committed
fixing minor bugs
1 parent 8b10997 commit 9ad7f37

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ examples/visualqc_prep/
99
examples/sub-01/
1010
user-testing/*
1111

12+
src/isolate_fsleyes_render_issue.py

src/dsst_defacing_wf.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def copy_over_sidecar(scan_filepath, input_anat_dir, output_anat_dir):
7373

7474

7575
def 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

116116
def generate_3d_renders(defaced_img, render_outdir):
@@ -132,16 +132,16 @@ def create_defacing_id_list(qc_dir):
132132
def 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")

src/generate_mappings.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@ def primary_scans_qc_prep(mapping_dict, qc_prep):
7777
id_list.append(dest)
7878
primary_link = dest / 'primary.nii.gz'
7979
if not primary_link.exists():
80-
primary_link.symlink_to(primary)
80+
try:
81+
primary_link.symlink_to(primary)
82+
except:
83+
pass
8184

8285
with open(vqc_t1_mri / 't1_mri_id_list.txt', 'w') as f:
8386
f.write('\n'.join([str(i) for i in id_list]))

0 commit comments

Comments
 (0)