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

ENH: Save scanner-to-T1w xform to outputs #2233

Merged
merged 12 commits into from
Aug 9, 2020

Conversation

tsalo
Copy link
Collaborator

@tsalo tsalo commented Aug 4, 2020

Closes #1184.

Open questions:

  • Should tfm transforms be supported in DerivativesDatasink?
    • Answer: Replace tfm with txt.
  • Do we want the native-to-T1w transform even when T1w isn't one of the desired spaces?
    • Answer: Yes.

Changes proposed in this pull request

  • Incorporate bold2anat_xfm and anat2bold_xfm into functional derivatives workflow. This will save these transforms only when T1w is a desired output space.

Documentation that should be reviewed

I added the transforms to the "Outputs of fMRIPrep" page.

@tsalo tsalo changed the title [ENH] Save native-to-T1w xform to outputs ENH: Save native-to-T1w xform to outputs Aug 4, 2020
@tsalo
Copy link
Collaborator Author

tsalo commented Aug 5, 2020

The current failure in the ds005 test seems to stem from the fact that the transform being written out has a tfm extension instead of txt or hd5 (thanks to @akimbler for noticing this). Here's the relevant log:

[Node] Running "ds_ref_t1w_warp" ("fmriprep.interfaces.DerivativesDataSink")
200804-21:56:04,678 nipype.workflow WARNING:
	 Storing result file without outputs
200804-21:56:04,679 nipype.workflow WARNING:
	 [Node] Error on "fmriprep_wf.single_subject_01_wf.func_preproc_task_mixedgamblestask_run_02_wf.func_derivatives_wf.ds_ref_t1w_warp" (/scratch/fmriprep_wf/single_subject_01_wf/func_preproc_task_mixedgamblestask_run_02_wf/func_derivatives_wf/ds_ref_t1w_warp)
200804-21:56:04,680 nipype.workflow ERROR:
	 Node ds_ref_t1w_warp failed to run on host 2eec16105d58.
200804-21:56:04,690 nipype.workflow ERROR:
	 Saving crash info to /out/fmriprep/sub-01/log/20200804-210721_3c8fede0-ff9a-4e24-8a11-f1d93226c22c/crash-20200804-215604-UID1001-ds_ref_t1w_warp-428bc157-af06-45f2-82f3-a67937241be4.txt
Traceback (most recent call last):
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/plugins/legacymultiproc.py", line 432, in _send_procs_to_workers
    self.procs[jobid].run(updatehash=updatehash)
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py", line 516, in run
    result = self._run_interface(execute=True)
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py", line 635, in _run_interface
    return self._run_command(execute)
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py", line 741, in _run_command
    result = self._interface.run(cwd=outdir)
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/interfaces/base/core.py", line 397, in run
    runtime = self._run_interface(runtime)
  File "/usr/local/miniconda/lib/python3.7/site-packages/niworkflows/interfaces/bids.py", line 535, in _run_interface
    raise ValueError(f"Could not build path with entities {out_entities}.")
ValueError: Could not build path with entities {'subject': '01', 'task': 'mixedgamblestask', 'run': 2, 'suffix': 'xfm', 'datatype': 'func', 'extension': 'tfm', 'from': 'native', 'to': 'T1w', 'mode': 'image'}.

@akimbler
Copy link

akimbler commented Aug 5, 2020

The current failure in the ds005 test seems to stem from the fact that the transform being written out has a tfm extension instead of txt or hd5 (thanks to @akimbler for noticing this). Here's the relevant log:

[Node] Running "ds_ref_t1w_warp" ("fmriprep.interfaces.DerivativesDataSink")
200804-21:56:04,678 nipype.workflow WARNING:
	 Storing result file without outputs
