Skip to content

Commit

Permalink
Merge pull request #37 from akhanf/fix-home
Browse files Browse the repository at this point in the history
- adds `--home $PWD` to the custom singularity exec calls, was failing without this when trying to use SLURM_TMPDIR
   - note: snakemake uses --home $PWD with the container directive too
- move qc folder from root into subject/session folders by using it as a datatype instead
  • Loading branch information
akhanf authored Dec 23, 2022
2 parents 0d19f66 + 48c5484 commit b7d795e
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 18 deletions.
15 changes: 13 additions & 2 deletions snakedwi/workflow/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,24 @@ rule all:
**get_eddy_quad_all(),
**get_bedpost_all(),
mask_qc=expand(
bids(root="qc", suffix="mask.png", desc="brain", **subj_wildcards),
bids(
root=root,
datatype="qc",
suffix="mask.png",
desc="brain",
**subj_wildcards
),
zip,
**input_zip_lists["dwi"]
),
reg_qc=expand(
bids(
root="qc", suffix="reg.png", from_="dwiref", to="T1w", **subj_wildcards
root=root,
datatype="qc",
suffix="reg.png",
from_="dwiref",
to="T1w",
**subj_wildcards
),
zip,
**input_zip_lists["dwi"]
Expand Down
27 changes: 18 additions & 9 deletions snakedwi/workflow/rules/prepdwi.smk
Original file line number Diff line number Diff line change
Expand Up @@ -718,13 +718,24 @@ rule qc_brainmask_for_eddy:
),
seg=get_mask_for_eddy(),
output:
# png = bids(root='qc',subject='{subject}',suffix='mask.png',desc='brain'),
png=report(
bids(root="qc", suffix="mask.png", desc="brain", **subj_wildcards),
bids(
root=root,
datatype="qc",
suffix="mask.png",
desc="brain",
**subj_wildcards
),
caption="../report/brainmask_dwi.rst",
category="Brainmask",
),
html=bids(root="qc", suffix="mask.html", desc="brain", **subj_wildcards),
html=bids(
root=root,
datatype="qc",
suffix="mask.html",
desc="brain",
**subj_wildcards
),
group:
"subj"
container:
Expand Down Expand Up @@ -984,20 +995,18 @@ if config["use_eddy_gpu"]:
gpus=1,
time=360, #6 hours (this is a conservative estimate, may be shorter)
mem_mb=32000,
log:
bids(root="logs", suffix="run_eddy_gpu.log", **subj_wildcards),
group:
"subj"
shell:
"singularity exec --nv -e {params.container} eddy_cuda9.1 "
"singularity exec --nv --home $PWD -e {params.container} eddy_cuda9.1 "
" --imain={input.dwi_concat} --mask={input.brainmask} "
" --acqp={input.phenc_concat} --index={input.eddy_index_txt} "
" --bvecs={input.bvecs} --bvals={input.bvals} "
" --out={params.out_prefix} "
" {params.s2v_opts} "
" {params.slspec_opt} "
" {params.topup_opt} "
" {params.flags} &> {log}"
" {params.flags}"


else:
Expand Down Expand Up @@ -1401,7 +1410,7 @@ if config["use_bedpost_gpu"]:
shell:
#remove the logs to reduce # of files
# remove the input dir (copy of files)
"singularity exec --nv -e {params.container} bedpostx_gpu {input.diff_dir} && "
"singularity exec --nv --home $PWD -e {params.container} bedpostx_gpu {input.diff_dir} && "
"rm -rf {output.bedpost_dir}/logs "


Expand Down Expand Up @@ -1490,7 +1499,7 @@ else:
mem_mb=16000,
time=360,
shell:
"singularity exec -B {params.parallel_script}:{params.parallel_script_container} -e "
"singularity exec --home $PWD -B {params.parallel_script}:{params.parallel_script_container} -e "
" {params.container} {params.bedpost_script} {input.diff_dir} -P {threads} && "
"rm -rf {output.bedpost_dir}/logs "

Expand Down
14 changes: 12 additions & 2 deletions snakedwi/workflow/rules/reg_dwi_to_t1.smk
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,23 @@ rule qc_reg_dwi_t1:
output:
png=report(
bids(
root="qc", suffix="reg.png", **subj_wildcards, from_="dwiref", to="T1w"
root=root,
datatype="qc",
suffix="reg.png",
**subj_wildcards,
from_="dwiref",
to="T1w"
),
caption="../report/reg_dwi_t1.rst",
category="B0 T1w registration",
),
html=bids(
root="qc", suffix="reg.html", from_="dwiref", to="T1w", **subj_wildcards
root=root,
datatype="qc",
suffix="reg.html",
from_="dwiref",
to="T1w",
**subj_wildcards
),
group:
"subj"
Expand Down
15 changes: 10 additions & 5 deletions snakedwi/workflow/rules/visqc.smk
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ rule qc_reg:
output:
png=report(
bids(
root="qc",
root=root,
datatype="qc",
subject="{subject}",
suffix="regqc.png",
from_="subject",
Expand All @@ -24,7 +25,8 @@ rule qc_reg:
subcategory="{desc} {template}",
),
html=bids(
root="qc",
root=root,
datatype="qc",
subject="{subject}",
suffix="regqc.html",
from_="subject",
Expand All @@ -51,7 +53,8 @@ rule qc_probseg:
output:
png=report(
bids(
root="qc",
root=root,
datatype="qc",
subject="{subject}",
suffix="probseg.png",
desc="atropos3seg",
Expand Down Expand Up @@ -82,7 +85,8 @@ rule qc_dseg:
output:
png=report(
bids(
root="qc",
root=root,
datatype="qc",
subject="{subject}",
suffix="dseg.png",
atlas="{atlas}",
Expand All @@ -93,7 +97,8 @@ rule qc_dseg:
subcategory="{atlas} Atlas from {template}",
),
html=bids(
root="qc",
root=root,
datatype="qc",
subject="{subject}",
suffix="dseg.html",
atlas="{atlas}",
Expand Down

0 comments on commit b7d795e

Please sign in to comment.