Skip to content

Commit

Permalink
downloads as inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan DeKraker - B. Bernhardt Lab committed Nov 2, 2023
1 parent 5974a5f commit b30f8cc
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 30 deletions.
4 changes: 2 additions & 2 deletions hippunfold/config/snakebids.yml
Original file line number Diff line number Diff line change
Expand Up @@ -471,14 +471,14 @@ nnunet_model:
synthseg_v0.1: 'zenodo.org/record/8184230/files/trained_model.3d_fullres.Task102_synsegGenDetailed.nnUNetTrainerV2.model_best.tar'
synthseg_v0.2: 'zenodo.org/record/8184230/files/trained_model.3d_fullres.Task203_synthseg.nnUNetTrainerV2.model_best.tar'

atlas_files_osf:
atlas_links_osf:
multihist7: 'https://files.ca-1.osf.io/v1/resources/v8acf/providers/osfstorage/65395b782827451220b86dd8/?zip='
bigbrain: 'https://files.ca-1.osf.io/v1/resources/v8acf/providers/osfstorage/65395b8b13d27b123094c96f/?zip='
magdeburg: 'https://files.ca-1.osf.io/v1/resources/v8acf/providers/osfstorage/65395b8013d27b122f94c938/?zip='
freesurfer: 'https://files.ca-1.osf.io/v1/resources/v8acf/providers/osfstorage/65395b8513d27b123094c96a/?zip='
#https://github.com/CenterForOpenScience/osf.io/issues/8256#issuecomment-379833911

template_files_osf:
template_links_osf:
CITI168: 'https://files.ca-1.osf.io/v1/resources/v8acf/providers/osfstorage/65395bf0282745121fb86a93/?zip='
dHCP: 'https://files.ca-1.osf.io/v1/resources/v8acf/providers/osfstorage/65395bff13d27b123094c9b4/?zip='
MBMv2: 'https://files.ca-1.osf.io/v1/resources/v8acf/providers/osfstorage/65395c0887852d133ca597dd/?zip='
Expand Down
51 changes: 37 additions & 14 deletions hippunfold/workflow/rules/downloads.smk
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,30 @@ rule download_model:

rule download_atlas:
params:
url=lambda wildcards: config["atlas_files_osf"][wildcards.atlas],
url=config["atlas_links_osf"][config["atlas"][0]],
output:
model_zip=os.path.join(download_dir,"{atlas}"+'.zip')
model_zip=os.path.join(download_dir,config["atlas"][0]+'.zip')
container:
config["singularity"]["autotop"]
shell:
"wget https://{params.url} -O {output.model_zip}"

rule download_template:
params:
url=lambda wildcards: config["template_files_osf"][wildcards.atlas],
url=config["template_links_osf"][config["template"]],
output:
model_zip=os.path.join(download_dir,"{template}"+'.zip')
model_zip=os.path.join(download_dir,config["template"]+'.zip')
container:
config["singularity"]["autotop"]
shell:
"wget https://{params.url} -O {output.model_zip}"


rule download_template_shape:
params:
url=config["template_links_osf"][config["inject_template"]],
output:
model_zip=os.path.join(download_dir,config["inject_template"]+'.zip')
container:
config["singularity"]["autotop"]
shell:
Expand All @@ -48,19 +59,34 @@ def atlas_outs():
outs = []
for a in config["atlas"]:
for fn in config["atlas_files"][a]:
outs.append(os.path.join(download_dir,config["atlas_files"][a][fn]))
return outs
for hemi in ['L','R']:
outs.append(download_dir + '/' +
expand(config["atlas_files"][a][fn],hemi=hemi)[0])
return list(dict.fromkeys(outs))

def template_outs():
outs = []
for fn in config["template_files"][config["template"]]:
outs.append(os.path.join(download_dir,config["template_files"][config["template"]][fn]))
return outs
for hemi in ['L','R']:
for dir in ['AP','PD','IO']:
outs.append(download_dir + '/' +
expand(config["template_files"][config["template"]][fn],hemi=hemi,dir=dir)[0])
return list(dict.fromkeys(outs))

