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


Python util.launchCommand函数代码示例

本文整理汇总了Python中util.launchCommand函数的典型用法代码示例。如果您正苦于以下问题:Python launchCommand函数的具体用法?Python launchCommand怎么用?Python launchCommand使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: computeDwiMaskFromFreesurfer

def computeDwiMaskFromFreesurfer(source, reference, sourceToResample, target, extraArgs):
    """

    Args:
        source:    an input image into the dwi space
        reference: usually the freesurfer normalize image
        sourceToResample: The image to apply the transform matrix: usually the freesurfer mask
        target: the output image name

        extraArgs: extra parameters to pass during the resampling computation step

    return
        A mask into the dwi native space

    """
    randomNumber = "{0:.6g}".format(random.randint(0,999999))

    #@TODO add dof as arguments parameters
    dummyTarget = "flirt_{}_target.nii.gz".format(randomNumber)
    matrix = "b0ToFressurfer_{}_transformation.mat".format(randomNumber)
    freesurferToB0 ='freesurferToB0_{}_transformation.mat'.format(randomNumber)

    cmd = "flirt -in {} -ref {} -omat {} -out {} {}".format(source, reference, matrix, dummyTarget, extraArgs)
    util.launchCommand(cmd)
    invertMatrix(matrix, freesurferToB0)
    cmd = "flirt -in {} -ref {} -applyxfm -init {} -out {} ".format(sourceToResample, source, freesurferToB0, target)
    util.launchCommand(cmd)
    return target
开发者ID:sbrambati,项目名称:toad,代码行数:28,代码来源:mriutil.py

示例2: convertAndRestride

def convertAndRestride(source, target, orientation):
    """Utility for converting between different file formats

    Args:
        source: The input source file
        target: The name of the resulting output file name

    """
    cmd = "mrconvert {} {} -stride {} -force -quiet".format(source, target, orientation)
    util.launchCommand(cmd)
    return target
开发者ID:kaurousseau,项目名称:toad,代码行数:11,代码来源:mriutil.py

示例3: tckresample

def tckresample(source, downsample, target, launch=True):
    """ perform resample on track files

    Args:
        source: the input track file
        downsample: decrease the density of points along the length of the
            streamline by some factor
        target: the output track file

    Returns: the executed command line
    """
    cmd = "tckresample -downsample {} {} {}"
    cmd = cmd.format(downsample, source, target)
    if launch: util.launchCommand(cmd)
    return cmd
开发者ID:UNFmontreal,项目名称:toad,代码行数:15,代码来源:mriutil.py

示例4: applyResampleFsl

def applyResampleFsl(source, reference, matrix, target, nearest=False):
    """Register an image with symmetric normalization and mutual information metric

    Args:
        source:
        reference: use this image as reference
        matrix:
        target: the output file name
        nearest: A boolean, process nearest neighbour interpolation

    Returns:
        return a file containing the resulting image transform
    """
    cmd = "flirt -in {} -ref {} -applyxfm -init {} -out {} ".format(source, reference, matrix, target)
    if nearest:
        cmd += "-interp nearestneighbour"
    util.launchCommand(cmd)
    return target
开发者ID:kaurousseau,项目名称:toad,代码行数:18,代码来源:mriutil.py

示例5: tckedit

def tckedit(source, roi, target, launch=True):
    """ perform various editing operations on track files.

    Args:
        source: the input track file(s)
        roi:    specify an inclusion region of interest, as either a binary mask image, or as a sphere
                using 4 comma-separared values (x,y,z,radius)
        target: the output track file

    Returns: the executed command line
    """
    cmd = "tckedit {} {} -quiet".format(source, target)

    if isinstance(roi, basestring):
        cmd += " -include {}".format(roi)
    else:
        for element in roi:
            cmd += " -include {}".format(element)
    if launch: util.launchCommand(cmd)
    return cmd
开发者ID:UNFmontreal,项目名称:toad,代码行数:20,代码来源:mriutil.py

示例6: stride3DImage

def stride3DImage(source, target, layout="1,2,3" ):
    """perform a reorientation of the axes and flip the image into a different layout

    Args:
        source:           the input image
        layout:           comma-separated list that specify the strides.
        outputNamePrefix: a prefix to rename target filename

    Returns:
        A 3 elements tuples representing the command line launch, the standards output and the standard error message
    """
    cmd = "mrconvert {} {} -stride {}".format(source, target, layout)
    return util.launchCommand(cmd)
开发者ID:sbrambati,项目名称:toad,代码行数:13,代码来源:mriutil.py

示例7: invertMatrix

def invertMatrix(source, target):
    """ invert a transformation matrices

    Args:
        source: an input transformation matrices
        target: an output transformation matrices name

    Returns:
        the resulting output transformation matrices name

    """
    cmd = "convert_xfm -inverse {} -omat {}".format(source, target)
    return util.launchCommand(cmd)
开发者ID:sbrambati,项目名称:toad,代码行数:13,代码来源:mriutil.py

示例8: fslToMrtrixEncoding

