Skip to content

Commit

Permalink
Merge tag '23.2.0' into deepprep
Browse files Browse the repository at this point in the history
23.2.0 (January 10, 2024)

New feature release in the 23.2.x series.

This release wraps up a significant refactor of fMRIPrep. The main new features
can be used with the ``--level`` and ``--derivatives`` flags.

The ``--level`` flag 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 takes arguments of the form ``name=/path/to/dir``,
for example ``--derivatives anat=$SMRIPREP_DIR``.  If provided, fMRIPrep will
read the specified directories for pre-computed derivatives. If a derivative is
found, it will be used instead of computing it from scratch. If a derivative is
not found, fMRIPrep will compute it and proceed as usual.

Taken together, these features can allow a dataset provider to run a minimal
fMRIPrep 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 fMRIPrep behavior, enabling easier workarounds for
bugs or experimentation with alternatives.

Additionally, this release includes a number of bug fixes and improvements.
This release adds support for MSM-Sulc, improving the alignment of subject
surfaces to the fsLR template. This process is enabled by default, but may
be disabled with the ``--no-msm`` flag.

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, use
``--ignore fmap-jacobian``.

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: Restore --ignore sbref functionality (nipreps#3180)
* FIX: Retrieve atlas ROIs at requested density (nipreps#3179)
* FIX: Keep minctracc executable in FreeSurfer installation (nipreps#3175)
* FIX: Exclude echo entity from optimally combined derivatives (nipreps#3166)
* FIX: Disable boldref-space outputs unless requested (nipreps#3159)
* FIX: Tag memory estimates in resamplers (nipreps#3150)
* FIX: Final revisions for next branch (nipreps#3134)
* FIX: Minor fixes to work with MSMSulc-enabled smriprep-next (nipreps#3098)
* FIX: Connect EPI-to-fieldmap transform (nipreps#3099)
* FIX: Use Py2-compatible version file template for fmriprep-docker (nipreps#3101)
* FIX: Update connections to unwarp_wf, convert ITK transforms to text (nipreps#3077)
* ENH: Allow --ignore fmap-jacobian to disable Jacobian determinant modulation during fieldmap correction (nipreps#3186)
* ENH: Exclude non-steady-state volumes from confound correlation plot (nipreps#3171)
* ENH: Pass FLAIR images to anatomical workflow builder to include in boilerplate (nipreps#3146)
* ENH: Restore carpetplot and other final adjustments (nipreps#3131)
* ENH: Restore CIFTI-2 generation (nipreps#3129)
* ENH: Restore resampling to surface GIFTIs (nipreps#3126)
* ENH: Restore confound generation (nipreps#3120)
* ENH: Restore resampling BOLD to volumetric templates (nipreps#3121)
* ENH: Restore resampling to T1w target (nipreps#3116)
* ENH: Add MSMSulc (nipreps#3085)
* ENH: Add reporting workflow for BOLD fit (nipreps#3082)
* ENH: Generate anatomical derivatives useful for resampling (nipreps#3081)
* RF: Load reportlets interfaces from nireports rather than niworkflows (nipreps#3176, nipreps#3184)
* RF: Separate goodvoxels mask creation from fsLR resampling (nipreps#3170)
* RF: Write out anatomical template derivatives (nipreps#3136)
* RF: Update primary bold workflow to incorporate single shot resampling (nipreps#3114)
* RF: Update derivative cache spec, calculate per-BOLD, reuse boldref2fmap (nipreps#3078)
* RF: Split fMRIPrep into fit and derivatives workflows (nipreps#2913)
* RPT: Rename CSF/WM confounds in fMRIPlot (nipreps#3172)
* TST: Add smoke tests for full workflow and most branching flags (nipreps#3155)
* TST: Add smoke-tests for bold_fit_wf (nipreps#3152)
* DOC: Fix documentation and description for init_bold_grayords_wf (nipreps#3051)
* DOC: Minor updates in outputs.rst (nipreps#3148)
* STY: Apply a couple refurb suggestions (nipreps#3151)
* STY: Fix flake8 warnings (nipreps#3044)
* STY: Apply pyupgrade suggestions (nipreps#3043)
* MNT: Restore mritotal subcommands to Dockerfile (nipreps#3149)
* MNT: Update smriprep to 0.13.1 (nipreps#3153)
* MNT: optimise size of PNG files (nipreps#3145)
* MNT: update vendored docs script ``github_link.py`` (nipreps#3144)
* MNT: Update tedana pin, test on Python 3.12 (nipreps#3141)
* MNT: Bump environment (nipreps#3132)
* MNT: Bump version requirements (nipreps#3107)
* MNT: http:// → https:// (nipreps#3097)
* MNT: Remove mritotal and dependencies from FreeSurfer ignore file (nipreps#3090)
* MNT: Update environment (nipreps#3073)
* MNT: Depend on newer sphinx (nipreps#3067)
* MNT: Install ANTs from conda-forge (nipreps#3061)
* MNT: Drop Python 3.8 and numpy 1.21 support (NEP29) (nipreps#3052)
* MNT: update update_zenodo.py script (nipreps#3042)
* MNT: Fix welcome message formatting and instructions (nipreps#3039)
* MNT: Python 3.11 should be supported (nipreps#3038)
* CI: Bump actions/setup-python from 4 to 5 (nipreps#3181)
* CI: Stop testing legacy layout (nipreps#3079)
* CI: Improve tag detection for docker builds (nipreps#3066)
* CI: Clean up pre-release builds (nipreps#3040)
  • Loading branch information
NingAnMe committed Jan 11, 2024
2 parents 6c8340b + 8b3a957 commit a84f452
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 53 deletions.
1 change: 1 addition & 0 deletions .maint/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Before every release, unlisted contributors will be invited again to add their n
| Liem | Franz | | 0000-0003-0646-4810 | URPP Dynamics of Healthy Aging, University of Zurich |
| Lurie | Daniel J. | | 0000-0001-8012-6399 | Department of Psychology, University of California, Berkeley |
| Ma | Feilong | | 0000-0002-6838-3971 | Dartmouth College: Hanover, NH, United States |
| Madison | Thomas | | 0000-0003-3030-6580 | Department of Pediatrics, University of Minnesota, MN, USA |
| Mentch | Jeff | | 0000-0002-7762-8678 | Speech & Hearing Bioscience & Technology Program, Harvard University |
| Moodie | Craig A. | | 0000-0003-0867-1469 | Department of Psychology, Stanford University |
| Naveau | Mikaël | | 0000-0001-6948-9068 | Cyceron, UMS 3408 (CNRS - UCBN), France |
Expand Down
89 changes: 51 additions & 38 deletions .zenodo.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,24 @@
"orcid": "0000-0002-1668-9629",
"type": "Researcher"
},
{
"affiliation": "Department of Pediatrics, University of Minnesota, MN, USA",
"name": "Madison, Thomas",
"orcid": "0000-0003-3030-6580",
"type": "Researcher"
},
{
"affiliation": "Florey Institute of Neuroscience and Mental Health",
"name": "Smith, Robert E.",
"orcid": "0000-0003-3636-4642",
"type": "Researcher"
},
{
"affiliation": "Neurospin, CEA",
"name": "Papadopoulos, Dimitri",
"orcid": "0000-0002-1242-8990",
"type": "Researcher"
},
{
"affiliation": "Centre for Modern Interdisciplinary Technologies, Nicolaus Copernicus University in Toruń",
"name": "Finc, Karolina",
Expand All @@ -26,18 +38,6 @@
"orcid": "0000-0002-6533-2909",
"type": "Researcher"
},
{
"affiliation": "Neurospin, CEA",
"name": "Papadopoulos, Dimitri",
"orcid": "0000-0002-1242-8990",
"type": "Researcher"
},
{
"affiliation": "Dartmouth College: Hanover, NH, United States",
"name": "Halchenko, Yaroslav O.",
"orcid": "0000-0003-3456-2493",
"type": "Researcher"
},
{
"affiliation": "Department of Neuroscience, University of Pennsylvania, PA, USA",
"name": "Tooley, Ursula A.",
Expand All @@ -51,9 +51,9 @@
"type": "Researcher"
},
{
"affiliation": "University of Texas at Austin",
"name": "de la Vega, Alejandro",
"orcid": "0000-0001-9062-3778",
"affiliation": "Dartmouth College: Hanover, NH, United States",
"name": "Halchenko, Yaroslav O.",
"orcid": "0000-0003-3456-2493",
"type": "Researcher"
},
{
Expand All @@ -63,9 +63,9 @@
"type": "Researcher"
},
{
"affiliation": "Montreal Neurological Institute, McGill University",
"name": "Urchs, Sebastian",
"orcid": "0000-0001-5504-8579",
"affiliation": "University of Texas at Austin",
"name": "de la Vega, Alejandro",
"orcid": "0000-0001-9062-3778",
"type": "Researcher"
},
{
Expand All @@ -75,9 +75,15 @@
"type": "Researcher"
},
{
"affiliation": "Charite Universitatsmedizin Berlin, Germany",
"name": "Waller, Lea",
"orcid": "0000-0002-3239-6957",
"affiliation": "Montreal Neurological Institute, McGill University",
"name": "Urchs, Sebastian",
"orcid": "0000-0001-5504-8579",
"type": "Researcher"
},
{
"affiliation": "Machine Learning Team, National Institute of Mental Health, USA",
"name": "Nielson, Dylan M.",
"orcid": "0000-0003-4613-6643",
"type": "Researcher"
},
{
Expand All @@ -86,6 +92,12 @@
"orcid": "0000-0002-2050-0614",
"type": "Researcher"
},
{
"affiliation": "Charite Universitatsmedizin Berlin, Germany",
"name": "Waller, Lea",
"orcid": "0000-0002-3239-6957",
"type": "Researcher"
},
{
"affiliation": "Speech & Hearing Bioscience & Technology Program, Harvard University",
"name": "Mentch, Jeff",
Expand All @@ -98,12 +110,6 @@
"orcid": "0000-0001-8012-6399",
"type": "Researcher"
},
{
"affiliation": "Department of Psychology, Columbia University",
"name": "Jacoby, Nir",
"orcid": "0000-0001-7936-9991",
"type": "Researcher"
},
{
"affiliation": "Computational Neuroimaging Lab, BioCruces Health Research Institute",
"name": "Erramuzpe, Asier",
Expand Down Expand Up @@ -194,6 +200,18 @@
"orcid": "0000-0002-1652-9297",
"type": "Researcher"
},
{
"affiliation": "Department of Psychology, Columbia University",
"name": "Jacoby, Nir",
"orcid": "0000-0001-7936-9991",
"type": "Researcher"
},
{
"affiliation": "Department of Psychology, University of Washington",
"name": "Kruper, John",
"orcid": "0000-0003-0081-391X",
"type": "Researcher"
},
{
"affiliation": "URPP Dynamics of Healthy Aging, University of Zurich",
"name": "Liem, Franz",
Expand Down Expand Up @@ -301,19 +319,19 @@
"orcid": "0000-0002-1668-9629"
},
{
"affiliation": "Montreal Neurological Institute, McGill University",
"name": "DuPre, Elizabeth",
"orcid": "0000-0003-1358-196X"
"affiliation": "Department of Psychology, Florida International University",
"name": "Salo, Taylor",
"orcid": "0000-0001-9813-3167"
},
{
"affiliation": "Neuroscience Program, University of Iowa",
"name": "Kent, James D.",
"orcid": "0000-0002-4892-2659"
},
{
"affiliation": "Department of Psychology, Florida International University",
"name": "Salo, Taylor",
"orcid": "0000-0001-9813-3167"
"affiliation": "Montreal Neurological Institute, McGill University",
"name": "DuPre, Elizabeth",
"orcid": "0000-0003-1358-196X"
},
{
"affiliation": "Department of Psychology, Stanford University",
Expand All @@ -330,11 +348,6 @@
"name": "Blair, Ross W.",
"orcid": "0000-0003-3007-1056"
},
{
"affiliation": "Machine Learning Team, National Institute of Mental Health",
"name": "Nielson, Dylan M.",
"orcid": "0000-0003-4613-6643"
},
{
"affiliation": "Department of Psychology, Stanford University",
"name": "Poldrack, Russell A.",
Expand Down
6 changes: 4 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
23.2.0 (To be determined)
23.2.0 (January 10, 2024)
=========================
New feature release in the 23.2.x series.

Expand Down Expand Up @@ -33,7 +33,8 @@ 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.
and expansion effects on signal intensity. To disable Jacobian weighting, use
``--ignore fmap-jacobian``.

Finally, a new resampling method has been added, to better account for
susceptibility distortion and motion in a single shot resampling to a volumetric
Expand All @@ -50,6 +51,7 @@ target space. We anticipate extending this to surface targets in the future.
* FIX: Connect EPI-to-fieldmap transform (#3099)
* FIX: Use Py2-compatible version file template for fmriprep-docker (#3101)
* FIX: Update connections to unwarp_wf, convert ITK transforms to text (#3077)
* ENH: Allow --ignore fmap-jacobian to disable Jacobian determinant modulation during fieldmap correction (#3186)
* ENH: Exclude non-steady-state volumes from confound correlation plot (#3171)
* ENH: Pass FLAIR images to anatomical workflow builder to include in boilerplate (#3146)
* ENH: Restore carpetplot and other final adjustments (#3131)
Expand Down
2 changes: 1 addition & 1 deletion fmriprep/cli/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def _slice_time_ref(value, parser):
action="store",
nargs="+",
default=[],
choices=["fieldmaps", "slicetiming", "sbref", "t2w", "flair"],
choices=["fieldmaps", "slicetiming", "sbref", "t2w", "flair", "fmap-jacobian"],
help="Ignore selected aspects of the input dataset to disable corresponding "
"parts of the workflow (a space delimited list)",
)
Expand Down
17 changes: 14 additions & 3 deletions fmriprep/interfaces/resampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class ResampleSeriesInputSpec(TraitedSpec):
"k-",
desc="the phase-encoding direction corresponding to in_data",
)
jacobian = traits.Bool(mandatory=True, desc="Whether to apply Jacobian correction")
num_threads = traits.Int(1, usedefault=True, desc="Number of threads to use for resampling")
output_data_type = traits.Str("float32", usedefault=True, desc="Data type of output image")
order = traits.Int(3, usedefault=True, desc="Order of interpolation (0=nearest, 3=cubic)")
Expand Down Expand Up @@ -105,6 +106,7 @@ def _run_interface(self, runtime):
transforms=transforms,
fieldmap=fieldmap,
pe_info=pe_info,
jacobian=self.inputs.jacobian,
nthreads=self.inputs.num_threads,
output_dtype=self.inputs.output_data_type,
order=self.inputs.order,
Expand Down Expand Up @@ -217,6 +219,7 @@ def resample_vol(
data: np.ndarray,
coordinates: np.ndarray,
pe_info: tuple[int, float],
jacobian: bool,
hmc_xfm: np.ndarray | None,
fmap_hz: np.ndarray,
output: np.dtype | np.ndarray | None = None,
Expand Down Expand Up @@ -282,8 +285,6 @@ def resample_vol(
vsm = fmap_hz * pe_info[1]
coordinates[pe_info[0], ...] += vsm

jacobian = 1 + np.gradient(vsm, axis=pe_info[0])

result = ndi.map_coordinates(
data,
coordinates,
Expand All @@ -293,14 +294,18 @@ def resample_vol(
cval=cval,
prefilter=prefilter,
)
result *= jacobian

if jacobian:
result *= 1 + np.gradient(vsm, axis=pe_info[0])

return result


async def resample_series_async(
data: np.ndarray,
coordinates: np.ndarray,
pe_info: list[tuple[int, float]],
jacobian: bool,
hmc_xfms: list[np.ndarray] | None,
fmap_hz: np.ndarray,
output_dtype: np.dtype | None = None,
Expand Down Expand Up @@ -361,6 +366,7 @@ async def resample_series_async(
data,
coordinates,
pe_info[0],
jacobian,
hmc_xfms[0] if hmc_xfms else None,
fmap_hz,
output_dtype,
Expand All @@ -384,6 +390,7 @@ async def resample_series_async(
data=volume,
coordinates=coordinates,
pe_info=pe_info[volid],
jacobian=jacobian,
hmc_xfm=hmc_xfms[volid] if hmc_xfms else None,
fmap_hz=fmap_hz,
output=out_array[..., volid],
Expand All @@ -407,6 +414,7 @@ def resample_series(
data: np.ndarray,
coordinates: np.ndarray,
pe_info: list[tuple[int, float]],
jacobian: bool,
hmc_xfms: list[np.ndarray] | None,
fmap_hz: np.ndarray,
output_dtype: np.dtype | None = None,
Expand Down Expand Up @@ -467,6 +475,7 @@ def resample_series(
data=data,
coordinates=coordinates,
pe_info=pe_info,
jacobian=jacobian,
hmc_xfms=hmc_xfms,
fmap_hz=fmap_hz,
output_dtype=output_dtype,
Expand All @@ -485,6 +494,7 @@ def resample_image(
transforms: nt.TransformChain,
fieldmap: nb.Nifti1Image | None,
pe_info: list[tuple[int, float]] | None,
jacobian: bool = True,
nthreads: int = 1,
output_dtype: np.dtype | str | None = 'f4',
order: int = 3,
Expand Down Expand Up @@ -566,6 +576,7 @@ def resample_image(
data=source.get_fdata(dtype='f4'),
coordinates=mapped_coordinates.T.reshape((3, *target.shape[:3])),
pe_info=pe_info,
jacobian=jacobian,
hmc_xfms=hmc_xfms,
fmap_hz=fieldmap.get_fdata(dtype='f4'),
output_dtype=output_dtype,
Expand Down
3 changes: 2 additions & 1 deletion fmriprep/workflows/bold/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def init_bold_volumetric_resample_wf(
*,
metadata: dict,
mem_gb: dict[str, float],
jacobian: bool,
fieldmap_id: str | None = None,
omp_nthreads: int = 1,
name: str = 'bold_volumetric_resample_wf',
Expand Down Expand Up @@ -123,7 +124,7 @@ def init_bold_volumetric_resample_wf(
boldref2target = pe.Node(niu.Merge(2), name='boldref2target', run_without_submitting=True)
bold2target = pe.Node(niu.Merge(2), name='bold2target', run_without_submitting=True)
resample = pe.Node(
ResampleSeries(),
ResampleSeries(jacobian=jacobian),
name="resample",
n_procs=omp_nthreads,
mem_gb=mem_gb['resampled'],
Expand Down
1 change: 1 addition & 0 deletions fmriprep/workflows/bold/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ def init_bold_wf(
fieldmap_id=fieldmap_id if not multiecho else None,
omp_nthreads=omp_nthreads,
mem_gb=mem_gb,
jacobian='fmap-jacobian' not in config.workflow.ignore,
name='bold_anat_wf',
)
bold_anat_wf.inputs.inputnode.resolution = "native"
Expand Down
2 changes: 1 addition & 1 deletion fmriprep/workflows/bold/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ def init_bold_native_wf(

# Resample to boldref
boldref_bold = pe.Node(
ResampleSeries(),
ResampleSeries(jacobian="fmap-jacobian" not in config.workflow.ignore),
name="boldref_bold",
n_procs=omp_nthreads,
mem_gb=mem_gb["resampled"],
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dependencies = [
"psutil >= 5.4",
"pybids >= 0.15.2",
"requests",
"sdcflows >= 2.6.0",
"sdcflows >= 2.8.0",
"smriprep >= 0.13.2",
"tedana >= 23.0.2",
"templateflow >= 23.0.0",
Expand Down
Loading

0 comments on commit a84f452

Please sign in to comment.