def template_shape_outs():
outs = []
for fn in config["template_files"][config["inject_template"]]:
for hemi in ['L','R']:
for dir in ['AP','PD','IO']:
for autotop in ['hipp','dentate']:
outs.append(download_dir + '/' +
expand(config["template_files"][config["inject_template"]][fn],hemi=hemi,dir=dir,autotop=autotop)[0])
return list(dict.fromkeys(outs))


rule unzip_template:
input:
model_zip=os.path.join(download_dir,"{template}"+'.zip'),
model_zip=os.path.join(download_dir,config["template"]+'.zip'),
params:
dir=download_dir,
output:
Expand All @@ -70,7 +96,7 @@ rule unzip_template:

rule unzip_atlas:
input:
model_zip=os.path.join(download_dir,"{atlas}"+'.zip'),
model_zip=os.path.join(download_dir,config["atlas"][0]+'.zip'),
params:
dir=download_dir,
output:
Expand All @@ -85,10 +111,7 @@ rule unzip_template_shape:
params:
dir=download_dir,
output:
template_seg=os.path.join(
download_dir,
config["template_files"][config["inject_template"]]["dseg"],
)
template_shape_outs()
shell:
"unzip {input.model_zip} -d {params.dir}"

7 changes: 3 additions & 4 deletions hippunfold/workflow/rules/gifti.smk
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ rule metric_to_nii:
group:
"subj"
shell:
"wb_command -metric-to-volume-mapping {input.metric_gii} {input.unfoldedsurf} {params.refflatnii} {output.metric_nii} {params.interp}"
"wb_command -metric-to-volume-mapping {input.metric_gii} {input.unfoldedsurf} {input.refflatnii} {output.metric_nii} {params.interp}"


rule unfolded_registration:
Expand Down Expand Up @@ -590,7 +590,7 @@ rule unfolded_registration:
mem_mb=16000,
time=10,
shell:
"antsRegistrationSyNQuick.sh {params.antsparams} -f {params.refthickness} -f {params.refcurvature} -f {params.refgyrification} -m {input.thickness} -m {input.curvature} -m {input.gyrification} -o {params.outsuffix} &> {log} && "
"antsRegistrationSyNQuick.sh {params.antsparams} -f {input.refthickness} -f {input.refcurvature} -f {input.refgyrification} -m {input.thickness} -m {input.curvature} -m {input.gyrification} -o {params.outsuffix} &> {log} && "
"cp {params.warpfn} {output.warp} && "
"cp {params.invwarpfn} {output.invwarp}"

Expand Down Expand Up @@ -1114,8 +1114,7 @@ rule nii_to_label_gii:
"tpl-avg_space-unfold_den-{density}_midthickness.surf.gii",
),
label_list=lambda wildcards: os.path.join(
workflow.basedir,
"..",
download_dir,
config["atlas_files"][wildcards.atlas]["label_list"],
),
params:
Expand Down
6 changes: 2 additions & 4 deletions hippunfold/workflow/rules/preproc_t1.smk
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,11 @@ rule warp_t1_to_corobl_crop:
type_="itk"
),
ref=os.path.join(
workflow.basedir,
"..",
download_dir,
config["template_files"][config["template"]]["crop_ref"],
),
std_to_cor=os.path.join(
workflow.basedir,
"..",
download_dir,
config["template_files"][config["template"]]["xfm_corobl"],
),
output:
Expand Down
8 changes: 2 additions & 6 deletions hippunfold/workflow/rules/qc.smk
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,8 @@ rule get_subfield_vols_subj:
allow_missing=True,
),
lookup_tsv=os.path.join(
workflow.basedir,
"..",
"resources",
"atlases-unfolded",
"{atlas}",
"desc-subfields_atlas-{atlas}_dseg.tsv",
download_dir,
config["atlas_files"][config["atlas"][0]]["label_list"]
),
group:
"subj"
Expand Down

0 comments on commit b30f8cc

Please sign in to comment.