How to use the niworkflows.utils.spaces.Reference.from_string function in niworkflows

To help you get started, we’ve selected a few niworkflows examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github poldracklab / niworkflows / niworkflows / utils / spaces.py View on Github external
# option was called without any output spaces, so user does not want outputs
            spaces.checkpoint()
        for val in values:
            val = val.rstrip(":")
            if (
                val not in NONSTANDARD_REFERENCES
                and not val.split(":")[0].startswith("fs")
                and ":res-" not in val
                and ":resolution-" not in val
            ):
                # by default, explicitly set volumetric resolution to native
                # relevant discussions:
                # https://github.com/nipreps/niworkflows/pull/457#discussion_r375510227
                # https://github.com/nipreps/niworkflows/pull/494
                val = ":".join((val, "res-native"))
            for sp in Reference.from_string(val):
                spaces.add(sp)
        setattr(namespace, self.dest, spaces)
github nipreps / dmriprep / dmriprep / config / __init__.py View on Github external
def init_spaces(checkpoint=True):
    """Initialize the :attr:`~workflow.spaces` setting."""
    from niworkflows.utils.spaces import Reference, SpatialReferences

    spaces = execution.output_spaces or SpatialReferences()
    if not isinstance(spaces, SpatialReferences):
        spaces = SpatialReferences(
            [ref for s in spaces.split(" ") for ref in Reference.from_string(s)]
        )

    if checkpoint and not spaces.is_cached():
        spaces.checkpoint()

    # Make the SpatialReferences object available
    workflow.spaces = spaces
github nipreps / dmriprep / dmriprep / cli / parser.py View on Github external
Non-standard spaces imply specific orientations and sampling grids. \
The default value of this flag (meaning, if the argument is not include in the command line) \
is ``--output-spaces run`` - the original space and sampling grid of the original DWI run. \
Important to note, the ``res-*`` modifier does not define the resolution used for \
the spatial normalization. To generate no DWI outputs (if that is intended for some reason), \
use this option without specifying any spatial references. For further details, please check out \
https://www.nipreps.org/dmriprep/en/%s/spaces.html"""
        % (currentv.base_version if is_release else "latest"),
    )

    #  ANTs options
    g_ants = parser.add_argument_group("Specific options for ANTs registrations")
    g_ants.add_argument(
        "--skull-strip-template",
        default="OASIS30ANTs",
        type=Reference.from_string,
        help="select a template for skull-stripping with antsBrainExtraction",
    )
    g_ants.add_argument(
        "--skull-strip-fixed-seed",
        action="store_true",
        help="do not use a random seed for skull-stripping - will ensure "
        "run-to-run replicability when used with --omp-nthreads 1",
    )

    # Fieldmap options
    g_fmap = parser.add_argument_group("Specific options for handling fieldmaps")
    g_fmap.add_argument(
        "--fmap-bspline",
        action="store_true",
        default=False,
        help="fit a B-Spline field using least-squares (experimental)",
github poldracklab / smriprep / smriprep / cli / run.py View on Github external
g_perfm.add_argument("-v", "--verbose", dest="verbose_count", action="count", default=0,
                         help="increases log verbosity for each occurence, debug level is -vvv")

    g_conf = parser.add_argument_group('Workflow configuration')
    g_conf.add_argument(
        '--output-spaces', nargs='*', action=OutputReferencesAction, default=SpatialReferences(),
        help='paths or keywords prescribing output spaces - '
             'standard spaces will be extracted for spatial normalization.')
    g_conf.add_argument(
        '--longitudinal', action='store_true',
        help='treat dataset as longitudinal - may increase runtime')

    #  ANTs options
    g_ants = parser.add_argument_group('Specific options for ANTs registrations')
    g_ants.add_argument(
        '--skull-strip-template', default='OASIS30ANTs', type=Reference.from_string,
        help='select a template for skull-stripping with antsBrainExtraction')
    g_ants.add_argument('--skull-strip-fixed-seed', action='store_true',
                        help='do not use a random seed for skull-stripping - will ensure '
                             'run-to-run replicability when used with --omp-nthreads 1')
    g_ants.add_argument(
        '--skull-strip-mode', action='store', choices=('auto', 'skip', 'force'),
        default='auto', help='determiner for T1-weighted skull stripping (force ensures skull '
                             'stripping, skip ignores skull stripping, and auto automatically '
                             'ignores skull stripping if pre-stripped brains are detected).')

    # FreeSurfer options
    g_fs = parser.add_argument_group('Specific options for FreeSurfer preprocessing')
    g_fs.add_argument(
        '--fs-license-file', metavar='PATH', type=Path,
        help='Path to FreeSurfer license key file. Get it (for free) by registering'
             ' at https://surfer.nmr.mgh.harvard.edu/registration.html')