当前位置: 首页>>代码示例>>Python>>正文


Python CommandLine.terminal_output方法代码示例

本文整理汇总了Python中nipype.interfaces.base.CommandLine.terminal_output方法的典型用法代码示例。如果您正苦于以下问题:Python CommandLine.terminal_output方法的具体用法?Python CommandLine.terminal_output怎么用?Python CommandLine.terminal_output使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nipype.interfaces.base.CommandLine的用法示例。


在下文中一共展示了CommandLine.terminal_output方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: area

# 需要导入模块: from nipype.interfaces.base import CommandLine [as 别名]
# 或者: from nipype.interfaces.base.CommandLine import terminal_output [as 别名]
def area(command, surface_file, verbose=False):
    """
    Measure area of each vertex in a surface mesh.
    (Calls Joachim Giard's C++ code)

    Parameters
    ----------
    command : string
        Voronoi-based surface area C++ executable command
    surface_file : string
        vtk file with surface mesh
    verbose : bool
        print statements?

    Returns
    -------
    area_file: string
        vtk file with surface area per vertex of mesh

    Examples
    --------
    >>> import os
    >>> import numpy as np
    >>> from mindboggle.shapes.surface_shapes import area
    >>> from mindboggle.mio.vtks import read_scalars
    >>> from mindboggle.mio.fetch_data import prep_tests
    >>> urls, fetch_data = prep_tests()
    >>> surface_file = fetch_data(urls['left_pial'], '', '.vtk')
    >>> verbose = False
    >>> ccode_path = os.environ['vtk_cpp_tools']
    >>> command = os.path.join(ccode_path, 'area', 'PointAreaMain')
    >>> area_file = area(command, surface_file, verbose)
    >>> scalars, name = read_scalars(area_file)
    >>> np.allclose(scalars[0:8],
    ...             [0.48270401731, 0.39661528543, 0.57813454792, 0.70574099571,
    ...              0.84318527207, 0.57642554119, 0.66942016035, 0.70629953593])
    True

    """
    import os
    from nipype.interfaces.base import CommandLine

    basename = os.path.splitext(os.path.basename(surface_file))[0]
    area_file = os.path.join(os.getcwd(), basename + '.area.vtk')
    args = ' '.join([surface_file, area_file])

    if verbose:
        print("{0} {1}".format(command, args))

    cli = CommandLine(command=command)
    cli.inputs.args = args
    cli.terminal_output = 'file'
    cli.run()

    if not os.path.exists(area_file):
        raise IOError(area_file + " not found")

    return area_file
开发者ID:binarybottle,项目名称:mindboggle,代码行数:60,代码来源:surface_shapes.py

示例2: travel_depth

# 需要导入模块: from nipype.interfaces.base import CommandLine [as 别名]
# 或者: from nipype.interfaces.base.CommandLine import terminal_output [as 别名]
def travel_depth(command, surface_file, verbose=False):
    """
    Measure "travel depth" of each vertex in a surface mesh.
    (Calls Joachim Giard's C++ code)

    Parameters
    ----------
    command : string
        travel depth C++ executable command
    surface_file : string
        vtk file
    verbose : bool
        print statements?

    Returns
    -------
    depth_file: string
        vtk file with travel depth per vertex of mesh

    Examples
    --------
    >>> import os
    >>> import numpy as np
    >>> from mindboggle.shapes.surface_shapes import travel_depth
    >>> from mindboggle.mio.vtks import read_scalars
    >>> from mindboggle.mio.fetch_data import prep_tests
    >>> urls, fetch_data = prep_tests()
    >>> surface_file = fetch_data(urls['left_pial'], '', '.vtk')
    >>> verbose = False
    >>> ccode_path = os.environ['vtk_cpp_tools']
    >>> command = os.path.join(ccode_path, 'travel_depth', 'TravelDepthMain')
    >>> depth_file = travel_depth(command, surface_file, verbose)
    >>> scalars, name = read_scalars(depth_file)
    >>> np.allclose(scalars[0:8], [0.020259869839, 0.06009166489, 0.12858575442, 0.045639221313, 0.007742772964, 0.052839111255, 0.053538904296, 0.013158746337])
    True

    """
    import os
    from nipype.interfaces.base import CommandLine

    basename = os.path.splitext(os.path.basename(surface_file))[0]
    depth_file = os.path.join(os.getcwd(), basename + '.travel_depth.vtk')
    args = ' '.join([surface_file, depth_file])

    if verbose:
        print("{0} {1}".format(command, args))

    cli = CommandLine(command=command)
    cli.inputs.args = args
    cli.terminal_output = 'file'
    cli.run()

    if not os.path.exists(depth_file):
        raise IOError(depth_file + " not found")

    return depth_file
