Skip to content

Commit

Permalink
Use directory instead of dynamic in Snakefile
Browse files Browse the repository at this point in the history
  • Loading branch information
tkkuehn committed Feb 26, 2021
1 parent a9bae3d commit da07be6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 49 deletions.
2 changes: 1 addition & 1 deletion snakebids2dicom/config/snakebids.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pybids_inputs:
wildcards:
- subject
- session
- acquisition
- acquisition

#configuration for the command-line parameters to make available
# passed on the argparse add_argument()
Expand Down
84 changes: 36 additions & 48 deletions snakebids2dicom/workflow/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,54 +7,44 @@ snakebids.generate_inputs_config(config)

wildcard_constraints: **snakebids.get_wildcard_constraints(config)

print('config["input_path"]["T1map"]: {}'.format(config["input_path"]["T1map"]))

rule all:
input:
[dynamic(
"{}/{{dicom_frame}}.dcm".format(bids_file)) for bids_file in
expand(
bids(
root="dicom",
datatype="anat",
acq="{acq}",
suffix="T1map",
**config["subj_wildcards"]
),
zip,
**config["input_zip_lists"]["T1map"],
allow_missing=True
)],
[dynamic(
"{}/{{dicom_frame}}.dcm".format(bids_file)) for bids_file in
expand(
bids(
root="dicom",
datatype="anat",
acq="{acq}",
suffix="T2map",
**config["subj_wildcards"]
),
zip,
**config["input_zip_lists"]["T2map"],
allow_missing=True
)]
expand(
bids(
root="dicom",
datatype="anat",
acq="{acq}",
suffix="T1map",
**config["subj_wildcards"]
),
zip,
**config["input_zip_lists"]["T1map"],
),
expand(
bids(
root="dicom",
datatype="anat",
acq="{acq}",
suffix="T2map",
**config["subj_wildcards"]
),
zip,
**config["input_zip_lists"]["T2map"],
)

# Having a separate rule for T1 maps and T2 maps is a little awkward, but
# Snakebids doesn't seem to handle suffixes as wildcards very well.
rule nifti2dicom_t1:
input:
config["input_path"]["T1map"]
output:
dynamic(
"{}/{{dicom_frame}}.dcm".format(
bids(
root="dicom",
datatype="anat",
acq="{acq}",
suffix="T1map",
**config["subj_wildcards"]
)
directory(
bids(
root="dicom",
datatype="anat",
acq="{acq}",
suffix="T1map",
**config["subj_wildcards"]
)
)
container:
Expand All @@ -66,15 +56,13 @@ rule nifti2dicom_t2:
input:
config["input_path"]["T2map"]
output:
dynamic(
"{}/{{dicom_frame}}.dcm".format(
bids(
root="dicom",
datatype="anat",
acq="{acq}",
suffix="T2map",
**config["subj_wildcards"]
)
directory(
bids(
root="dicom",
datatype="anat",
acq="{acq}",
suffix="T2map",
**config["subj_wildcards"]
)
)
container:
Expand Down

0 comments on commit da07be6

Please sign in to comment.