def fslToMrtrixEncoding(dwi, bVecs, bVals, target):
    """Create a B encoding gradient file base on bVals and bVecs encoding file

    Args:
        dwi:           the input diffusion weight images
        bVecs: a vector value file.
        bVals: a gradient b value encoding file.
        target: the output file name
    Returns:
        A 3 elements tuples representing the command line launch, the standards output and the standard error message

    """
    cmd = "mrinfo {} -fslgrad {} {} -export_grad_mrtrix {} --quiet".format(dwi, bVecs, bVals, target)
    return util.launchCommand(cmd)
开发者ID:sbrambati,项目名称:toad,代码行数:14,代码来源:mriutil.py

示例9: extractSubVolume

def extractSubVolume(source, target, extractAtAxis, extractAtCoordinate, nthreads = "1"):
    """Perform an extraction of a subset of the source image

    Args:
        source: The input image
        target: The resulting output name
        extractAtAxis: extract data only in the axis of interest
        extractAtCoordinate: extract data only in the coordinates of interest

    Returns:
         A tuple of 3 elements representing (the command launch, the stdout and stderr of the execution)
    """
    cmd = "mrconvert -coord {} {} {} {} -nthreads {} -quiet".format(extractAtAxis, extractAtCoordinate, source, target, nthreads)
    return util.launchCommand(cmd)
开发者ID:sbrambati,项目名称:toad,代码行数:14,代码来源:mriutil.py

示例10: extractB0sFromDwi

def extractB0sFromDwi(source, target, bVals, bVecs, nthreads = "1"):
    """Perform an extraction of all b0s image found into a DWI image

    Args:
        source: The input image
        target: The resulting output name
        bvals:   BValue table
        bvecs: Gradient table

    Returns:
         A tuple of 3 elements representing (the command launch, the stdout and stderr of the execution)
    """
    cmd = 'dwiextract -bzero {} {} -fslgrad {} {} -nthreads {} -quiet'.format(source, target, bVecs, bVals, nthreads)
    return util.launchCommand(cmd)
开发者ID:UNFmontreal,项目名称:toad,代码行数:14,代码来源:mriutil.py

示例11: mrtrixToFslEncoding

def mrtrixToFslEncoding(dwi, bEncs, bVecsTarget, bValsTarget):
    """Create a B encoding gradient file base on bVals and bVecs encoding file

    Args:
        dwi:           the input diffusion weight images
        bEncs: a mrtrix encoding gradient direction file.
        bVecsTarget: a output vector file name.
        bValsTarget: a output value file name.
    Returns:
        A 3 elements tuples representing the command line launch, the standards output and the standard error message

    """
    cmd = "mrinfo {} -grad {} -export_grad_fsl {} {} --quiet".format(dwi, bEncs, bVecsTarget, bValsTarget)
    return util.launchCommand(cmd)
开发者ID:sbrambati,项目名称:toad,代码行数:14,代码来源:mriutil.py

示例12: getBValues

def getBValues(source, grad):
    """Use mrinfo to get BValues

    Args:
        Source: dwi file

    Returns:
        An array of bValues

    Raises:
        ValueError: if mrinfo binary is not found

    """
    cmd = "mrinfo {} -grad {} -shells".format(source, grad)
    (executedCmd, stdout, stderr) = util.launchCommand(cmd)
    return stdout.split()
开发者ID:UNFmontreal,项目名称:toad,代码行数:16,代码来源:mriutil.py

示例13: mrinfo

def mrinfo(source):
    """display or extract specific information from the source header.

    Args:
        source: the input image

    Returns:
        An array of information generate by the standard output command line

    Raises:
        ValueError: if mrinfo binary is not found
    """

    cmd = "mrinfo {}".format(source)
    (executedCmd, stdout, stderr) = util.launchCommand(cmd)
    return stdout.splitlines()
开发者ID:sbrambati,项目名称:toad,代码行数:16,代码来源:mriutil.py

示例14: fslmaths

def fslmaths(source1, target, operator="bin", source2=None):
    """Perform a mathematical operations using a second image or a numeric value

    Args:
        source1: he input image
        target:  Name of the resulting output image
        operator: Operator to apply
        source2: Image associate with the operator if Binary operation is specified

    Returns:
        A tuple of 3 elements representing (the command launch, the stdout and stderr of the execution)

    """
    if source2 is None:
        cmd = "fslmaths {} -{} {} ".format(source1, operator, target)
    else:
        cmd = "fslmaths {} -{} {} {}".format(source1, operator, source2, target)

    return util.launchCommand(cmd)
开发者ID:sbrambati,项目名称:toad,代码行数:19,代码来源:mriutil.py

示例15: tckedit

def tckedit(source, roi, target, downsample= "2"):
    """ perform various editing operations on track files.

    Args:
        source: the input track file(s)
        roi:    specify an inclusion region of interest, as either a binary mask image, or as a sphere
                using 4 comma-separared values (x,y,z,radius)
        target: the output track file
        downsample: increase the density of points along the length of the streamline by some factor

    Returns:
        the output track file
    """
    cmd = "tckedit {} {} -downsample {} -quiet ".format(source, target, downsample)
    if isinstance(roi, basestring):
        cmd += " -include {}".format(roi)
    else:
        for element in roi:
            cmd += " -include {}".format(element)
    return util.launchCommand(cmd)
开发者ID:sbrambati,项目名称:toad,代码行数:20,代码来源:mriutil.py


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