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

SynthSR+SyN for fieldmap-less distortion correction #50

Merged
merged 8 commits into from
Feb 20, 2023
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
38 changes: 28 additions & 10 deletions snakedwi/config/snakebids.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ derivatives: False
analysis_levels: &analysis_levels
- participant

no_topup: False
use_eddy_s2v: False
eddy_no_quad: False
no_bedpost: False
use_syn_sdc: False

targets_by_analysis_level:
participant:
Expand Down Expand Up @@ -92,10 +87,16 @@ parse_args:
action: 'store_true'
default: False

--no_bedpost:
help: 'Disable bedpost (default: %(default)s)'
action: 'store_true'
default: False
--use_bedpost:
help: 'Enable bedpost (disabled by default)'
action: 'store_false'
dest: 'no_bedpost'
default: True

# --no_bedpost:
# help: 'Disable bedpost (default: %(default)s)'
# action: 'store_true'
# default: True


--use_eddy_s2v:
Expand Down Expand Up @@ -156,6 +157,16 @@ parse_args:
action: 'store_true'
default: False

# --synthsr_sdc:
#help: "Enable SynthSR+SyN fieldmap-less distortion-correction. This uses SynthSR to transform T1w and b0 images to the same 1mm T1w contrast prior to non-linear registration to obtain a field-map. (default: %(default)s)"
#action: 'store_true'
#default: True

--no_synthsr_sdc:
help: "Disable SynthSR+SyN fieldmap-less distortion-correction (enabled by default)"
action: 'store_false'
dest: 'use_synthsr_sdc'
default: True


#---- to update below this
Expand All @@ -173,6 +184,9 @@ singularity:
python: 'docker://khanlab/pythondeps-snakedwi:v0.2.0'
synthstrip: 'docker://freesurfer/synthstrip:1.3'
sdcflows: 'docker://nipreps/fmriprep:22.1.1' #can't currently just use sdcflows docker as it is missing freesurfer's mri_robust_template
synthsr: 'docker://akhanf/synthsr:main'
synthmorph: 'docker://freesurfer/synthmorph:1'




Expand Down Expand Up @@ -281,6 +295,7 @@ eddy:
default_effective_echo_spacing: 0.0001 #if not defined in JSON files

#for test data
root: 'results'
participant_label:
exclude_participant_label:
masking_method: b0_synthstrip
Expand All @@ -292,4 +307,7 @@ use_eddy_gpu: False
use_bedpost_gpu: False
rigid_dwi_t1_init: 'identity'
rigid_dwi_t1_iters: '50x50'
root: 'results'
eddy_no_quad: False
no_topup: False
use_syn_sdc: False
use_synthsr_sdc: True
22 changes: 22 additions & 0 deletions snakedwi/workflow/rules/eddy.smk
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,17 @@ def get_eddy_topup_fmap_input(wildcards):
**subj_wildcards,
).format(**wildcards),
}
elif method == "synthsr":
return {
"fmap": bids(
root=work,
datatype="dwi",
suffix="fmap.nii.gz",
desc="b0",
method="synthSRsdc",
**subj_wildcards,
).format(**wildcards)
}
elif method == "syn":
return {
"fmap": bids(
Expand Down Expand Up @@ -130,6 +141,17 @@ def get_eddy_topup_fmap_opt(wildcards, input):
root=work, suffix="topup", datatype="dwi", **subj_wildcards
).format(**wildcards)
return f"--topup={topup_prefix}"
elif method == "synthsr":
fmap_prefix = bids(
root=work,
datatype="dwi",
suffix="fmap",
desc="b0",
method="synthSRsdc",
**subj_wildcards,
).format(**wildcards)
return f"--field={fmap_prefix}"

elif method == "syn":
fmap_prefix = bids(
root=work,
Expand Down
2 changes: 2 additions & 0 deletions snakedwi/workflow/rules/masking_b0_synthstrip.smk
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ rule synthstrip_b0:
container:
config["singularity"]["synthstrip"]
threads: 8
shadow:
"minimal"
group:
"subj"
shell:
Expand Down
2 changes: 2 additions & 0 deletions snakedwi/workflow/rules/reg_dwi_to_t1.smk
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ rule synthstrip_t1:
container:
config["singularity"]["synthstrip"]
threads: 8
shadow:
"minimal"
shell:
"python3 /freesurfer/mri_synthstrip -i {input.t1} -m {output.mask}"

Expand Down
8 changes: 4 additions & 4 deletions snakedwi/workflow/rules/reg_t1_to_template.smk
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ rule convert_template_xfm_ras2itk:
datatype="transforms",
**subj_wildcards,
suffix="xfm.txt",
from_="subject",
to="{template}",
from_="{from}",
to="{to}",
desc="{desc}",
type_="ras"
),
Expand All @@ -65,8 +65,8 @@ rule convert_template_xfm_ras2itk:
datatype="transforms",
**subj_wildcards,
suffix="xfm.txt",
from_="subject",
to="{template}",
from_="{from}",
to="{to}",
desc="{desc}",
type_="itk"
),
Expand Down
Loading