200804-21:56:04,679 nipype.workflow WARNING:
	 [Node] Error on "fmriprep_wf.single_subject_01_wf.func_preproc_task_mixedgamblestask_run_02_wf.func_derivatives_wf.ds_ref_t1w_warp" (/scratch/fmriprep_wf/single_subject_01_wf/func_preproc_task_mixedgamblestask_run_02_wf/func_derivatives_wf/ds_ref_t1w_warp)
200804-21:56:04,680 nipype.workflow ERROR:
	 Node ds_ref_t1w_warp failed to run on host 2eec16105d58.
200804-21:56:04,690 nipype.workflow ERROR:
	 Saving crash info to /out/fmriprep/sub-01/log/20200804-210721_3c8fede0-ff9a-4e24-8a11-f1d93226c22c/crash-20200804-215604-UID1001-ds_ref_t1w_warp-428bc157-af06-45f2-82f3-a67937241be4.txt
Traceback (most recent call last):
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/plugins/legacymultiproc.py", line 432, in _send_procs_to_workers
    self.procs[jobid].run(updatehash=updatehash)
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py", line 516, in run
    result = self._run_interface(execute=True)
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py", line 635, in _run_interface
    return self._run_command(execute)
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py", line 741, in _run_command
    result = self._interface.run(cwd=outdir)
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/interfaces/base/core.py", line 397, in run
    runtime = self._run_interface(runtime)
  File "/usr/local/miniconda/lib/python3.7/site-packages/niworkflows/interfaces/bids.py", line 535, in _run_interface
    raise ValueError(f"Could not build path with entities {out_entities}.")
ValueError: Could not build path with entities {'subject': '01', 'task': 'mixedgamblestask', 'run': 2, 'suffix': 'xfm', 'datatype': 'func', 'extension': 'tfm', 'from': 'native', 'to': 'T1w', 'mode': 'image'}.

I think this is caused on the niworkflows side of things, specifically this.

@tsalo
Copy link
Collaborator Author

tsalo commented Aug 5, 2020

I'll see if limiting to runs with T1w-space outputs resolves the issue by not dealing with tfm xforms at all. If it doesn't, then I'll have to query the devs about tfm xforms and whether they should be supported or not.

@tsalo tsalo marked this pull request as ready for review August 5, 2020 21:11
@tsalo tsalo requested review from oesteban and effigies August 6, 2020 19:26
@effigies
Copy link
Member

effigies commented Aug 7, 2020

  • Should tfm transforms be supported in DerivativesDatasink?

What does tfm mean in this context?

  • Do we want the native-to-T1w transform even when T1w isn't one of the desired spaces?

Yes, I think it's a good idea. Transforms are cheap. I would err on the side of saving too many transforms and too few resampled BOLD series.


I don't think native has any meaning in BIDS. What about scanner?

https://bids-specification.readthedocs.io/en/stable/99-appendices/08-coordinate-systems.html


Otherwise looks good.

@tsalo
Copy link
Collaborator Author

tsalo commented Aug 7, 2020

What does tfm mean in this context?

I don't know why tfm is popping up, but an error that was occurring with ds005 involved tfm as the extension. That extension isn't supported within the niworkflows nipreps.json.

Yes, I think it's a good idea. Transforms are cheap. I would err on the side of saving too many transforms and too few resampled BOLD series.

Okay, this will involve a corresponding PR to niworkflows, so it'll be a couple of days, I think.

I don't think native has any meaning in BIDS. What about scanner?

The transform relates to the BOLD reference image, so it's not truly "native" or scanner space. Would reference work?

@oesteban
Copy link
Member

oesteban commented Aug 7, 2020

I don't know why tfm is popping up, but an error that was occurring with ds005 involved tfm as the extension. That extension isn't supported within the niworkflows nipreps.json

What is the error, exactly? - the .tfm extension should be replaceable by .txt.

The transform relates to the BOLD reference image, so it's not truly "native" or scanner space. Would reference work?

For NIfTI scanner means whatever coordinates the scanner registered. So assuming that the BOLD reference has the same affine information as the BOLD run it refers, then it is correct to say it has scanner space.

