Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions scripts/preprocess/run_script_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ def run_hippunfold_parallel(subjects, bids_dir=None, hippo_dir=None, num_procs=1

if subjects_to_run!=[]:
print(get_m(f'Start Hippunfold segmentation in parallel for {subjects_to_run}', None, 'INFO'))
command = format(f"hippunfold {bids_dir} {hippo_dir} participant --participant-label {' '.join(subjects_to_run)} --core {num_procs} --modality T1w")
subjects_to_run_shortformat = [subject_id.split('sub-')[-1] for subject_id in subjects_to_run]
command = format(f"hippunfold {bids_dir} {hippo_dir} participant --participant-label {' '.join(subjects_to_run_shortformat)} --core {num_procs} --modality T1w")
if verbose:
print(command)
proc = Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8')
Expand All @@ -55,8 +56,10 @@ def run_hippunfold_parallel(subjects, bids_dir=None, hippo_dir=None, num_procs=1
if delete_intermediate:
print(get_m(f'Delete intermediate files that takes lot of space: hippunfold_outputs/hippunfold/<subject_id>/warps and hippunfold_outputs/work folders', subjects_to_run, 'INFO'))
for subject in subjects_to_run:
shutil.rmtree(hippo_dir, 'hippunfold', subject, 'warps')
shutil.rmtree(hippo_dir, 'work', f'{subject}_work.tar.gz')
if os.path.exists(os.path.join(hippo_dir, 'hippunfold', subject, 'warps')):
shutil.rmtree(os.path.join(hippo_dir, 'hippunfold', subject, 'warps'))
if os.path.isfile(os.path.join(hippo_dir, 'work', f'{subject_bids_id}_work.tar.gz')):
os.remove(os.path.join(hippo_dir, 'work', f'{subject_bids_id}_work.tar.gz'))
return True
else:
print(get_m(f'Hippunfold segmentation failed for 1 of the subject. Please check the logs at {hippo_dir}/logs/<subject_id>', None, 'ERROR'))
Expand Down