Skip to content

Commit 1d32d9d

Browse files
committed
DOC: Fix doctest
1 parent 111e14c commit 1d32d9d

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

nibabies/workflows/bold/outputs.py

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,44 +10,59 @@
1010

1111

1212
def prepare_timing_parameters(metadata):
13-
"""Convert initial timing metadata to post-realignment timing metadata
13+
"""
14+
Convert initial timing metadata to post-realignment timing metadata
15+
1416
In particular, SliceTiming metadata is invalid once STC or any realignment is applied,
1517
as a matrix of voxels no longer corresponds to an acquisition slice.
1618
Therefore, if SliceTiming is present in the metadata dictionary, and a sparse
1719
acquisition paradigm is detected, DelayTime or AcquisitionDuration must be derived to
1820
preserve the timing interpretation.
21+
1922
Examples
2023
--------
24+
2125
.. testsetup::
26+
2227
>>> from unittest import mock
28+
2329
If SliceTiming metadata is absent, then the only change is to note that
2430
STC has not been applied:
31+
2532
>>> prepare_timing_parameters(dict(RepetitionTime=2))
2633
{'RepetitionTime': 2, 'SliceTimingCorrected': False}
2734
>>> prepare_timing_parameters(dict(RepetitionTime=2, DelayTime=0.5))
2835
{'RepetitionTime': 2, 'DelayTime': 0.5, 'SliceTimingCorrected': False}
2936
>>> prepare_timing_parameters(dict(VolumeTiming=[0.0, 1.0, 2.0, 5.0, 6.0, 7.0],
30-
... AcquisitionDuration=1.0))
37+
... AcquisitionDuration=1.0)) # doctest: +NORMALIZE_WHITESPACE
3138
{'VolumeTiming': [0.0, 1.0, 2.0, 5.0, 6.0, 7.0], 'AcquisitionDuration': 1.0,
3239
'SliceTimingCorrected': False}
40+
3341
When SliceTiming is available and used, then ``SliceTimingCorrected`` is ``True``
3442
and the ``StartTime`` indicates a series offset.
35-
>>> with mock.patch("fmriprep.config.workflow.ignore", []):
36-
... prepare_timing_parameters(dict(RepetitionTime=2, SliceTiming=[0.0, 0.2, 0.4, 0.6]))
43+
44+
>>> with mock.patch("nibabies.config.workflow.ignore", []):
45+
... prepare_timing_parameters(dict(
46+
... RepetitionTime=2,
47+
... SliceTiming=[0.0, 0.2, 0.4, 0.6])) # doctest: +NORMALIZE_WHITESPACE
3748
{'RepetitionTime': 2, 'SliceTimingCorrected': True, 'DelayTime': 1.2, 'StartTime': 0.3}
38-
>>> with mock.patch("fmriprep.config.workflow.ignore", []):
39-
... prepare_timing_parameters(dict(VolumeTiming=[0.0, 1.0, 2.0, 5.0, 6.0, 7.0],
40-
... SliceTiming=[0.0, 0.2, 0.4, 0.6, 0.8]))
49+
>>> with mock.patch("nibabies.config.workflow.ignore", []):
50+
... prepare_timing_parameters(dict(
51+
... VolumeTiming=[0.0, 1.0, 2.0, 5.0, 6.0, 7.0],
52+
... SliceTiming=[0.0, 0.2, 0.4, 0.6, 0.8])) # doctest: +NORMALIZE_WHITESPACE
4153
{'VolumeTiming': [0.0, 1.0, 2.0, 5.0, 6.0, 7.0], 'SliceTimingCorrected': True,
4254
'AcquisitionDuration': 1.0, 'StartTime': 0.4}
55+
4356
When SliceTiming is available and not used, then ``SliceTimingCorrected`` is ``False``
4457
and TA is indicated with ``DelayTime`` or ``AcquisitionDuration``.
45-
>>> with mock.patch("fmriprep.config.workflow.ignore", ["slicetiming"]):
58+
59+
>>> with mock.patch("nibabies.config.workflow.ignore", ["slicetiming"]):
4660
... prepare_timing_parameters(dict(RepetitionTime=2, SliceTiming=[0.0, 0.2, 0.4, 0.6]))
4761
{'RepetitionTime': 2, 'SliceTimingCorrected': False, 'DelayTime': 1.2}
48-
>>> with mock.patch("fmriprep.config.workflow.ignore", ["slicetiming"]):
49-
... prepare_timing_parameters(dict(VolumeTiming=[0.0, 1.0, 2.0, 5.0, 6.0, 7.0],
50-
... SliceTiming=[0.0, 0.2, 0.4, 0.6, 0.8]))
62+
>>> with mock.patch("nibabies.config.workflow.ignore", ["slicetiming"]):
63+
... prepare_timing_parameters(dict(
64+
... VolumeTiming=[0.0, 1.0, 2.0, 5.0, 6.0, 7.0],
65+
... SliceTiming=[0.0, 0.2, 0.4, 0.6, 0.8])) # doctest: +NORMALIZE_WHITESPACE
5166
{'VolumeTiming': [0.0, 1.0, 2.0, 5.0, 6.0, 7.0], 'SliceTimingCorrected': False,
5267
'AcquisitionDuration': 1.0}
5368
"""

0 commit comments

Comments
 (0)