|
10 | 10 |
|
11 | 11 |
|
12 | 12 | 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 | +
|
14 | 16 | In particular, SliceTiming metadata is invalid once STC or any realignment is applied,
|
15 | 17 | as a matrix of voxels no longer corresponds to an acquisition slice.
|
16 | 18 | Therefore, if SliceTiming is present in the metadata dictionary, and a sparse
|
17 | 19 | acquisition paradigm is detected, DelayTime or AcquisitionDuration must be derived to
|
18 | 20 | preserve the timing interpretation.
|
| 21 | +
|
19 | 22 | Examples
|
20 | 23 | --------
|
| 24 | +
|
21 | 25 | .. testsetup::
|
| 26 | +
|
22 | 27 | >>> from unittest import mock
|
| 28 | +
|
23 | 29 | If SliceTiming metadata is absent, then the only change is to note that
|
24 | 30 | STC has not been applied:
|
| 31 | +
|
25 | 32 | >>> prepare_timing_parameters(dict(RepetitionTime=2))
|
26 | 33 | {'RepetitionTime': 2, 'SliceTimingCorrected': False}
|
27 | 34 | >>> prepare_timing_parameters(dict(RepetitionTime=2, DelayTime=0.5))
|
28 | 35 | {'RepetitionTime': 2, 'DelayTime': 0.5, 'SliceTimingCorrected': False}
|
29 | 36 | >>> 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 |
31 | 38 | {'VolumeTiming': [0.0, 1.0, 2.0, 5.0, 6.0, 7.0], 'AcquisitionDuration': 1.0,
|
32 | 39 | 'SliceTimingCorrected': False}
|
| 40 | +
|
33 | 41 | When SliceTiming is available and used, then ``SliceTimingCorrected`` is ``True``
|
34 | 42 | 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 |
37 | 48 | {'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 |
41 | 53 | {'VolumeTiming': [0.0, 1.0, 2.0, 5.0, 6.0, 7.0], 'SliceTimingCorrected': True,
|
42 | 54 | 'AcquisitionDuration': 1.0, 'StartTime': 0.4}
|
| 55 | +
|
43 | 56 | When SliceTiming is available and not used, then ``SliceTimingCorrected`` is ``False``
|
44 | 57 | 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"]): |
46 | 60 | ... prepare_timing_parameters(dict(RepetitionTime=2, SliceTiming=[0.0, 0.2, 0.4, 0.6]))
|
47 | 61 | {'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 |
51 | 66 | {'VolumeTiming': [0.0, 1.0, 2.0, 5.0, 6.0, 7.0], 'SliceTimingCorrected': False,
|
52 | 67 | 'AcquisitionDuration': 1.0}
|
53 | 68 | """
|
|
0 commit comments