Skip to content

Conversation

@tsalo
Copy link
Contributor

@tsalo tsalo commented Oct 1, 2019

Closes #399.

This PR allows bold_reference_wf to accept multiple BOLD and/or SBRef files, under the assumption that multiple files reflect multiple echoes from the same run. It currently just selects the first image from each for use, but could be extended to use information from multiple echoes for reference image generation.

The workflow still returns just one BOLD file, since a number of workflows take the BOLD file stored in the output node as their inputs, and they are not currently set up to work with multi-echo data. To that end I also added a function to utils.misc to select the first item in a list.

These changes shouldn't impact behavior at all, but there will need to be a corresponding PR in fMRIPrep in order to feed multi-echo data and SBRefs into the reference image workflow, when available.

@codecov
Copy link

codecov bot commented Oct 1, 2019

Codecov Report

Merging #408 into master will decrease coverage by 5.59%.
The diff coverage is 34.61%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #408     +/-   ##
=========================================
- Coverage   59.05%   53.46%   -5.6%     
=========================================
  Files          45       59     +14     
  Lines        5002     5630    +628     
  Branches      681      681             
=========================================
+ Hits         2954     3010     +56     
- Misses       2002     2565    +563     
- Partials       46       55      +9
Flag Coverage Δ
#masks ?
#reportlettests 100% <ø> (?)
#unittests 41.42% <34.61%> (-0.57%) ⬇️
Impacted Files Coverage Δ
niworkflows/utils/misc.py 80.58% <100%> (+0.78%) ⬆️
niworkflows/func/util.py 24.39% <16.66%> (-53.7%) ⬇️
niworkflows/interfaces/registration.py 51.47% <30%> (-10.6%) ⬇️
niworkflows/interfaces/fixes.py 47.05% <0%> (-39.22%) ⬇️
niworkflows/engine/workflows.py 26.31% <0%> (-15.79%) ⬇️
niworkflows/interfaces/utils.py 40.71% <0%> (-7.39%) ⬇️
niworkflows/viz/utils.py 74.09% <0%> (-7.26%) ⬇️
niworkflows/interfaces/ants.py 63.74% <0%> (-7.02%) ⬇️
... and 17 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bf96c7c...0b14105. Read the comment docs.

Copy link
Member

@effigies effigies left a comment

Choose a reason for hiding this comment

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

Looks pretty good overall. Some suggestions. Is there to be an fMRIPrep patch that depends on this? It looks like with the switch to MapNode, we're going to have to have some simultaneous changes downstream.

@oesteban Do we use init_bold_reference_wf in MRIQC or anywhere else?

@tsalo
Copy link
Contributor Author

tsalo commented Oct 2, 2019

@effigies thanks! I've made the requested changes. I do plan to open a patch PR to fMRIPrep to match this one.

The tests seem to be failing due to a random connection error.

@effigies
Copy link
Member

effigies commented Oct 2, 2019

