Commit 42441af2 authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

RF: Add support for NIFTI_TEMPLATE_XFORM_OTHER code.

parent 5851e4c0
......@@ -30,6 +30,7 @@ specification:
NIFTI_XFORM_ALIGNED_ANAT
NIFTI_XFORM_TALAIRACH
NIFTI_XFORM_MNI_152
NIFTI_XFORM_TEMPLATE_OTHER
"""
......@@ -81,7 +82,14 @@ NIFTI_XFORM_MNI_152 = 4
"""MNI 152 normalized coordinates."""
NIFTI_XFORM_ANALYZE = 5
NIFTI_XFORM_TEMPLATE_OTHER = 5
"""Coordinates aligned to some template that is not MNI152 or Talairach.
See https://www.nitrc.org/forum/message.php?msg_id=26394 for details.
"""
NIFTI_XFORM_ANALYZE = 6
"""Code which indicates that this is an ANALYZE image, not a NIFTI image. """
......
......@@ -825,6 +825,7 @@ class Nifti(notifier.Notifier, meta.Meta):
- :data:`~.constants.NIFTI_XFORM_ALIGNED_ANAT`
- :data:`~.constants.NIFTI_XFORM_TALAIRACH`
- :data:`~.constants.NIFTI_XFORM_MNI_152`
- :data:`~.constants.NIFTI_XFORM_TEMPLATE_OTHER`
- :data:`~.constants.NIFTI_XFORM_ANALYZE`
"""
......@@ -852,8 +853,9 @@ class Nifti(notifier.Notifier, meta.Meta):
if sform_code != constants.NIFTI_XFORM_UNKNOWN: code = sform_code
elif qform_code != constants.NIFTI_XFORM_UNKNOWN: code = qform_code
# Invalid values
if code not in range(5):
# Invalid code (the maxmimum NIFTI_XFORM_*
# code value is 5 at present)
if code not in range(6):
code = constants.NIFTI_XFORM_UNKNOWN
return int(code)
......
......@@ -259,8 +259,9 @@ def applyArgStyle(style=None,
conventions, e.g. ``-a val``, ``--arg=val``, ``-a val1 val2``,
``--arg=val1,val2``.
The ``style`` and ``valsep`` (and ``charstyle`` and ``charsep``) arguments
control how key-value pairs are converted into command-line options:
The ``style`` and ``valsep`` options (and ``charstyle`` and ``charsep``,
for single-character/short arguments) control how key-value pairs are
converted into command-line options:
========= ========== ===========================
......@@ -323,11 +324,15 @@ def applyArgStyle(style=None,
one of ``' '``, ``','`` or ``'"'``. Defaults to ``' '``
if ``'=' not in style``, ``','`` otherwise.
:arg singlechar_args: If ``True``, equivalent to ``charstyle='-'``.
:arg singlechar_args: If ``True``, equivalent to ``charstyle='-'``. This
argument remains for compatibility, but may be
removed in a future version.
:arg kwargs: Arguments to be converted into command-line options.
:returns: A list containing the generated command-line options.
:returns: A sequence containing the generated command-line options, the
same as what ``shlex.split`` would generate for a properly
quoted string.
"""
if style is None:
......@@ -373,13 +378,7 @@ def applyArgStyle(style=None,
if style in ('--', '--='): return f'--{arg}'
else: return f'-{arg}'
# Formt the argument value. Always returns
# a sequence. We don't add quotes around
# values - instead we just ensure that
# arguments+values are grouped correctly in
# the final result (the same as what
# shlex.split would generate for a properly
# quoted string).
# Formt the argument value.
def fmtval(val, sep):
if isinstance(val, abc.Sequence) and (not isinstance(val, str)):
val = [str(v) for v in val]
......@@ -389,7 +388,7 @@ def applyArgStyle(style=None,
else:
return [str(val)]
# Format the argument and value together.
# Combine the argument and value together.
# val is assumed to be a sequence.
def fmtargval(arg, val, style):
# if '=' in style, val will
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment