Skip to content

Commit 2de656b

Browse files
committed
DOC: Move that new nifti images section to the bottom
1 parent 581a143 commit 2de656b

File tree

1 file changed

+35
-33
lines changed

1 file changed

+35
-33
lines changed

doc/source/nifti_images.rst

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,41 @@ the sform: ``get_qform()``, ``set_qform()``.
281281
The qform also has a corresponding ``qform_code`` with the same interpretation
282282
as the `sform_code`.
283283

284+
The fall-back header affine
285+
===========================
286+
287+
This is the affine of last resort, constructed only from the ``pixdim`` voxel
288+
sizes. The `NIfTI specification <nifti1>`_ says that this should set the
289+
first voxel in the image as [0, 0, 0] in world coordinates, but we nibabblers
290+
follow SPM_ in preferring to set the central voxel to have [0, 0, 0] world
291+
coordinate. The NIfTI spec also implies that the image should be assumed to be
292+
in RAS+ *voxel* orientation for this affine (see :doc:`coordinate_systems`).
293+
Again like SPM, we prefer to assume LAS+ voxel orientation by default.
294+
295+
You can always get the fall-back affine with ``get_base_affine()``:
296+
297+
>>> n1_header.get_base_affine()
298+
array([[ -2. , 0. , 0. , 127. ],
299+
[ 0. , 2. , 0. , -95. ],
300+
[ 0. , 0. , 2.2, -25.3],
301+
[ 0. , 0. , 0. , 1. ]])
302+
303+
.. _choosing-image-affine:
304+
305+
Choosing the image affine
306+
=========================
307+
308+
Given there are three possible affines defined in the NIfTI header, nibabel
309+
has to chose which of these to use for the image ``affine``.
310+
311+
The algorithm is defined in the ``get_best_affine()`` method. It is:
312+
313+
#. If ``sform_code`` != 0 ('unknown') use the sform affine; else
314+
#. If ``qform_code`` != 0 ('unknown') use the qform affine; else
315+
#. Use the fall-back affine.
316+
317+
.. _default-sform-qform-codes:
318+
284319
Default sform and qform codes
285320
=============================
286321

@@ -336,39 +371,6 @@ If you wish to set the sform and qform affines and/or codes to some other
336371
value, you can always set them after creation using the ``set_sform`` and
337372
``set_qform`` methods, as described above.
338373

339-
The fall-back header affine
340-
===========================
341-
342-
This is the affine of last resort, constructed only from the ``pixdim`` voxel
343-
sizes. The `NIfTI specification <nifti1>`_ says that this should set the
344-
first voxel in the image as [0, 0, 0] in world coordinates, but we nibabblers
345-
follow SPM_ in preferring to set the central voxel to have [0, 0, 0] world
346-
coordinate. The NIfTI spec also implies that the image should be assumed to be
347-
in RAS+ *voxel* orientation for this affine (see :doc:`coordinate_systems`).
348-
Again like SPM, we prefer to assume LAS+ voxel orientation by default.
349-
350-
You can always get the fall-back affine with ``get_base_affine()``:
351-
352-
>>> n1_header.get_base_affine()
353-
array([[ -2. , 0. , 0. , 127. ],
354-
[ 0. , 2. , 0. , -95. ],
355-
[ 0. , 0. , 2.2, -25.3],
356-
[ 0. , 0. , 0. , 1. ]])
357-
358-
.. _choosing-image-affine:
359-
360-
Choosing the image affine
361-
=========================
362-
363-
Given there are three possible affines defined in the NIfTI header, nibabel
364-
has to chose which of these to use for the image ``affine``.
365-
366-
The algorithm is defined in the ``get_best_affine()`` method. It is:
367-
368-
#. If ``sform_code`` != 0 ('unknown') use the sform affine; else
369-
#. If ``qform_code`` != 0 ('unknown') use the qform affine; else
370-
#. Use the fall-back affine.
371-
372374
************
373375
Data scaling
374376
************

0 commit comments

Comments
 (0)