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: Threshold boldref resampled values to be non-negative #2630

Merged
merged 5 commits into from
Dec 9, 2021

Conversation

effigies
Copy link
Member

https://neurostars.org/t/negative-data-following-multi-echo-optimal-combination-in-fmriprep/20698

The simplest place to do this seemed to be post-resample, pre-merge. This way it applies to single-echo and multi-echo data identically, with no possibility of missed branches during workflow construction.

I chose to make a simple Python interface rather than use fslmaths just because I didn't want to reason about possible type coercion.

Should we be doing this in all resampling workflows?

Copy link
Member

@oesteban oesteban left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good in principle, although we may have this interface already in niworkflows (or something really close) and we may have a patched version of antsApplyTransforms that runs this thresholding too - worth having a look and confirming I'm wrong before merging.

@@ -620,7 +628,8 @@ def init_bold_preproc_trans_wf(
(("bold_file", _first), "reference_image")]),
(inputnode, merge, [("name_source", "header_source")]),
(merge_xforms, bold_transform, [("out", "transforms")]),
(bold_transform, merge, [("out_files", "in_files")]),
(bold_transform, threshold, [("out_files", "in_file")]),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would actually threshold the "preprocessed" echos, right? (which is actually the fix to the problem, as the boldref is not the target here).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this thresholds the preprocessed echos (or the preprocessed BOLD, if single echo).

fmriprep/interfaces/maths.py Outdated Show resolved Hide resolved
fmriprep/interfaces/maths.py Outdated Show resolved Hide resolved
@pep8speaks
Copy link

pep8speaks commented Dec 1, 2021

Hello @effigies! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2021-12-08 16:37:17 UTC

@effigies
Copy link
Member Author

effigies commented Dec 1, 2021

@mgxd Switched to a clipping interface.

@oesteban We use MultiApplyTransforms, which definitely doesn't threshold. I would rather keep it explicit than patch.

Should we also be thresholding after MultiApplyTransforms when resampling to T1w and template?

@effigies effigies force-pushed the fix/threshold_echos branch 2 times, most recently from 54945b9 to 2de37ac Compare December 1, 2021 15:27
Copy link
Collaborator

@mgxd mgxd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just need to add in the missing imports

Copy link
Collaborator

@mgxd mgxd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, that may have been pre-emptive...

fmriprep/interfaces/maths.py Show resolved Hide resolved
@effigies effigies added this to the 21.0.0 milestone Dec 8, 2021
@effigies effigies merged commit 6942aed into nipreps:master Dec 9, 2021
@effigies effigies deleted the fix/threshold_echos branch December 9, 2021 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants