Skip to content

Commit

Permalink
removed unneeded def
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan DeKraker committed Dec 17, 2024
1 parent b69dd4b commit da663d7
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 37 deletions.
45 changes: 19 additions & 26 deletions hippunfold/workflow/rules/common.smk
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def get_modality_suffix(modality):

def get_final_spec():
if len(config["hemi"]) == 2:
specs = inputs[get_modality_key(config["modality"])].expand(
specs = inputs[config["modality"]].expand(
bids(
root=root,
datatype="surf",
Expand All @@ -57,7 +57,7 @@ def get_final_spec():
allow_missing=True,
)
else:
specs = inputs[get_modality_key(config["modality"])].expand(
specs = inputs[config["modality"]].expand(
bids(
root=root,
datatype="surf",
Expand All @@ -80,7 +80,7 @@ def get_final_spec():
def get_final_surf():
gii = []
gii.extend(
inputs[get_modality_key(config["modality"])].expand(
inputs[config["modality"]].expand(
bids(
root=root,
datatype="surf",
Expand All @@ -100,7 +100,7 @@ def get_final_surf():
)
)
gii.extend(
inputs[get_modality_key(config["modality"])].expand(
inputs[config["modality"]].expand(
bids(
root=root,
datatype="surf",
Expand All @@ -123,7 +123,7 @@ def get_final_surf():


def get_final_subfields():
return inputs[get_modality_key(config["modality"])].expand(
return inputs[config["modality"]].expand(
bids(
root=root,
datatype="anat",
Expand All @@ -150,7 +150,7 @@ def get_final_coords():
coords = []
# compute all laplace coords by default (incl IO)
coords.extend(
inputs[get_modality_key(config["modality"])].expand(
inputs[config["modality"]].expand(
bids(
root=root,
datatype="coords",
Expand All @@ -171,7 +171,7 @@ def get_final_coords():
)
)
coords.extend(
inputs[get_modality_key(config["modality"])].expand(
inputs[config["modality"]].expand(
bids(
root=root,
datatype="coords",
Expand All @@ -197,7 +197,7 @@ def get_final_transforms():
xfms = []

xfms.extend(
inputs[get_modality_key(config["modality"])].expand(
inputs[config["modality"]].expand(
bids(
root=root,
datatype="warps",
Expand All @@ -217,7 +217,7 @@ def get_final_transforms():
)

xfms.extend(
inputs[get_modality_key(config["modality"])].expand(
inputs[config["modality"]].expand(
bids(
root=root,
datatype="warps",
Expand All @@ -237,7 +237,7 @@ def get_final_transforms():
)

xfms.extend(
inputs[get_modality_key(config["modality"])].expand(
inputs[config["modality"]].expand(
bids(
root=root,
datatype="warps",
Expand All @@ -256,10 +256,9 @@ def get_final_transforms():

def get_final_anat():
anat = []

if "T1w" in ref_spaces or "T2w" in ref_spaces:
anat.extend(
inputs[get_modality_key(config["modality"])].expand(
inputs[config["modality"]].expand(
bids(
root=root,
datatype="anat",
Expand All @@ -284,7 +283,7 @@ def get_final_qc():

if not template_modality == False:
qc.extend(
inputs[get_modality_key(config["modality"])].expand(
inputs[config["modality"]].expand(
bids(
root=root,
datatype="qc",
Expand All @@ -298,7 +297,7 @@ def get_final_qc():
)
)
qc.extend(
inputs[get_modality_key(config["modality"])].expand(
inputs[config["modality"]].expand(
bids(
root=root,
datatype="qc",
Expand All @@ -316,7 +315,7 @@ def get_final_qc():
)
)
qc.extend(
inputs[get_modality_key(config["modality"])].expand(
inputs[config["modality"]].expand(
bids(
root=root,
datatype="qc",
Expand All @@ -337,7 +336,7 @@ def get_final_qc():
)
if len(config["hemi"]) == 2:
qc.extend(
inputs[get_modality_key(config["modality"])].expand(
inputs[config["modality"]].expand(
bids(
root=root,
datatype="qc",
Expand All @@ -355,7 +354,7 @@ def get_final_qc():
if (config["modality"] == "T1w") or (config["modality"] == "T2w"):
if not config["use_template_seg"]:
qc.extend(
inputs[get_modality_key(config["modality"])].expand(
inputs[config["modality"]].expand(
bids(
root=root,
datatype="qc",
Expand Down Expand Up @@ -392,27 +391,21 @@ def get_final_output():
final_output = []

modality_suffix = get_modality_suffix(config["modality"])
modality_key = get_modality_key(config["modality"])
modality_key = config["modality"]

# use a zip list for subject/session:
zip_list = inputs[modality_key].zip_lists
if "session" in zip_list:
zip_list = snakebids.filter_list(
zip_list,
{
"session": inputs[get_modality_key(config["modality"])].zip_lists[
"session"
]
},
{"session": inputs[config["modality"]].zip_lists["session"]},
)

final_output.extend(
expand(
expand(subj_output, zip, allow_missing=True, **zip_list),
modality_suffix=modality_suffix,
)
)

return final_output


Expand Down Expand Up @@ -455,7 +448,7 @@ def get_final_work_tar():


def get_work_dir(wildcards):
folder_with_file = inputs[get_modality_key(config["modality"])].expand(
folder_with_file = inputs[config["modality"]].expand(
bids(root=work, **inputs.subj_wildcards), **wildcards
)
folder_without_file = os.path.dirname(folder_with_file[0])
Expand Down
12 changes: 3 additions & 9 deletions hippunfold/workflow/rules/gifti.smk
Original file line number Diff line number Diff line change
Expand Up @@ -1331,9 +1331,7 @@ rule create_spec_file_hipp:
metric=get_gifti_metric_types(wildcards.label),
allow_missing=True,
),
subfields=lambda wildcards: inputs[
get_modality_key(config["modality"])
].expand(
subfields=lambda wildcards: inputs[config["modality"]].expand(
bids(
root=root,
datatype="surf",
Expand Down Expand Up @@ -1363,9 +1361,7 @@ rule create_spec_file_hipp:
space=["{space}", "unfold"],
allow_missing=True,
),
cifti_metrics=lambda wildcards: inputs[
get_modality_key(config["modality"])
].expand(
cifti_metrics=lambda wildcards: inputs[config["modality"]].expand(
bids(
root=root,
datatype="surf",
Expand All @@ -1378,9 +1374,7 @@ rule create_spec_file_hipp:
cifti=get_cifti_metric_types(wildcards.label),
allow_missing=True,
),
cifti_labels=lambda wildcards: inputs[
get_modality_key(config["modality"])
].expand(
cifti_labels=lambda wildcards: inputs[config["modality"]].expand(
bids(
root=root,
datatype="surf",
Expand Down
2 changes: 1 addition & 1 deletion hippunfold/workflow/rules/qc.smk
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ rule qc_reg_to_template:
rule get_subfield_vols_subj:
"""Export segmentation volume for a subject to TSV"""
input:
segs=inputs[get_modality_key(config["modality"])].expand(
segs=inputs[config["modality"]].expand(
bids(
root=root,
**inputs.subj_wildcards,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ rule create_native_crop_ref:
"""Create ref space for hires crop in native space
TODO: expose the resampling factor and size as cmd line args"""
input:
seg=inputs[get_modality_key(config["modality"])].expand(
seg=inputs[config["modality"]].expand(
bids(
root=root,
datatype="anat",
Expand Down

0 comments on commit da663d7

Please sign in to comment.