@tsalo
Copy link
Collaborator Author

tsalo commented Aug 7, 2020

What is the error, exactly? - the .tfm extension should be replaceable by .txt.

You can see the error in this comment: #2233 (comment)
If tfm can be replaced with txt, I can handle that in the workflow I think.

For NIfTI scanner means whatever coordinates the scanner registered. So assuming that the BOLD reference has the same affine information as the BOLD run it refers, then it is correct to say it has scanner space.

Okay, I can use scanner instead then.

@oesteban
Copy link
Member

oesteban commented Aug 7, 2020

If tfm can be replaced with txt

Yes, that should work out

Also output transforms no matter what and replace tfm with txt extension.
@tsalo tsalo changed the title ENH: Save native-to-T1w xform to outputs ENH: Save scanner-to-T1w xform to outputs Aug 7, 2020
@@ -14,6 +14,8 @@ fmriprep/sub-100185/func/sub-100185_task-machinegame_run-1_desc-confounds_regres
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-1_desc-confounds_regressors.tsv
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-1_desc-preproc_bold.json
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-1_desc-preproc_bold.nii.gz
fmriprep/sub-100185/func/sub-100185_task-machinegame_run-1_from-native_to-T1w_mode-image_xfm.txt
Copy link
Member

Choose a reason for hiding this comment

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

One possibility here, which I think is very unclear from the BIDS-Derivs draft of transforms, is whether the "default" value can be omitted (similarly to why we omit space- when writing the bold file):

fmriprep/sub-100185/func/sub-100185_task-machinegame_run-1_to-T1w_mode-image_xfm.txt

WDYT @effigies ?

Copy link
Member

Choose a reason for hiding this comment

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

that also covers the inverse:

fmriprep/sub-100185/func/sub-100185_task-machinegame_run-1_from-T1w_mode-image_xfm.txt

Copy link
Member

Choose a reason for hiding this comment

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

I think I'd rather be explicit. I see the sense in not adding an unnecessary space-scanner to a file that hasn't been moved into another space, but a transformation no longer has its own implicit space.

@effigies
Copy link
Member

effigies commented Aug 7, 2020

Now that I'm looking at that page again, should the T1w space be individual? That would obviously be a bigger change than this PR.

@oesteban
Copy link
Member

oesteban commented Aug 7, 2020 via email

@effigies
Copy link
Member

effigies commented Aug 7, 2020

Which is the T1w, right? At least when fmriprep constructs the reference.

@oesteban
Copy link
Member

oesteban commented Aug 7, 2020 via email

@tsalo
Copy link
Collaborator Author

tsalo commented Aug 7, 2020

@oesteban, I think @effigies was proposing to change T1w to individual, so it would be from-scanner_to-individual.

@effigies
Copy link
Member

effigies commented Aug 7, 2020

Yes. Thanks for clarifying, @tsalo. To be clear, the proposal is to change the T1w space to individual throughout the derivatives. It is beyond this PR, but I thought I should bring it up, while we're taking about it.

@tsalo
Copy link
Collaborator Author

tsalo commented Aug 8, 2020

I opened #2234 for the space terminology question, since it's not something I'd be able to do within this PR.

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.

Thanks much for this.

@oesteban oesteban merged commit c717c6b into nipreps:master Aug 9, 2020
HippocampusGirl added a commit to HippocampusGirl/fmriprep that referenced this pull request Sep 16, 2020
20.2.0 RC0 (September 04, 2020)

With this third minor release series of 2020,
the first *fMRIPrep LTS* (*long-term support*) is finally here!

This release contains a number of bug-fixes and enhancements mostly
related to easing the maintenance, anticipating patch-release breaking
changes to ensure a longstanding LTS, and addressing some run-to-run
repeatability problems of the CompCor implementation.

Thank you for using *fMRIPrep*!
If you encounter any issues with this release, please let us know
by posting an issue on our GitHub page!

A full list of changes can be found below.

* FIX: Revise the reproducibility of CompCor masks (nipreps#2130)
* FIX: Simplify transform aggregation in resampling, pass identity transforms for multi-echo cases (nipreps#2239)
* FIX: Skip the T1w check if ``--anat-derivatives`` is provided. (nipreps#2201)
* FIX: Storing ``--bids-filters`` within config file (nipreps#2177)
* FIX: Revise multi-echo reference generation, permitting using SBRefs too (nipreps#1803)
* FIX: FreeSurfer license manipulation & canary
* ENH: Output CompCor masks if ``--debug compcor`` is passed (nipreps#2248)
* ENH: Conform to BIDS Derivatives as of BIDS 1.4.0 (nipreps#2223)
* ENH: Reuse config (nipreps#2240)
* ENH: Save BOLD-anatomical transforms to derivatives folder (nipreps#2233)
* ENH: Leverage BIDSLayout's ``database_path`` (nipreps#2203)
* ENH: Add ``--no-tty`` option to ``fmriprep-docker.py`` (nipreps#2204)
* ENH: Report number of echoes in BOLD summary. (nipreps#2184)
* ENH: Ensure NiPype telemetry is just pinged once (nipreps#2168)
* DOC: Update reference in "Refinement of Brain Mask" description (nipreps#2215)
* DOC: List *TemplateFlow* templates that need to be prefetched (nipreps#2196)
* DOC: Update references to https://github.com/nipreps (nipreps#2191)
* DOC: Pin NiPype with new Sphinx extension syntax (nipreps#2092)
* MAINT: Track nipreps#2252 from 20.1.x series (nipreps#2253)
* MAINT: Silence PyBIDS warning by setting extension mode (nipreps#2250)
* MAINT: Drop CircleCI docs build (nipreps#2247)
* MAINT: Pin latest *NiPreps* (nipreps#2244)
* MAINT: Update ``setup.cfg`` (flake8 and pytest) (nipreps#2183)
* MAINT: Delete release-drafter (nipreps#2169)
* MAINT: Track bug-fix release on the 20.1.x series (nipreps#2165)
* MAINT: Remove auto-comment bot (nipreps#2166)
* MAINT: Improve the questions on the bug-report template (nipreps#2158)
HippocampusGirl added a commit to HippocampusGirl/fmriprep that referenced this pull request Sep 16, 2020
20.2.0rc1

With this third minor release series of 2020,
the first *fMRIPrep LTS* (*long-term support*) is finally here!

This release contains a number of bug-fixes and enhancements mostly
related to easing the maintenance, anticipating patch-release breaking
changes to ensure a longstanding LTS, and addressing some run-to-run
repeatability problems of the CompCor implementation.

.. admonition:: Long-Term Support (LTS)

    *fMRIPrep* 20.2 LTS introduces the `long-term support program
    <https://www.nipreps.org/devs/releases/#long-term-support-series>`__.
    This LTS version will be kindly steered and maintained by
    the group of Dr. Basile Pinsard and Prof. Pierre Bellec at
    `CRIUGM <http://www.criugm.qc.ca/>`__, (Université de Montréal).
    The LTS is planned for a window of 4 years of support (i.e., until
    September 2024).

.. caution::

    As with all minor version increments, working directories
    from previous versions **should not be reused**.

Thank you for using *fMRIPrep*!
If you encounter any issues with this release, please let us know
by posting an issue on our GitHub page!

A full list of changes can be found below.

* FIX: Get missing ``probseg`` file from MNI152NLin2009cAsym (nipreps#2271)
* FIX: Restore ``--ignore t2w/flair`` options (nipreps#2260)
* FIX: Revise the reproducibility of *CompCor* masks (nipreps#2130)
* FIX: Simplify transform aggregation in resampling, pass identity transforms for multi-echo cases (nipreps#2239)
* FIX: Skip the T1w check if ``--anat-derivatives`` is provided. (nipreps#2201)
* FIX: Storing ``--bids-filters`` within config file (nipreps#2177)
* FIX: Revise multi-echo reference generation, permitting using SBRefs too (nipreps#1803)
* FIX: *FreeSurfer* license manipulation & canary
* ENH: Output CompCor masks if ``--debug compcor`` is passed (nipreps#2248)
* ENH: Conform to BIDS Derivatives as of BIDS 1.4.0 (nipreps#2223)
* ENH: Reuse config (nipreps#2240)
* ENH: Save BOLD-anatomical transforms to derivatives folder (nipreps#2233)
* ENH: Leverage BIDSLayout's ``database_path`` (nipreps#2203)
* ENH: Add ``--no-tty`` option to ``fmriprep-docker.py`` (nipreps#2204)
* ENH: Report number of echoes in BOLD summary. (nipreps#2184)
* ENH: Ensure *NiPype* telemetry is just pinged once (nipreps#2168)
* DOC: Add FAQ entry for using pre-indexed layouts (nipreps#2256)
* DOC: Update reference in "Refinement of Brain Mask" description (nipreps#2215)
* DOC: List *TemplateFlow* templates that need to be prefetched (nipreps#2196)
* DOC: Update references to https://github.com/nipreps (nipreps#2191)
* DOC: Pin *NiPype* with new Sphinx extension syntax (nipreps#2092)
* MAINT: Track nipreps#2269 and nipreps#2269, bug-fixes on the 20.1.x series
* MAINT: Remove derivatives from layout index ignores (nipreps#2258)
* MAINT: Track nipreps#2252 from 20.1.x series (nipreps#2253)
* MAINT: Silence *PyBIDS* warning by setting extension mode (nipreps#2250)
* MAINT: Drop CircleCI docs build (nipreps#2247)
* MAINT: Pin latest *NiPreps* (nipreps#2244)
* MAINT: Update ``setup.cfg`` (flake8 and pytest) (nipreps#2183)
* MAINT: Delete release-drafter (nipreps#2169)
* MAINT: Track bug-fix release on the 20.1.x series (nipreps#2165)
* MAINT: Remove auto-comment bot (nipreps#2166)
* MAINT: Improve the questions on the bug-report template (nipreps#2158)

.. admonition:: Author list for papers based on *fMRIPrep* 20.2 LTS series

    As described in the `Contributor Guidelines
    <https://www.nipreps.org/community/CONTRIBUTING/#recognizing-contributions>`__,
    anyone listed as developer or contributor may write and submit manuscripts
    about *fMRIPrep*.
    To do so, please move the author(s) name(s) to the front of the following list:

    Markiewicz, Christopher J. \ :sup:`1`\ ; Goncalves, Mathias \ :sup:`1`\ ; DuPre, Elizabeth \ :sup:`2`\ ; Kent, James D. \ :sup:`3`\ ; Salo, Taylor \ :sup:`4`\ ; Ciric, Rastko \ :sup:`1`\ ; Pinsard, Basile \ :sup:`5`\ ; Finc, Karolina \ :sup:`6`\ ; de la Vega, Alejandro \ :sup:`7`\ ; Feingold, Franklin \ :sup:`1`\ ; Tooley, Ursula A. \ :sup:`8`\ ; Benson, Noah C. \ :sup:`9`\ ; Urchs, Sebastian \ :sup:`2`\ ; Blair, Ross W. \ :sup:`1`\ ; Erramuzpe, Asier \ :sup:`10`\ ; Lurie, Daniel J. \ :sup:`11`\ ; Heinsfeld, Anibal S. \ :sup:`12`\ ; Jacoby, Nir \ :sup:`13`\ ; Jamison, Keith W. \ :sup:`14`\ ; Frederick, Blaise B. \ :sup:`15, 16`\ ; Valabregue, Romain \ :sup:`17`\ ; Sneve, Markus H. \ :sup:`18`\ ; Liem, Franz \ :sup:`19`\ ; Adebimpe, Azeez \ :sup:`20`\ ; Velasco, Pablo \ :sup:`21`\ ; Wexler, Joseph B. \ :sup:`1`\ ; Groen, Iris I. A. \ :sup:`22`\ ; Ma, Feilong \ :sup:`23`\ ; Amlien, Inge K. \ :sup:`18`\ ; Bellec, Pierre \ :sup:`5`\ ; Cieslak, Matthew \ :sup:`20`\ ; Devenyi, Grabriel A. \ :sup:`24`\ ; Ghosh, Satrajit S. \ :sup:`25, 26`\ ; Gomez, Daniel E. P. \ :sup:`27`\ ; Halchenko, Yaroslav O. \ :sup:`23`\ ; Isik, Ayse Ilkay \ :sup:`28`\ ; Moodie, Craig A. \ :sup:`1`\ ; Naveau, Mikaël \ :sup:`29`\ ; Rivera-Dompenciel, Adriana \ :sup:`3`\ ; Satterthwaite, Theodore D. \ :sup:`20`\ ; Sitek, Kevin R. \ :sup:`30`\ ; Stojić, Hrvoje \ :sup:`31`\ ; Thompson, William H. \ :sup:`1`\ ; Wright, Jessey \ :sup:`1`\ ; Ye, Zhifang \ :sup:`32`\ ; Gorgolewski, Krzysztof J. \ :sup:`1`\ ; Poldrack, Russell A. \ :sup:`1`\ ; Esteban, Oscar \ :sup:`33`\ .

    Affiliations:

      1. Department of Psychology, Stanford University
      2. Montreal Neurological Institute, McGill University
      3. Neuroscience Program, University of Iowa
      4. Department of Psychology, Florida International University
      5. SIMEXP Lab, CRIUGM, University of Montréal, Montréal, Canada
      6. Centre for Modern Interdisciplinary Technologies, Nicolaus Copernicus University in Toruń
      7. University of Texas at Austin
      8. Department of Neuroscience, University of Pennsylvania, PA, USA
      9. Department of Psychology, New York University
      10. Computational Neuroimaging Lab, BioCruces Health Research Institute
      11. Department of Psychology, University of California, Berkeley
      12. Child Mind Institute
      13. Department of Psychology, Columbia University
      14. Department of Radiology, Weill Cornell Medicine
      15. McLean Hospital Brain Imaging Center, MA, USA
      16. Consolidated Department of Psychiatry, Harvard Medical School, MA, USA
      17. CENIR, INSERM U1127, CNRS UMR 7225, UPMC Univ Paris 06 UMR S 1127, Institut du Cerveau et de la Moelle épinière, ICM, F-75013, Paris, France
      18. Center for Lifespan Changes in Brain and Cognition, University of Oslo
      19. URPP Dynamics of Healthy Aging, University of Zurich
      20. Perelman School of Medicine, University of Pennsylvania, PA, USA
      21. Center for Brain Imaging, New York University
      22. Department of Psychology, New York University, NY, USA
      23. Dartmouth College: Hanover, NH, United States
      24. Department of Psychiatry, McGill University
      25. McGovern Institute for Brain Research, MIT, MA, USA
      26. Department of Otolaryngology, Harvard Medical School, MA, USA
      27. Donders Institute for Brain, Cognition and Behaviour, Radboud University Nijmegen
      28. Max Planck Institute for Empirical Aesthetics
      29. Cyceron, UMS 3408 (CNRS - UCBN), France
      30. Speech & Hearing Bioscience & Technology Program, Harvard University
      31. Max Planck UCL Centre for Computational Psychiatry and Ageing Research, University College London
      32. State Key Laboratory of Cognitive Neuroscience and Learning, Beijing Normal University
      33. Department of Radiology, CHUV, Université de Lausanne
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.

Provide BOLD to T1w affine transform in the output folder
4 participants