开发者ID:binarybottle,项目名称:mindboggle,代码行数:58,代码来源:surface_shapes.py

示例3: curvature

# 需要导入模块: from nipype.interfaces.base import CommandLine [as 别名]
# 或者: from nipype.interfaces.base.CommandLine import terminal_output [as 别名]

#.........这里部分代码省略.........
    CurvatureMain -m 0 -n 2
    -i lh.min_curv.vtk -x lh.max_curv.vtk -g lh.gaussian_curv.vtk
    -d lh.min_dir.vtk lh.pial.vtk  lh.mean_curv.vtk

    Notes:
    -m 0 is best if you have low resolution or want local peaks,
    but can be too sensitive to the local linear geometry of the mesh,
    unless the neighborhood parameter is set high enough (like 2).

    -m 1 is not well tested and the filtering is done using Euclidean
    distances, so it's only good for incorrect but fast visualization.

    -m 2 is a good approximation based on the Laplacian, but very large
    curvatures (negative or positive) are underestimated (saturation).

    Parameters
    ----------
    command : string
        C++ executable command for computing curvature
    method : integer {0,1,2}
        method number
    arguments : string
        additional arguments, such as neighborhood parameter
    surface_file : string
        name of VTK surface mesh file
    verbose : bool
        print statements?

    Returns
    -------
    mean_curvature_file : string
        mean curvature file
    gauss_curvature_file : string
        gauss curvature file
    max_curvature_file : string
        max curvature file
    min_curvature_file : string
        min curvature file
    min_curvature_vector_file : string
        min curvature vector file

    Examples
    --------
    >>> import os
    >>> import numpy as np
    >>> from mindboggle.shapes.surface_shapes import curvature
    >>> from mindboggle.mio.vtks import read_scalars
    >>> from mindboggle.mio.fetch_data import prep_tests
    >>> urls, fetch_data = prep_tests()
    >>> surface_file = fetch_data(urls['left_pial'], '', '.vtk')
    >>> method = 2
    >>> arguments = '-n 0.7'
    >>> verbose = False
    >>> ccode_path = os.environ['vtk_cpp_tools']
    >>> command = os.path.join(ccode_path, 'curvature', 'CurvatureMain')
    >>> mean_curvature_file, f1,f2,f3,f4 = curvature(command, method,
    ...     arguments, surface_file, verbose)
    >>> scalars, name = read_scalars(mean_curvature_file)
    >>> np.allclose(scalars[0:8], [-5.8136068088, -5.9312990469, -6.2805500474, -5.6210018286, -5.6963067208, -5.8039874097, -5.8726460688, -5.7106966401])
    True

    """
    import os
    from nipype.interfaces.base import CommandLine

    args = ['-m', str(method)]
    gauss_curvature_file = None
    max_curvature_file = None
    min_curvature_file = None
    min_curvature_vector_file = None

    basename = os.path.splitext(os.path.basename(surface_file))[0]
    mean_curvature_file = os.path.join(os.getcwd(), basename) + \
        '.mean_curvature.vtk'
    if method in [0, 1]:
        gauss_curvature_file = stem + '.gauss_curvature.vtk'
        args.extend(['-g', gauss_curvature_file])
    if method == 0:
        max_curvature_file = stem + '.max_curvature.vtk'
        min_curvature_file = stem + '.min_curvature.vtk'
        min_curvature_vector_file = stem + '.min_curvature.txt'
        args.extend(['-x', max_curvature_file,
                     '-i', min_curvature_file,
                     '-d', min_curvature_vector_file])

    if arguments:
        args.extend([arguments])

    args.extend([surface_file, mean_curvature_file])

    if verbose:
        print("{0} {1}".format(command, args))

    cli = CommandLine(command=command)
    cli.inputs.args = ' '.join(args)
    cli.terminal_output = 'file'
    cli.run()

    return mean_curvature_file, gauss_curvature_file, \
           max_curvature_file, min_curvature_file, min_curvature_vector_file
开发者ID:binarybottle,项目名称:mindboggle,代码行数:104,代码来源:surface_shapes.py


注:本文中的nipype.interfaces.base.CommandLine.terminal_output方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。