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

FIX: SyN workflow #453

Merged
merged 2 commits into from
Apr 10, 2025
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
49 changes: 29 additions & 20 deletions nibabies/workflows/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,7 @@
omp_nthreads=omp_nthreads,
output_dir=output_dir,
subject=subject_id,
sd_prior=False, # No priors for infants yet
)
fmap_wf.__desc__ = f"""

Expand All @@ -618,17 +619,18 @@
if node.split('.')[-1].startswith('ds_'):
fmap_wf.get_node(node).interface.out_path_base = ''

fmap_select_std = pe.Node(
KeySelect(fields=['std2anat_xfm'], key='MNI152NLin2009cAsym'),
name='fmap_select_std',
run_without_submitting=True,
)
if any(estimator.method == fm.EstimatorType.ANAT for estimator in fmap_estimators):
workflow.connect([
(anat_fit_wf, fmap_select_std, [
('outputnode.std2anat_xfm', 'std2anat_xfm'),
('outputnode.template', 'keys')]),
]) # fmt:skip
# MG: No prior is used ATM, so no need for xfm
# fmap_select_std = pe.Node(
# KeySelect(fields=['std2anat_xfm'], key='MNI152NLin2009cAsym'),
# name='fmap_select_std',
# run_without_submitting=True,
# )
# if any(estimator.method == fm.EstimatorType.ANAT for estimator in fmap_estimators):
# workflow.connect([
# (anat_fit_wf, fmap_select_std, [
# ('outputnode.std2anat_xfm', 'std2anat_xfm'),
# ('outputnode.template', 'keys')]),
# ]) # fmt:skip

for estimator in fmap_estimators:
config.loggers.workflow.info(
Expand Down Expand Up @@ -663,6 +665,7 @@
debug=config.execution.sloppy,
auto_bold_nss=True,
t1w_inversion=False,
sd_prior=False,
name=f'syn_preprocessing_{estimator.bids_id}',
)
syn_preprocessing_wf.inputs.inputnode.in_epis = sources
Expand All @@ -673,9 +676,10 @@
('outputnode.anat_preproc', 'inputnode.in_anat'),
('outputnode.anat_mask', 'inputnode.mask_anat'),
]),
(fmap_select_std, syn_preprocessing_wf, [
('std2anat_xfm', 'inputnode.std2anat_xfm'),
]),
# MG: No prior is used ATM, so no need for xfm
# (fmap_select_std, syn_preprocessing_wf, [
# ('std2anat_xfm', 'inputnode.std2anat_xfm'),
# ]),
(syn_preprocessing_wf, fmap_wf, [
('outputnode.epi_ref', f'in_{estimator.bids_id}.epi_ref'),
('outputnode.epi_mask', f'in_{estimator.bids_id}.epi_mask'),
Expand Down Expand Up @@ -920,6 +924,7 @@
fmapless=bool(use_syn) or ignore_fieldmaps and force_syn,
force_fmapless=force_syn or ignore_fieldmaps and use_syn,
bids_filters=filters,
anat_suffix=['T1w', 'T2w'],
)

if not fmap_estimators:
Expand All @@ -933,12 +938,16 @@
raise ValueError(message)
return [], {}

if ignore_fieldmaps and any(f.method == fm.EstimatorType.ANAT for f in fmap_estimators):
config.loggers.workflow.info(
'Option "--ignore fieldmaps" was set, but either "--use-syn-sdc" '
'or "--force-syn" were given, so fieldmap-less estimation will be executed.'
)
fmap_estimators = [f for f in fmap_estimators if f.method == fm.EstimatorType.ANAT]
if ignore_fieldmaps:
if any(f.method == fm.EstimatorType.ANAT for f in fmap_estimators):
config.loggers.workflow.info(

Check warning on line 943 in nibabies/workflows/base.py

View check run for this annotation

Codecov / codecov/patch

nibabies/workflows/base.py#L943

Added line #L943 was not covered by tests
'Option "--ignore fieldmaps" was set, but either "--use-syn-sdc" '
'or "--force-syn" were given, so fieldmap-less estimation will be executed.'
)
fmap_estimators = [f for f in fmap_estimators if f.method == fm.EstimatorType.ANAT]

Check warning on line 947 in nibabies/workflows/base.py

View check run for this annotation

Codecov / codecov/patch

nibabies/workflows/base.py#L947

Added line #L947 was not covered by tests
else:
config.loggers.workflow.info('Ignoring fieldmaps - no estimators will be used.')
return [], {}

Check warning on line 950 in nibabies/workflows/base.py

View check run for this annotation

Codecov / codecov/patch

nibabies/workflows/base.py#L949-L950

Added lines #L949 - L950 were not covered by tests

# Pare down estimators to those that are actually used
# If fmap_estimators == [], all loops/comprehensions terminate immediately
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dependencies = [
"pybids >= 0.15.0",
"requests",
"SimpleITK",
"sdcflows >= 2.10.0",
"sdcflows @ git+https://github.com/nipreps/sdcflows.git@master",
"smriprep >= 0.17.0",
"tedana >= 23.0.2",
"templateflow >= 24.2.0",
Expand Down