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

RF: Move to fit/apply workflow #360

Merged
merged 142 commits into from
Aug 1, 2024
Merged

RF: Move to fit/apply workflow #360

merged 142 commits into from
Aug 1, 2024

Conversation

mgxd
Copy link
Collaborator

@mgxd mgxd commented Apr 29, 2024

The goal of this PR is mirror workflow changes in fMRIPrep, splitting the processing into "fit" and "apply" modes.

This is still a work-in-progress.

New features:

  • --level {minimal, resampling, full} to specify levels of outputs:

    • minimal produces anatomical template, mask, anatomical -> template registrations, surface reconstruction. These can then be further processed and/or manually edited and reused as --derivatives inputs.
    • full produces all outputs, like previous versions of nibabies
  • Increased control in the use of previously computed derivatives

    • Derivatives no longer need to be in native T1w/T2w space, as long as a T1w/T2w preprocessed template is include.
  • Selective anatomical reference preference with --reference-anatomical flag

    • Previously, T1w was preferred as the output space.
    • If no option is specified, will select based on
        1. surface reconstruction method
        1. participant age

Example MCRIBS derivatives input and command

Generating surfaces with MCRIBS still requires precomputed segmentations - this is an example directory layout that can be used:

data/derivatives/anat
├── dataset_description.json
└── sub-01
    └── ses-1mo
        └── anat
            ├── sub-01_ses-1mo_desc-preproc_T1w.nii.gz
            ├── sub-01_ses-1mo_desc-preproc_T2w.nii.gz
            ├── sub-01_ses-1mo_space-T2w_desc-aseg_dseg.nii.gz
            └── sub-01_ses-1mo_space-T2w_desc-brain_mask.nii.gz
  • Note that sub-01_ses-1mo_desc-preproc_T2w.nii.gz is a denoised and INU corrected image, and is used as space-T2w. The aseg and mask are in that image space.
nibabies /data /data/derivatives/nibabies participant \
-w /work --participant-label 01 \
--fs-subjects-dir /opt/freesurfer/subjects \
--derivatives anat=/data/derivatives/anat \
--anat-only --surface-recon-method mcribs --cifti-output -s 1mo

Closes #87, #218, #288, #294, #307

mgxd added 30 commits March 28, 2024 15:53
@mgxd
Copy link
Collaborator Author

mgxd commented Aug 1, 2024

Merging this in now as it's been delayed long enough - updates to the circle smoke test + documentation will be done in separate PRs

@mgxd mgxd marked this pull request as ready for review August 1, 2024 03:35
@mgxd mgxd merged commit 5a138f5 into nipreps:master Aug 1, 2024
8 of 9 checks passed
@mgxd mgxd deleted the rf/fit-apply branch August 1, 2024 12:11
mgxd added a commit that referenced this pull request Aug 30, 2024
24.0.0 (August 29, 2024)

This major release includes a substantial refactoring of the pipeline.

One key addition is the addition of the `--level` flag, which can take the arguments minimal, resampling or full. The default is full, which should produce nearly the same results as previous versions. minimal will produce only the minimum necessary to deterministically generate the remaining derivatives. resampling will produce some additional derivatives, intended to simplify resampling with other tools.

The `--derivatives` flag was altered to take arguments in the form `name=/path/to/dir`.
For each directory provided, if a derivative is found - it will be used instead of computing it from scratch. If a derivative is not found, NiBabies will compute it and proceed as usual.

Taken together, these features can allow a dataset provider to run a minimal NiBabies run, targeting many output spaces, while a user can then run a `--derivatives` run to generate additional derivatives in only the output spaces they need. Another use case is to provide an precomputed derivative to override the default NiBabies behavior, enabling easier workarounds for bugs or experimentation with alternatives.

Another new feature is a dynamic anatomical reference, which is set based on surface reconstruction method or through the `--reference-anatomical` flag. Previously, T1w was the default output space. Now, the reference anatomical is determined based on the surface reconstruction method.

Additionally, minor adjustments have been made to MCRIBS surface reconstruction to address failure rates. This is still an on-going investigation, but preliminary results look promising.

This release resolves a number of issues with fieldmaps inducing distortions during correction. Phase difference and direct fieldmaps are now masked correctly, preventing the overestimation of distortions outside the brain. Additionally, we now implement Jacobian weighting during unwarping, which corrects for compression and expansion effects on signal intensity. To disable Jacobian weighting, add `fmap-jacobian` to the `--ignore` argument.

Finally, a new resampling method has been added, to better account for susceptibility distortion and motion in a single shot resampling to a volumetric target space. We anticipate extending this to surface targets in the future.

  * FIX: nest pathlib import in fix_multi_source_name (#365)
  * FIX: Avoid retrieving multiple templates from latest TF (#353)
  * FIX: Raise informative error if no t1w or t2w found (#347)
  * FIX: Easier pyenv usage (#342)
  * FIX: Catch nonexistent derivatives, clean up subworkflow logic (#336)
  * FIX: Use fsLR reg sphere for MCRIBS morphometrics resampling (#334)
  * FIX: T2star map MNI scaling (#320)

  * ENH: Alter outputs when MCRIBS reconstruction is used (#329)
  * ENH: Use nireports for Report generation + add reportlet per reconstruction (#328)
  * ENH: better repr for Derivatives class (#351)

  * RF: Move to fit/apply workflow (#360)
  * RF: Replace `resource_filename` with `load_data` (#345)

  * MAINT: Bump urllib3 from 2.0.3 to 2.0.7 (#319)
  * MAINT: Raise minimum to 3.10, bump actions (#337)
  * MAINT: Bump pillow from 9.5.0 to 10.0.1 (#317)
  * MAINT: Update to latest migas API (#326)

  * DOC: Use correct argument flag (#338)
  * DOC: Move to new theme, add outputs description (#383)
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.

Add T2w anatomical images to the report
1 participant