Skip to content

Commit

Permalink
Update fastsurfer.smk
Browse files Browse the repository at this point in the history
  • Loading branch information
greydongilmore committed Feb 11, 2022
1 parent 240aeb9 commit e56ae97
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions workflow/rules/fastsurfer.smk
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
def get_pre_t1_filename(wildcards):
files=glob(bids(root=join(config['out_dir'], 'bids'), subject=config['subject_prefix']+f'{wildcards.subject}', datatype='anat', session='pre', run='*', suffix='T1w.nii.gz'))
files=glob(bids(root=join(config['out_dir'], 'bids'), subject=config['subject_prefix']+f'{wildcards.subject}', datatype='anat', session='pre', acq=config['noncontrast_t1']['acq'], run='*', suffix='T1w.nii.gz'))
if len(files) <=1:
file=expand(bids(root=join(config['out_dir'], 'bids'), subject=config['subject_prefix']+'{subject}', datatype='anat', session='pre', run='01', suffix='T1w.nii.gz'),subject=wildcards.subject)
file=expand(bids(root=join(config['out_dir'], 'bids'), subject=config['subject_prefix']+'{subject}', datatype='anat', session='pre', acq=config['noncontrast_t1']['acq'], run='01', suffix='T1w.nii.gz'),subject=wildcards.subject)
if len(file)==0:
file=expand(bids(root=join(config['out_dir'], 'bids'), subject=config['subject_prefix']+'{subject}', datatype='anat', session='pre', run='01', suffix='T1w.nii.gz'),subject=wildcards.subject)
else:
files.sort(key=lambda f: int(re.sub('\D', '', f)))
file=files[-1]
if file:
if not exists(file[0]):
file=expand(bids(root=join(config['out_dir'], 'bids'), subject=config['subject_prefix']+'{subject}', datatype='anat', session='pre', run='01', suffix='T1w.nii.gz'),subject=wildcards.subject)
if file:
print(f'Pre T1w non-contrast file: {basename(file[0])}')
return file

if config['fastsurfer']['seg_only']:
Expand All @@ -22,9 +30,8 @@ if config['fastsurfer']['seg_only']:
touch_fastsurfer=touch(join(config['out_dir'], 'logs', 'sub-' + subject_id + "_fastsurfer.done")),
threads:config['fastsurfer']['threads']
shell:
"export FASTSURFER_HOME={params.fastsurfer_run} &&export PYTORCH_CUDA_ALLOC_CONF=max_split_size_mb:50&&{params.fastsurfer_run}/run_fastsurfer.sh \
--t1 {input.t1} --sd {output.fastsurfer_out} --sid {params.sid} --order {params.order} \
--py {params.py} --threads {params.threads} --parallel"
"export FASTSURFER_HOME={params.fastsurfer_run} &&PYTORCH_CUDA_ALLOC_CONF=max_split_size_mb:4096 {params.fastsurfer_run}/run_fastsurfer.sh \
--t1 {input.t1} --sd {output.fastsurfer_out} --sid {params.sid} --order {params.order} --py {params.py} --run_viewagg_on cpu"
else:
rule fastsurfer_seg:
input:
Expand Down

0 comments on commit e56ae97

Please sign in to comment.