Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes bugs introduced in download-osf PR #280

Merged
merged 2 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
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
14 changes: 7 additions & 7 deletions hippunfold/workflow/rules/gifti.smk
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ rule metric_to_nii:
params:
interp="-nearest-vertex 1",
refflatnii=lambda wildcards, input: Path(input.atlas_dir)
/ config["atlas_files"]["multihist7"]["label_nii"],
/ config["atlas_files"]["multihist7"]["label_nii"].format(**wildcards),
output:
metric_nii=bids(
root=work,
Expand Down Expand Up @@ -531,11 +531,11 @@ rule unfolded_registration:
warpfn="tmp1Warp.nii.gz",
invwarpfn="tmp1InverseWarp.nii.gz",
refthickness=lambda wildcards, input: Path(input.atlas_dir)
/ config["atlas_files"][wildcards.atlas]["thickness"],
/ config["atlas_files"][wildcards.atlas]["thickness"].format(**wildcards),
refcurvature=lambda wildcards, input: Path(input.atlas_dir)
/ config["atlas_files"][wildcards.atlas]["curvature"],
/ config["atlas_files"][wildcards.atlas]["curvature"].format(**wildcards),
refgyrification=lambda wildcards, input: Path(input.atlas_dir)
/ config["atlas_files"][wildcards.atlas]["gyrification"],
/ config["atlas_files"][wildcards.atlas]["gyrification"].format(**wildcards),
output:
warp=bids(
root=work,
Expand Down Expand Up @@ -1058,7 +1058,7 @@ rule resample_atlas_to_refvol:
atlas_dir=lambda wildcards: Path(download_dir) / "atlas" / wildcards.atlas,
params:
atlas=lambda wildcards, input: Path(input.atlas_dir)
/ config["atlas_files"][wildcards.atlas]["label_nii"],
/ config["atlas_files"][wildcards.atlas]["label_nii"].format(**wildcards),
output:
label_nii=bids(
root=work,
Expand Down Expand Up @@ -1110,7 +1110,7 @@ rule nii_to_label_gii:
atlas_dir=lambda wildcards: Path(download_dir) / "atlas" / wildcards.atlas,
params:
label_list=lambda wildcards, input: Path(input.atlas_dir)
/ config["atlas_files"][wildcards.atlas]["label_list"],
/ config["atlas_files"][wildcards.atlas]["label_list"].format(**wildcards),
structure_type=lambda wildcards: hemi_to_structure[wildcards.hemi],
output:
label_gii=bids(
Expand All @@ -1131,7 +1131,7 @@ rule nii_to_label_gii:
shadow:
"minimal"
shell:
"wb_command -volume-to-surface-mapping {params.label_list} {input.surf} temp.shape.gii -enclosing && "
"wb_command -volume-to-surface-mapping {input.label_nii} {input.surf} temp.shape.gii -enclosing && "
"wb_command -metric-label-import temp.shape.gii {params.label_list} {output.label_gii} && "
"wb_command -set-structure {output.label_gii} {params.structure_type}"

Expand Down
22 changes: 12 additions & 10 deletions hippunfold/workflow/rules/nnunet.smk
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,13 @@ rule unflip_nnunet_nii:
def get_f3d_ref(wildcards, input):

if config["modality"] == "T2w":
nii = (
Path(input.template_dir)
/ config["template_files"][config["template"]]["crop_ref"]
)
nii = Path(input.template_dir) / config["template_files"][config["template"]][
"crop_ref"
].format(**wildcards)
elif config["modality"] == "T1w":
nii = (
Path(input.template_dir)
/ config["template_files"][config["template"]]["crop_refT1w"]
)
nii = Path(input.template_dir) / config["template_files"][config["template"]][
"crop_refT1w"
].format(**wildcards)
else:
raise ValueError("modality not supported for nnunet!")
return nii
Expand Down Expand Up @@ -302,8 +300,12 @@ rule qc_nnunet_dice:
template_dir=Path(download_dir) / "template" / config["template"],
params:
hipp_lbls=[1, 2, 7, 8],
ref=lambda wildcards, input: Path(input.template_dir)
/ config["template_files"][config["template"]]["Mask_crop"],
ref=lambda wildcards, input: (
Path(input.template_dir)
/ config["template_files"][config["template"]]["Mask_crop"].format(
**wildcards
)
),
output:
dice=report(
bids(
Expand Down
2 changes: 1 addition & 1 deletion hippunfold/workflow/rules/preproc_seg.smk
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ rule warp_seg_to_corobl_crop:
template_dir=Path(download_dir) / "template" / config["template"],
params:
ref=lambda wildcards, input: Path(input.template_dir)
/ config["template_files"][config["template"]]["crop_ref"],
/ config["template_files"][config["template"]]["crop_ref"].format(**wildcards),
output:
nii=bids(
root=work,
Expand Down
12 changes: 8 additions & 4 deletions hippunfold/workflow/rules/preproc_t1.smk
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ else:

def reg_to_template_cmd(wildcards, input, output):

ref = (
ref = str(
Path(input.template_dir)
/ config["template_files"][config["template"]][wildcards.modality],
/ config["template_files"][config["template"]][wildcards.modality].format(
**wildcards
),
)
if config["no_reg_template"]:
cmd = f"reg_resample -flo {input.flo} -ref {ref} -res {output.warped_subj} -aff {input.xfm_identity}; cp {input.xfm_identity} {output.xfm_ras}"
Expand Down Expand Up @@ -183,7 +185,9 @@ rule compose_template_xfm_corobl:
template_dir=Path(download_dir) / "template" / config["template"],
params:
std_to_cor=lambda wildcards, input: Path(input.template_dir)
/ config["template_files"][config["template"]]["xfm_corobl"],
/ config["template_files"][config["template"]]["xfm_corobl"].format(
**wildcards
),
output:
sub_to_cor=bids(
root=work,
Expand Down Expand Up @@ -288,7 +292,7 @@ rule warp_t1_to_corobl_crop:
template_dir=Path(download_dir) / "template" / config["template"],
params:
ref=lambda wildcards, input: Path(input.template_dir)
/ config["template_files"][config["template"]]["crop_ref"],
/ config["template_files"][config["template"]]["crop_ref"].format(**wildcards),
output:
t1=bids(
root=work,
Expand Down
9 changes: 4 additions & 5 deletions hippunfold/workflow/rules/preproc_t2.smk
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,9 @@ def get_cmd_compose_t2_xfm_corobl(wildcards, input):
# xfm0: t2 to template
xfm0 = input.t2_to_std
# xfm1: template to corobl
xfm1 = (
Path(input.template_dir)
/ config["template_files"][config["template"]]["xfm_corobl"]
)
xfm1 = Path(input.template_dir) / config["template_files"][config["template"]][
"xfm_corobl"
].format(**wildcards)

return "c3d_affine_tool -itk {xfm0} -itk {xfm1} -mult -oitk {output}"

Expand Down Expand Up @@ -394,7 +393,7 @@ rule warp_t2_to_corobl_crop:
template_dir=Path(download_dir) / "template" / config["template"],
params:
ref=lambda wildcards, input: Path(input.template_dir)
/ config["template_files"][config["template"]]["crop_ref"],
/ config["template_files"][config["template"]]["crop_ref"].format(**wildcards),
output:
nii=bids(
root=work,
Expand Down
8 changes: 6 additions & 2 deletions hippunfold/workflow/rules/qc.smk
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ rule qc_reg_to_template:
),
template_dir=Path(download_dir) / "template" / config["template"],
params:
ref=lambda wildcards, input: Path(input.template_dir)
/ config["template_files"][config["template"]][wildcards.native_modality],
ref=lambda wildcards, input: str(
Path(input.template_dir)
/ config["template_files"][config["template"]][
wildcards.native_modality
].format(**wildcards)
),
output:
png=report(
bids(
Expand Down
Loading