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


Python IO.createDirectory方法代码示例

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


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

示例1: writeData

# 需要导入模块: from ClearMap import IO [as 别名]
# 或者: from ClearMap.IO import createDirectory [as 别名]
def writeData(filename, data, startIndex=0):
    """Write image stack to single or multiple image files
    
    Arguments:
        filename (str): file name as regular expression
        data (array): image data
        startIndex (int): index of first z-slice
    
    Returns:
        str: file name as regular expression
    """

    # create directory if not exsits
    io.createDirectory(filename)

    # check for the \d{xx} part of the regular expression -> if not assume file header
    (fileheader, fileext, digitfrmt) = splitFileExpression(filename)

    d = len(data.shape)
    if d == 2:
        fname = fileheader + (digitfrmt % startIndex) + fileext
        io.writeData(fname, data)
        return fname
    else:
        nz = data.shape[2]
        for i in range(nz):
            fname = fileheader + (digitfrmt % (i + startIndex)) + fileext
            io.writeData(fname, data[:, :, i])
        return filename
开发者ID:ChristophKirst,项目名称:ClearMapUnstable,代码行数:31,代码来源:FileList.py

示例2: moveTeraStitcherStackToFileList

# 需要导入模块: from ClearMap import IO [as 别名]
# 或者: from ClearMap.IO import createDirectory [as 别名]
def moveTeraStitcherStackToFileList(source, sink, deleteDirectory=True, verbose=True):
    """Moves image files from TeraSticher file structure to a list of files
  
  Arguments:
    source (str): base directory of the TeraStitcher files
    sink (str): regular expression of the files to copy to
    verbose (bool): show progress

  Returns:
    str: sink regular expression
  """

    fns = glob.glob(os.path.join(source, "*/*/*"))
    fns = natsort.natsorted(fns)

    io.createDirectory(sink)
    for i, f in enumerate(fns):
        fn = filelist.fileExpressionToFileName(sink, i)
        if verbose:
            print "%s -> %s" % (f, fn)
        shutil.move(f, fn)

    if deleteDirectory:
        p, _ = os.path.split(fns[0])
        p = p.split(os.path.sep)
        p = p[:-2]
        p = os.path.sep.join(p)
        shutil.rmtree(p)

    return sink
开发者ID:ChristophKirst,项目名称:ClearMapUnstable,代码行数:32,代码来源:Stitching.py

示例3: copyTeraStitcherStackToFileList

# 需要导入模块: from ClearMap import IO [as 别名]
# 或者: from ClearMap.IO import createDirectory [as 别名]
def copyTeraStitcherStackToFileList(source, sink, verbose=True):
    """Copies image files from TeraSticher file structure to a list of files
  
  Arguments:
    source (str): base directory of the TeraStitcher files
    sink (str): regular expression of the files to copy to
    verbose (bool): show progress

  Returns:
    str: sink regular expression
  """
    # TODO: multiple tiles !
    fns = glob.glob(os.path.join(source, "*/*/*"))
    fns = natsort.natsorted(fns)
    # print fns

    io.createDirectory(sink)
    for i, f in enumerate(fns):
        fn = filelist.fileExpressionToFileName(sink, i)
        if verbose:
            print "%s -> %s" % (f, fn)
        shutil.copyfile(f, fn)

    return sink
开发者ID:ChristophKirst,项目名称:ClearMapUnstable,代码行数:26,代码来源:Stitching.py

示例4: stitchData

# 需要导入模块: from ClearMap import IO [as 别名]
# 或者: from ClearMap.IO import createDirectory [as 别名]
def stitchData(
    xmlPlacementFile,
    resultPath,
    algorithm=None,
    resolutions=None,
    form=None,
    channel=None,
    subRegion=None,
    bitDepth=None,
    blockSize=None,
    cleanup=True,
    compress=False,
):
    """Runs the final stiching step of TeraSticher
  
  Arguments:
    xmlPlacementFile (str or None): the xml placement descriptor
    resultPath (str): result path, file name or file expression for the stiched data
    algorithm (str or None): optional algorithm to use for placement: 
                             'NOBLEND' for no blending
                             'SINBLEND' for sinusoidal blending
    resolutions (tuple or None): the different resolutions to produce
    form (str or None): the output form, if None determined automatically
    channel (str or None): the channels to use, 'R', 'G', 'B' or 'all'
    subRegion (tuple or None): optional sub region in the form ((xmin,xmax),(ymin,ymax), (zmin, zmax))
    bitDepth (int or None): the pits per pixel to use, default is 8
    blockSize (tuple): the sizes of various blocks to save stiched image into
    cleanup (bool): if True delete the TeraSticher file structure
    compress (bool): if True compress final tif images
  
  Returns:
    str : the result path or file name of the stiched data
    
  See also:
    `TeraStitcher project step <https://github.com/abria/TeraStitcher/wiki/Step-6:-Merge>`_.
  """

    checkSticherInitialized()
    global TeraStitcherBinary

    cmd = TeraStitcherBinary + ' --merge --imout_format="tif" '

    cmd = cmd + '--projin="' + xmlPlacementFile + '" '

    if len(resultPath) > 3 and resultPath[-4:] == ".tif":
        if io.isFileExpression(resultPath):
            form = "TiledXY|2Dseries"
            resultPath, filename = os.path.split(resultPath)
        else:
            form = "TiledXY|3Dseries"
            resultPath, filename = os.path.split(resultPath)
    else:
        filename = None

    cmd = cmd + '--volout="' + resultPath + '" '

    if algorithm is not None:
        cmd = cmd + ' --algorithm="' + algorithm + '" '

    if resolutions is not None:
        cmd = cmd + '--resolutions="'
        for r in sorted(resolutions):
            cmd = cmd + str(r)
        cmd = cmd + " "

    if form is not None:
        cmd = cmd + '--volout_plugin="' + form + '" '

    if channel is not None:
        cmd = cmd + '--imin_channel="' + channel + '" '

    if subRegion is not None:
        sns = (("--R0=", "--R1="), ("--C0=", "--C1="), ("--D0=", "--D1-"))
        for d in range(3):
            for m in range(2):
                if subRegion[d][m] is not None:
                    cmd = cmd + sns[d][m] + str(subRegion[d][m]) + " "

    if blockSize is not None:
        bs = ("--slicewidth=", "--sliceheight=", "--slicedepth=")
        for d in range(3):
            if blockSize[d] is not None:
                cmd = cmd + bs[d] + str(blockSize[d]) + " "

    if bitDepth is not None:
        cmd = cmd + "--imout_depth=" + str(bitDepth) + " "

    if not compress:
        cmd = cmd + "--libtiff_uncompress "

    # print resultPath
    io.createDirectory(resultPath, split=False)

    print "running: " + cmd
    res = os.system(cmd)

    if res != 0:
        raise RuntimeError("stitchData: failed executing: " + cmd)

    if filename is not None:
#.........这里部分代码省略.........
开发者ID:ChristophKirst,项目名称:ClearMapUnstable,代码行数:103,代码来源:Stitching.py


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