Before you change any code in fMRIPrep, can you just update the niworkflows requirement, to see if that breaks tests? If we can maintain backwards compatibility, I think that would be ideal. If we don't currently have it, I think we can fix it up with:

     workflow.connect([
         (inputnode, enhance_and_skullstrip_bold_wf, [('bold_mask', 'inputnode.pre_mask')]),
-        (inputnode, validate, [('bold_file', 'in_file')]),
+        (inputnode, validate, [(('bold_file', ensure_list), 'in_file')]),
         (inputnode, gen_ref, [('sbref_file', 'sbref_file')]),
         (inputnode, calc_dummy_scans, [('dummy_scans', 'dummy_scans')]),

Using nipype.utils.filemanip.ensure_list.

@pep8speaks
Copy link

pep8speaks commented Oct 2, 2019

Hello @tsalo, Thank you for updating!

Cheers! There are no style issues detected in this Pull Request. 🍻 To test for issues locally, pip install flake8 and then run flake8 niworkflows.

Comment last updated at 2020-06-07 02:12:47 UTC

@effigies
Copy link
Member

effigies commented Oct 2, 2019

Don't worry about the pep8 speaks just yet... I need to configure it.

@effigies
Copy link
Member

effigies commented Oct 2, 2019

Okay, should be configured. Can you merge master in?

@effigies
Copy link
Member

effigies commented Oct 2, 2019

Hmm. I don't understand why it's not getting the 99-character limit correct. I'll look into it.

@effigies
Copy link
Member

effigies commented Oct 2, 2019

Got it. It was looking for config in setup.cfg, not tox.ini. Updated. Would you mind rebasing this time, to avoid a bunch of merge commits?

@tsalo
Copy link
Contributor Author

tsalo commented Oct 2, 2019

Will do. Regarding fMRIPrep compatibility, what is the best way for me to check? I can run fMRIPrep (plus my niworkflows fork) locally in a Docker image, but is it enough to run with --boilerplate or should I process a dataset fully with --sloppy?

@tsalo tsalo closed this Oct 2, 2019
@tsalo tsalo reopened this Oct 2, 2019
@tsalo
Copy link
Contributor Author

tsalo commented Oct 2, 2019

Oh sorry, I made a merge commit instead. Sorry about that. I assume that this can be squashed and merged though? To remove those commits?

@effigies
Copy link
Member

effigies commented Oct 2, 2019

Eh, either way. But I don't think you're likely to run into any conflicts with:

git fetch poldracklab
git rebase poldracklab/master

If it doesn't rebase cleanly, just git rebase --abort and don't worry about it.

@effigies
Copy link
Member

effigies commented Oct 2, 2019

Cool, thanks.

For fMRIPrep, I just mean have a commit where you update the niworkflows dependency to niworkflows @ git+https://github.com/tsalo/niworkflows.git@<commit>, and let the tests run on CI, before making any code changes.

@effigies
Copy link
Member

effigies commented Oct 2, 2019

Okay. Hopefully last rebase needed...

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.

I'm worried these changes are very implicit, before going ahead we should set up several tests. Happy to help with that.

@tsalo
Copy link
Contributor Author

tsalo commented Oct 24, 2019

Just wanted to ping this PR. The last time I checked, there was still some disagreement about the behavior of InputMultiObject. Should I treat single-item InputMultiObjects as strings or lists?

@oesteban
Copy link
Member

oesteban commented Oct 24, 2019 via email

@tsalo
Copy link
Contributor Author

tsalo commented Oct 24, 2019

No pressure! I just wanted to make sure it wasn't waiting on me for anything.

@pull-assistant
Copy link

pull-assistant bot commented Dec 7, 2019

Score: 0.72

Best reviewed: commit by commit


Optimal code review plan (6 warnings, 2 commits squashed)

Allow bold_reference_wf to accept lists of EPI/SBRef files.

niworkflows/func/util.py 89% changes removed in enh: do not use inli...

...ows/interfaces/registration.py 47% changes removed in enh: deep revision o...

niworkflows/utils/misc.py 69% changes removed in fix: do not use ``ni...

     Remove output from failed attempt to track description.

     Add doctest for select_first.

Replace traits.Either with InputMultiPath.

...ows/interfaces/registration.py 50% changes removed in Update niworkflows/i...

Use ensure_list for backwards compatibility.

niworkflows/func/util.py 67% changes removed in Add multiecho argume...

     Update niworkflows/func/util.py

     Update niworkflows/interfaces/registration.py

Add multiecho argument to init_bold_reference_wf.

niworkflows/func/util.py 62% changes removed in enh: better handling...

     Check inputs against multiecho argument in EstimateReferenceImage.

Fix that mistake.

...ows/interfaces/registration.py 50% changes removed in enh: deep revision o...

     Update niworkflows/utils/misc.py

     FIX: Update mask-regression tests for #408

Apply suggestions fr... ... enh: do not use inli...

Squashed 2 commits:

niworkflows/func/util.py 82% changes removed in enh: better handling...

     enh: deep revision of EstimateReferenceImage

     chore: cosmetic changes & deduplicate _pop definition in ants

     critical: bump regression data cache-id on CircleCI [skip ci]

     enh: better handling of sbrefs and the workflow's description

     fix: do not use nipype.utils.filemanip.ensure_list

Powered by Pull Assistant. Last update 89f1704 ... 6fe250c. Read the comment docs.

@oesteban
Copy link
Member

oesteban commented Mar 1, 2020

Codacy Here is an overview of what got changed by this pull request:

Complexity increasing per file
==============================
- niworkflows/interfaces/registration.py  4
- niworkflows/func/util.py  2
         

See the complete overview on Codacy

@codecov
Copy link

codecov bot commented Mar 18, 2020

Codecov Report

Merging #408 into master will decrease coverage by 0.33%.
The diff coverage is 36.50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #408      +/-   ##
==========================================
- Coverage   64.50%   64.16%   -0.34%     
==========================================
  Files          43       44       +1     
  Lines        5341     5372      +31     
  Branches      778      784       +6     
==========================================
+ Hits         3445     3447       +2     
- Misses       1745     1774      +29     
  Partials      151      151              
Flag Coverage Δ
#documentation 33.74% <20.63%> (-0.08%) ⬇️
#masks ?
#reportlettests 100.00% <ø> (?)
#travis 59.29% <30.15%> (-0.09%) ⬇️
#unittests 47.75% <30.15%> (-0.02%) ⬇️
Impacted Files Coverage Δ
niworkflows/interfaces/registration.py 49.38% <8.57%> (-2.34%) ⬇️
niworkflows/func/util.py 80.00% <38.46%> (-7.84%) ⬇️
niworkflows/anat/ants.py 70.78% <100.00%> (+1.17%) ⬆️
niworkflows/utils/connections.py 100.00% <100.00%> (ø)
niworkflows/interfaces/images.py 58.00% <0.00%> (-4.04%) ⬇️
niworkflows/viz/utils.py 80.35% <0.00%> (+0.23%) ⬆️
niworkflows/interfaces/mni.py 42.52% <0.00%> (+0.24%) ⬆️
niworkflows/utils/bids.py 75.00% <0.00%> (+0.74%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f963b2c...6fe250c. Read the comment docs.

@oesteban
Copy link
Member

oesteban commented Jun 6, 2020

I'm going to make this a draft so that it is isn't accidentally merged without updating the regression data (which I'll do right before merging).

@oesteban oesteban marked this pull request as draft June 6, 2020 00:13
oesteban added 3 commits June 5, 2020 21:33
This is necessary as now the masks regressions will only be run on
the first echo of ME datasets.

This id bump will only be applied after merging into master, as the
regression tests are run only on master or branches with the prefix
``masks?/``.

Reference: #1.
Because that function utilizes ``is_container``, which is imported at
global context, nipype could not evaluate ``ensure_list`` calls inlined
inside ``connect``. This would end up failing with:

```
fMRIPrep failed: name 'is_container' is not defined
```

A new module for nipype connections is created to provide this kind of
commodity functions for all NiPreps.
@oesteban
Copy link
Member

oesteban commented Jun 8, 2020

Thumbs up?

@oesteban
Copy link
Member

oesteban commented Jun 8, 2020

Okay, I just uploaded the new masks and started https://app.circleci.com/pipelines/github/oesteban/niworkflows/115/workflows/3236dc2a-0115-4f3e-88d5-ab31cdd332f4

Once that build is passing, I'll merge this PR.

@oesteban oesteban marked this pull request as ready for review June 8, 2020 16:02
@oesteban oesteban merged commit 962ce99 into nipreps:master Jun 8, 2020
oesteban added a commit to tsalo/fmriprep that referenced this pull request Jun 9, 2020
effigies pushed a commit to nipreps/fmriprep-rodents that referenced this pull request Jul 9, 2020
oesteban added a commit that referenced this pull request Aug 14, 2020
First release in the 1.3.x series. This release includes enhancements and bug-fixes
towards the release of the first LTS version of fMRIPrep.
PyBIDS has been revised to use more recent versions, a series of ANTs' interfaces
have been deemed ready to upstream into Nipype, and several improvements regarding
multi-echo EPI are included.
With thanks to Basile Pinsard for contributions.

  * FIX: Patch ``ApplyTransforms`` spec to permit identity in a chain (#554)
  * FIX: Add dots to extensions in PyBIDS' config file (#548)
  * FIX: Segmentation plots aligned with cardinal axes (#544)
  * FIX: Skip T1w file existence check if ``anat_derivatives`` are provided (#545)
  * FIX: Avoid diverting CIFTI dtype from original BOLD (#532)
  * ENH: Add ``smooth`` input to ``RegridToZooms`` (#549)
  * ENH: Enable ``DerivativesDataSink`` to take multiple source files to derive entities (#547)
  * ENH: Allow ``bold_reference_wf`` to accept multiple EPIs/SBRefs (#408)
  * ENH: Numerical stability of EPI brain-masks using probabilistic prior (#485)
  * ENH: Add a pure-Python interface to resample to specific resolutions (#511)
  * MAINT: Finalize upstreaming of ANTs' interfaces to Nipype (#550)
  * MAINT: Update to Python +3.6 (#541)
HippocampusGirl added a commit to HippocampusGirl/niworkflows that referenced this pull request Sep 29, 2020
1.3.0rc3

First release in the 1.3.x series. This release includes enhancements and bug-fixes
towards the release of the first LTS version of fMRIPrep.
PyBIDS has been revised to use more recent versions, a series of ANTs' interfaces
have been deemed ready to upstream into Nipype, and several improvements regarding
multi-echo EPI are included.
With thanks to Basile Pinsard for contributions.

* FIX: Patch ``ApplyTransforms`` spec to permit identity in a chain (nipreps#554)
* FIX: Add dots to extensions in PyBIDS' config file (nipreps#548)
* FIX: Segmentation plots aligned with cardinal axes (nipreps#544)
* FIX: Skip T1w file existence check if ``anat_derivatives`` are provided (nipreps#545)
* FIX: Avoid diverting CIFTI dtype from original BOLD (nipreps#532)
* ENH: Add ``smooth`` input to ``RegridToZooms`` (nipreps#549)
* ENH: Enable ``DerivativesDataSink`` to take multiple source files to derive entities (nipreps#547)
* ENH: Allow ``bold_reference_wf`` to accept multiple EPIs/SBRefs (nipreps#408)
* ENH: Numerical stability of EPI brain-masks using probabilistic prior (nipreps#485)
* ENH: Add a pure-Python interface to resample to specific resolutions (nipreps#511)
* MAINT: Finalize upstreaming of ANTs' interfaces to Nipype (nipreps#550)
* MAINT: Update to Python +3.6 (nipreps#541)
HippocampusGirl added a commit to HippocampusGirl/niworkflows that referenced this pull request Sep 29, 2020
1.3.0

First release in the 1.3.x series.
This release includes enhancements and bug-fixes towards the release of the first
LTS (*long-term support*) version of *fMRIPrep*.
*PyBIDS* has been revised to use more recent versions, a series of ANTs' interfaces
have been deemed ready to upstream into *Nipype*, and several improvements regarding
multi-echo EPI are included.
With thanks to Basile Pinsard for contributions.

* FIX: Patch ``ApplyTransforms`` spec to permit identity in a chain (nipreps#554)
* FIX: Add dots to extensions in PyBIDS' config file (nipreps#548)
* FIX: Segmentation plots aligned with cardinal axes (nipreps#544)
* FIX: Skip T1w file existence check if ``anat_derivatives`` are provided (nipreps#545)
* FIX: Avoid diverting CIFTI dtype from original BOLD (nipreps#532)
* ENH: Add ``smooth`` input to ``RegridToZooms`` (nipreps#549)
* ENH: Enable ``DerivativesDataSink`` to take multiple source files to derive entities (nipreps#547)
* ENH: Allow ``bold_reference_wf`` to accept multiple EPIs/SBRefs (nipreps#408)
* ENH: Numerical stability of EPI brain-masks using probabilistic prior (nipreps#485)
* ENH: Add a pure-Python interface to resample to specific resolutions (nipreps#511)
* MAINT: Upstream all bug-fixes in the 1.2.9 release
* MAINT: Finalize upstreaming of ANTs' interfaces to Nipype (nipreps#550)
* MAINT: Update to Python +3.6 (nipreps#541)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update boilerplate to correctly handle single-band references Accept multiple EPIs/SBRefs for reference image calculation

5 participants