From d3ccc7616d4d36095d5f30e36ca4260493eb3428 Mon Sep 17 00:00:00 2001 From: Ali Khan Date: Thu, 15 Feb 2024 16:23:11 -0500 Subject: [PATCH] use downloaded template for shape-inject --- hippunfold/config/snakebids.yml | 48 +++++++++++----------- hippunfold/workflow/rules/preproc_t1.smk | 2 +- hippunfold/workflow/rules/shape_inject.smk | 23 ++++------- 3 files changed, 34 insertions(+), 39 deletions(-) diff --git a/hippunfold/config/snakebids.yml b/hippunfold/config/snakebids.yml index 515fb7b7..99366158 100644 --- a/hippunfold/config/snakebids.yml +++ b/hippunfold/config/snakebids.yml @@ -382,32 +382,32 @@ template_files: crop_refT1w: tpl-dHCP_cohort-1_res-1_space-corobl_hemi-{hemi}_T1w.nii.gz Mask_crop: tpl-dHCP_cohort-1_res-1_space-corobl_hemi-{hemi}_desc-hipp_mask.nii.gz MBMv2: - T1w: MBMv2/Template_sym_MTR_80um.nii.gz - T2w: MBMv2/Template_sym_T2_80um.nii.gz - xfm_corobl: MBMv2/tpl-MBMv2_from-native_to-corobl_type-itk_affine.txt - crop_ref: MBMv2/tpl-MBMv2_hemi-{hemi}_space-corobl_{modality}.nii.gz - Mask_crop: MBMv2/tpl-MBMv2_hemi-{hemi}_space-corobl_desc-hipp_mask.nii.gz - dseg: MBMv2/tpl-MBMv2_hemi-R_space-corobl_desc-tissuemanual_dseg.nii.gz - coords: MBMv2/tpl-MBMv2_dir-{dir}_hemi-R_space-corobl_label-{autotop}_desc-laplace_coords.nii.gz + T1w: Template_sym_MTR_80um.nii.gz + T2w: Template_sym_T2_80um.nii.gz + xfm_corobl: tpl-MBMv2_from-native_to-corobl_type-itk_affine.txt + crop_ref: tpl-MBMv2_hemi-{hemi}_space-corobl_{modality}.nii.gz + Mask_crop: tpl-MBMv2_hemi-{hemi}_space-corobl_desc-hipp_mask.nii.gz + dseg: tpl-MBMv2_hemi-R_space-corobl_desc-tissuemanual_dseg.nii.gz + coords: tpl-MBMv2_dir-{dir}_hemi-R_space-corobl_label-{autotop}_desc-laplace_coords.nii.gz MBMv3: - T1w: MBMv3/tpl-MBMv3_T1w.nii.gz - T2w: MBMv3/tpl-MBMv3_T2w.nii.gz - xfm_corobl: MBMv3/tpl-MBMv3_from-native_to-corobl_type-itk_affine.txt - crop_ref: MBMv3/tpl-MBMv3_hemi-{hemi}_space-corobl_{modality}.nii.gz - Mask_crop: MBMv3/tpl-MBMv3_hemi-{hemi}_space-corobl_desc-hipp_mask.nii.gz - dseg: MBMv3/tpl-MBMv3_hemi-R_space-corobl_desc-tissue_dseg.nii.gz - coords: MBMv3/tpl-MBMv3_dir-{dir}_hemi-R_space-corobl_label-{autotop}_desc-laplace_coords.nii.gz + T1w: tpl-MBMv3_T1w.nii.gz + T2w: tpl-MBMv3_T2w.nii.gz + xfm_corobl: tpl-MBMv3_from-native_to-corobl_type-itk_affine.txt + crop_ref: tpl-MBMv3_hemi-{hemi}_space-corobl_{modality}.nii.gz + Mask_crop: tpl-MBMv3_hemi-{hemi}_space-corobl_desc-hipp_mask.nii.gz + dseg: tpl-MBMv3_hemi-R_space-corobl_desc-tissue_dseg.nii.gz + coords: tpl-MBMv3_dir-{dir}_hemi-R_space-corobl_label-{autotop}_desc-laplace_coords.nii.gz CIVM: - T1w: CIVM/tpl-CIVM_T1w.nii.gz - xfm_corobl: CIVM/tpl-CIVM_from-native_to-corobl_type-itk_affine.txt - crop_ref: CIVM/tpl-CIVM_hemi-{hemi}_space-corobl_{modality}.nii.gz - Mask_crop: CIVM/tpl-CIVM_hemi-{hemi}_space-corobl_desc-hipp_mask.nii.gz - dseg: CIVM/tpl-CIVM_hemi-R_space-corobl_desc-tissue_dseg.nii.gz - coords: CIVM/tpl-CIVM_dir-{dir}_hemi-R_space-corobl_label-{autotop}_desc-laplace_coords.nii.gz + T1w: tpl-CIVM_T1w.nii.gz + xfm_corobl: tpl-CIVM_from-native_to-corobl_type-itk_affine.txt + crop_ref: tpl-CIVM_hemi-{hemi}_space-corobl_{modality}.nii.gz + Mask_crop: tpl-CIVM_hemi-{hemi}_space-corobl_desc-hipp_mask.nii.gz + dseg: tpl-CIVM_hemi-R_space-corobl_desc-tissue_dseg.nii.gz + coords: tpl-CIVM_dir-{dir}_hemi-R_space-corobl_label-{autotop}_desc-laplace_coords.nii.gz upenn: - T1w: upenn/tpl-upenn_desc-hipptissue_dseg.nii.gz - dseg: upenn/tpl-upenn_desc-hipptissue_dseg.nii.gz - coords: upenn/tpl-upenn_dir-{dir}_label-{autotop}_coords.nii.gz + T1w: tpl-upenn_desc-hipptissue_dseg.nii.gz + dseg: tpl-upenn_desc-hipptissue_dseg.nii.gz + coords: tpl-upenn_dir-{dir}_label-{autotop}_coords.nii.gz atlas_files: multihist7: @@ -458,6 +458,8 @@ no_reg_template: False modality: T2w +inject_template: upenn + template: CITI168 atlas: diff --git a/hippunfold/workflow/rules/preproc_t1.smk b/hippunfold/workflow/rules/preproc_t1.smk index 96bf100f..65ffeb35 100644 --- a/hippunfold/workflow/rules/preproc_t1.smk +++ b/hippunfold/workflow/rules/preproc_t1.smk @@ -245,7 +245,7 @@ rule template_xfm_itk2ras: datatype="warps", **config["subj_wildcards"], suffix="xfm.txt", - from_="{native_modality,T1w|T2w}", + from_="{native_modality}", to="corobl", desc="affine", type_="itk" diff --git a/hippunfold/workflow/rules/shape_inject.smk b/hippunfold/workflow/rules/shape_inject.smk index 60aedbd6..d724d99d 100644 --- a/hippunfold/workflow/rules/shape_inject.smk +++ b/hippunfold/workflow/rules/shape_inject.smk @@ -88,13 +88,10 @@ rule prep_segs_for_greedy: rule import_template_shape: input: - template_seg=os.path.join( - workflow.basedir, - "..", - "resources", - "tpl-upenn", - "tpl-upenn_desc-hipptissue_dseg.nii.gz", - ), + template_dir=Path(download_dir) / "template" / config["inject_template"], + params: + template_seg=lambda wildcards, input: Path(input.template_dir) + / config["template_files"][config["inject_template"]]["dseg"], output: template_seg=bids( root=work, @@ -279,13 +276,6 @@ rule template_shape_inject: rule inject_init_laplace_coords: input: - coords=os.path.join( - workflow.basedir, - "..", - "resources", - "tpl-upenn", - "tpl-upenn_dir-{dir}_label-{autotop}_coords.nii.gz", - ), subject_seg=get_input_for_shape_inject, matrix=bids( root=work, @@ -310,7 +300,10 @@ rule inject_init_laplace_coords: space="corobl", hemi="{hemi}" ), + template_dir=Path(download_dir) / "template" / config["inject_template"], params: + coords=lambda wildcards, input: Path(input.template_dir) + / config["template_files"][config["inject_template"]]["coords"], interp_opt="-ri NN", output: init_coords=bids( @@ -340,7 +333,7 @@ rule inject_init_laplace_coords: config["singularity"]["autotop"] threads: 8 shell: - "greedy -d 3 -threads {threads} {params.interp_opt} -rf {input.subject_seg} -rm {input.coords} {output.init_coords} -r {input.warp} {input.matrix} &> {log}" + "greedy -d 3 -threads {threads} {params.interp_opt} -rf {input.subject_seg} -rm {params.coords} {output.init_coords} -r {input.warp} {input.matrix} &> {log}" rule unflip_init_coords: