Skip to content

Commit

Permalink
stringing rules together
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan DeKraker - B. Bernhardt Lab committed Oct 31, 2023
1 parent 1142c2a commit 2366360
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 63 deletions.
86 changes: 43 additions & 43 deletions hippunfold/config/snakebids.yml
Original file line number Diff line number Diff line change
Expand Up @@ -363,43 +363,43 @@ template: CITI168

template_files:
CITI168:
T1w: templates-3d/CITI168/T1w_head_700um.nii.gz
T2w: templates-3d/CITI168/T2w_head_700um.nii.gz
xfm_corobl: templates-3d/CITI168/CoronalOblique_rigid.txt
crop_ref: templates-3d/CITI168/T2w_300umCoronalOblique_hemi-{hemi}.nii.gz
crop_refT1w: templates-3d/CITI168/T1w_300umCoronalOblique_hemi-{hemi}.nii.gz
Mask_crop: templates-3d/CITI168/Mask_300umCoronalOblique_hemi-{hemi}.nii.gz
T1w: CITI168/T1w_head_700um.nii.gz
T2w: CITI168/T2w_head_700um.nii.gz
xfm_corobl: CITI168/CoronalOblique_rigid.txt
crop_ref: CITI168/T2w_300umCoronalOblique_hemi-{hemi}.nii.gz
crop_refT1w: CITI168/T1w_300umCoronalOblique_hemi-{hemi}.nii.gz
Mask_crop: CITI168/Mask_300umCoronalOblique_hemi-{hemi}.nii.gz
dHCP:
T1w: templates-3d/tpl-dHCP/cohort-1/tpl-dHCP_cohort-1_res-1_T1w.nii.gz
xfm_corobl: templates-3d/tpl-dHCP/cohort-1/tpl-dHCP_cohort-1_to-corobl_affine.txt
crop_ref: templates-3d/CITI168/T2w_300umCoronalOblique_hemi-{hemi}.nii.gz
crop_refT1w: templates-3d/CITI168/T1w_300umCoronalOblique_hemi-{hemi}.nii.gz
Mask_crop: templates-3d/CITI168/Mask_300umCoronalOblique_hemi-{hemi}.nii.gz
T1w: tpl-dHCP/cohort-1/tpl-dHCP_cohort-1_res-1_T1w.nii.gz
xfm_corobl: tpl-dHCP/cohort-1/tpl-dHCP_cohort-1_to-corobl_affine.txt
crop_ref: CITI168/T2w_300umCoronalOblique_hemi-{hemi}.nii.gz
crop_refT1w: CITI168/T1w_300umCoronalOblique_hemi-{hemi}.nii.gz
Mask_crop: CITI168/Mask_300umCoronalOblique_hemi-{hemi}.nii.gz
upenn:
dseg: templates-3d/tpl-upenn/tpl-upenn_desc-hipptissue_dseg.nii.gz
coords: templates-3d/tpl-upenn/tpl-upenn_dir-{dir}_label-{autotop}_coords.nii.gz
dseg: tpl-upenn/tpl-upenn_desc-hipptissue_dseg.nii.gz
coords: tpl-upenn/tpl-upenn_dir-{dir}_label-{autotop}_coords.nii.gz
MBMv2:
T1w: templates-3d/tpl-MBMv2/Template_sym_MTR_80um.nii.gz
T2w: templates-3d/tpl-MBMv2/Template_sym_T2_80um.nii.gz
xfm_corobl: templates-3d/tpl-MBMv2/tpl-MBMv2_from-native_to-corobl_type-itk_affine.txt
crop_ref: templates-3d/tpl-MBMv2/tpl-MBMv2_hemi-{hemi}_space-corobl_T2w.nii.gz
crop_refT1w: templates-3d/tpl-MBMv2/tpl-MBMv2_hemi-{hemi}_space-corobl_MTR.nii.gz
Mask_crop: templates-3d/tpl-MBMv2/tpl-MBMv2_hemi-{hemi}_space-corobl_desc-hipp_mask.nii.gz
dseg: templates-3d/tpl-MBMv2/tpl-MBMv2_hemi-R_space-corobl_desc-tissuemanual_dseg.nii.gz
coords: templates-3d/tpl-MBMv2/tpl-MBMv2_dir-{dir}_hemi-R_space-corobl_label-{autotop}_desc-laplace_coords.nii.gz
T1w: tpl-MBMv2/Template_sym_MTR_80um.nii.gz
T2w: tpl-MBMv2/Template_sym_T2_80um.nii.gz
xfm_corobl: tpl-MBMv2/tpl-MBMv2_from-native_to-corobl_type-itk_affine.txt
crop_ref: tpl-MBMv2/tpl-MBMv2_hemi-{hemi}_space-corobl_T2w.nii.gz
crop_refT1w: tpl-MBMv2/tpl-MBMv2_hemi-{hemi}_space-corobl_MTR.nii.gz
Mask_crop: tpl-MBMv2/tpl-MBMv2_hemi-{hemi}_space-corobl_desc-hipp_mask.nii.gz
dseg: tpl-MBMv2/tpl-MBMv2_hemi-R_space-corobl_desc-tissuemanual_dseg.nii.gz
coords: tpl-MBMv2/tpl-MBMv2_dir-{dir}_hemi-R_space-corobl_label-{autotop}_desc-laplace_coords.nii.gz
MBMv3:
T1w: templates-3d/tpl-MBMv3/tpl-MBMv3_T1w.nii.gz
T2w: templates-3d/tpl-MBMv3/tpl-MBMv3_T2w.nii.gz
xfm_corobl: templates-3d/tpl-MBMv3/tpl-MBMv3_from-native_to-corobl_type-itk_affine.txt
crop_ref: templates-3d/tpl-MBMv3/tpl-MBMv3_hemi-{hemi}_space-corobl_T2w.nii.gz
crop_refT1w: templates-3d/tpl-MBMv3/tpl-MBMv3_hemi-{hemi}_space-corobl_T1w.nii.gz
Mask_crop: templates-3d/tpl-MBMv3/tpl-MBMv3_hemi-{hemi}_space-corobl_desc-hipp_mask.nii.gz
dseg: templates-3d/tpl-MBMv3/tpl-MBMv3_hemi-R_space-corobl_desc-tissue_dseg.nii.gz
coords: templates-3d/tpl-MBMv3/tpl-MBMv3_dir-{dir}_hemi-R_space-corobl_label-{autotop}_desc-laplace_coords.nii.gz
T1w: tpl-MBMv3/tpl-MBMv3_T1w.nii.gz
T2w: tpl-MBMv3/tpl-MBMv3_T2w.nii.gz
xfm_corobl: tpl-MBMv3/tpl-MBMv3_from-native_to-corobl_type-itk_affine.txt
crop_ref: tpl-MBMv3/tpl-MBMv3_hemi-{hemi}_space-corobl_T2w.nii.gz
crop_refT1w: tpl-MBMv3/tpl-MBMv3_hemi-{hemi}_space-corobl_T1w.nii.gz
Mask_crop: tpl-MBMv3/tpl-MBMv3_hemi-{hemi}_space-corobl_desc-hipp_mask.nii.gz
dseg: tpl-MBMv3/tpl-MBMv3_hemi-R_space-corobl_desc-tissue_dseg.nii.gz
coords: tpl-MBMv3/tpl-MBMv3_dir-{dir}_hemi-R_space-corobl_label-{autotop}_desc-laplace_coords.nii.gz
upenn:
T1w: templates-3d/tpl-upenn/tpl-upenn_desc-hipptissue_dseg.nii.gz
dseg: templates-3d/tpl-upenn/tpl-upenn_desc-hipptissue_dseg.nii.gz
coords: templates-3d/tpl-upenn/tpl-upenn_dir-{dir}_label-{autotop}_coords.nii.gz
T1w: tpl-upenn/tpl-upenn_desc-hipptissue_dseg.nii.gz
dseg: tpl-upenn/tpl-upenn_desc-hipptissue_dseg.nii.gz
coords: tpl-upenn/tpl-upenn_dir-{dir}_label-{autotop}_coords.nii.gz



