Skip to content

Commit

Permalink
applied similar logic to procT1w
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan DeKraker - B. Bernhardt Lab committed Mar 20, 2024
1 parent 557bec2 commit 95cf1be
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 65 deletions.
1 change: 1 addition & 0 deletions hippunfold/config/snakebids.yml
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ singularity:
autotop: 'docker://khanlab/hippunfold_deps:v0.5.0'

xfm_identity: resources/etc/identity_xfm.txt
xfm_identity_itk: resources/etc/identity_xfm_itk.txt

template_files:
CITI168:
Expand Down
5 changes: 5 additions & 0 deletions hippunfold/resources/etc/identity_xfm_itk.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#Insight Transform File V1.0
#Transform 0
Transform: MatrixOffsetTransformBase_double_3_3
Parameters: 1 0 0 0 1 0 0 0 1 0 0 0
FixedParameters: 0 0 0
70 changes: 5 additions & 65 deletions hippunfold/workflow/rules/preproc_t2.smk
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,6 @@ rule reg_t2_to_t1:

def get_inputs_compose_t2_xfm_corobl(wildcards):
if config["t1_reg_template"]:
# xfm0: t2 to t1
# xfm1: t1 to corobl
t2_to_t1 = (
bids(
root=work,
Expand All @@ -263,66 +261,18 @@ def get_inputs_compose_t2_xfm_corobl(wildcards):
type_="itk"
),
)
t1_to_cor = (
bids(
root=work,
datatype="warps",
**config["subj_wildcards"],
suffix="xfm.txt",
from_="T1w",
to="corobl",
desc="affine",
type_="itk"
),
)
return {"t2_to_t1": t2_to_t1, "t1_to_cor": t1_to_cor}

else:

# xfm0: t2 to template
t2_to_std = (
bids(
root=work,
datatype="warps",
**config["subj_wildcards"],
suffix="xfm.txt",
from_="T2w",
to=config["template"],
desc="affine",
type_="itk"
),
)

# xfm1: template to corobl
template_dir = Path(download_dir) / "template" / config["template"]
return {"t2_to_std": t2_to_std, "template_dir": template_dir}


def get_cmd_compose_t2_xfm_corobl(wildcards, input):
if config["t1_reg_template"]:
# xfm0: t2 to t1
xfm0 = input.t2_to_t1
# xfm1: t1 to corobl
xfm1 = input.t1_to_cor
else:
# 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"
].format(**wildcards)

return "c3d_affine_tool -itk {xfm0} -itk {xfm1} -mult -oitk {output}"
t2_to_t1 = Path(workflow.basedir).parent / config["xfm_identity_itk"]
to_corobl = Path(download_dir) / "template" / config["template"] / config["template_files"][config["template"]]["xfm_corobl"]
return {"t2_to_t1": t2_to_t1, "to_corobl": to_corobl}


# now have t2 to t1 xfm, compose this with t1 to corobl xfm
rule compose_t2_xfm_corobl:
input:
unpack(get_inputs_compose_t2_xfm_corobl),
params:
cmd=get_cmd_compose_t2_xfm_corobl,
output:
t2_to_cor=bids(
bids(
root=work,
datatype="warps",
**config["subj_wildcards"],
Expand All @@ -332,22 +282,12 @@ rule compose_t2_xfm_corobl:
desc="affine",
type_="itk"
),
log:
bids(
root="logs",
**config["subj_wildcards"],
suffix="composecorobl.txt",
from_="T2w",
to="corobl",
desc="affine",
type_="itk"
),
container:
config["singularity"]["autotop"]
group:
"subj"
shell:
"{params.cmd} > {log}"
"c3d_affine_tool -itk {input.t2_to_t1} -itk {input.to_corobl} -mult -oitk {output}"


# if already have t2w in T1w space, then we don't need to use composed xfm:
Expand Down

0 comments on commit 95cf1be

Please sign in to comment.