Expand All @@ -408,20 +408,20 @@ atlas:

atlas_files:
multihist7:
label_nii: atlases-unfolded/multihist7/sub-maxprob_label-hipp_desc-manualsubfieldsunfoldaligned_dseg.nii.gz
label_list: atlases-unfolded/multihist7/labellist.txt
thick: atlases-unfolded/multihist7/thickness.nii.gz
curv: atlases-unfolded/multihist7/curvature.nii.gz
gyr: atlases-unfolded/multihist7/gyrification.nii.gz
label_nii: multihist7/sub-maxprob_label-hipp_desc-manualsubfieldsunfoldaligned_dseg.nii.gz
label_list: multihist7/labellist.txt
thick: multihist7/thickness.nii.gz
curv: multihist7/curvature.nii.gz
gyr: multihist7/gyrification.nii.gz
bigbrain:
label_nii: atlases-unfolded/bigbrain/sub-bigbrain_hemi-{hemi}_label-hipp_desc-manualsubfields_dseg.nii.gz
label_list: atlases-unfolded/bigbrain/sub-bigbrain_labellist.txt
label_nii: bigbrain/sub-bigbrain_hemi-{hemi}_label-hipp_desc-manualsubfields_dseg.nii.gz
label_list: bigbrain/sub-bigbrain_labellist.txt
magdeburg:
label_nii: atlases-unfolded/magdeburg/sub-all_hemi-{hemi}_label-hipp_desc-manualsubfields_maxprob.nii.gz
label_list: atlases-unfolded/magdeburg/magdeburg_labellist.txt
label_nii: magdeburg/sub-all_hemi-{hemi}_label-hipp_desc-manualsubfields_maxprob.nii.gz
label_list: magdeburg/magdeburg_labellist.txt
freesurfer:
label_nii: atlases-unfolded/freesurfer/sub-all_hemi-{hemi}_space-unfold_label-hipp_desc-freesurfersubfields_dseg.nii.gz
label_list: atlases-unfolded/freesurfer/freesurfer_labellist.txt
label_nii: freesurfer/sub-all_hemi-{hemi}_space-unfold_label-hipp_desc-freesurfersubfields_dseg.nii.gz
label_list: freesurfer/freesurfer_labellist.txt


inject_template: upenn
Expand Down
48 changes: 33 additions & 15 deletions hippunfold/workflow/rules/downloads.smk
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ def get_model_tar():

return os.path.abspath(os.path.join(download_dir, local_tar.split("/")[-1]))


rule download_model:
params:
url=config["nnunet_model"][config["force_nnunet_model"]]
Expand All @@ -34,6 +33,16 @@ rule download_atlas:
shell:
"wget https://{params.url} -O {output.model_zip}"

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


def atlas_outs():
outs = []
Expand All @@ -42,35 +51,44 @@ def atlas_outs():
outs.append(os.path.join(download_dir,config["atlas_files"][a][fn]))
return outs

rule unzip_atlas:
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


rule unzip_template:
input:
model_zip=lambda wildcards: os.path.join(download_dir,"{wildcards.atlas}"+'.zip'),
atlas=config["atlas"],
model_zip=os.path.join(download_dir,"{template}"+'.zip'),
params:
dir=download_dir,
output:
atlas_outs(),
template_outs(),
shell:
"unzip {input.model_zip} -d {params.dir}"


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


rule unzip_template:
rule unzip_template_shape:
input:
model_zip=os.path.join(download_dir,config["template"]+'.zip'),
model_zip=os.path.join(download_dir,config["inject_template"]+'.zip'),
params:
dir=download_dir,
output:
os.path.join(download_dir,config["template_files"][config["template"]]["T1w"])
template_seg=os.path.join(
download_dir,
config["template_files"][config["inject_template"]]["dseg"],
)
shell:
"unzip {input.model_zip} -d {params.dir}"

2 changes: 1 addition & 1 deletion hippunfold/workflow/rules/nnunet.smk
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def get_f3d_ref(wildcards):
if config["modality"] == "T2w":
nii = (
os.path.join(
download_dir
download_dir,
config["template_files"][config["template"]]["crop_ref"],
),
)
Expand Down
6 changes: 2 additions & 4 deletions hippunfold/workflow/rules/shape_inject.smk
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ rule prep_segs_for_greedy:
rule import_template_shape:
input:
template_seg=os.path.join(
workflow.basedir,
"..",
download_dir,
config["template_files"][config["inject_template"]]["dseg"],
),
output:
Expand Down Expand Up @@ -278,8 +277,7 @@ rule template_shape_inject:
rule inject_init_laplace_coords:
input:
coords=os.path.join(
workflow.basedir,
"..",
download_dir,
config["template_files"][config["inject_template"]]["coords"],
),
subject_seg=get_input_for_shape_inject,
Expand Down

0 comments on commit 2366360

Please sign in to comment.