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


Python IO.dataSizeFromDataRange方法代码示例

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


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

示例1: dataSize

# 需要导入模块: from ClearMap import IO [as 别名]
# 或者: from ClearMap.IO import dataSizeFromDataRange [as 别名]
def dataSize(filename, **args):
    """Returns size of data in tif file
    
    Arguments:
        filename (str): file name as regular expression
        x,y,z (tuple): data range specifications
    
    Returns:
        tuple: data size
    """
    t = tiff.TiffFile(filename);
    d3 = len(t.pages);
    d2 = t.pages[0].shape;
    #d2 = (d2[0], d2[1]);
    if len(d2) == 3:
      d2 = (d2[2], d2[1], d2[0]);
    else:
      d2 = (d2[1], d2[0]);
    
    if d3 > 1:
        dims = d2 + (d3,);
    else:
        dims =  d2;
    
    return io.dataSizeFromDataRange(dims, **args);
开发者ID:jennan,项目名称:ClearMap,代码行数:27,代码来源:TIF.py

示例2: readData

# 需要导入模块: from ClearMap import IO [as 别名]
# 或者: from ClearMap.IO import dataSizeFromDataRange [as 别名]
def readData(filename, x = all, y = all, z = all, **args):
    """Read data from a single tif image or stack
    
    Arguments:
        filename (str): file name as regular expression
        x,y,z (tuple): data range specifications
    
    Returns:
        array: image data
    """
    
    dsize = dataSize(filename);
    #print "dsize %s" % str(dsize);    
    
    if len(dsize) == 2:
        data = tiff.imread(filename, key = 0);
        #print "data.shape %s" % str(data.shape);        
        
        return io.dataToRange(data.transpose([1,0]), x = x, y = y);
        #return io.dataToRange(data, x = x, y = y);
        
    else:
        if z is all:
            data = tiff.imread(filename);
            if data.ndim == 2:
                # data = data
                data = data.transpose([1,0]);
            elif data.ndim == 3:
                #data = data.transpose([1,2,0]);
                data = data.transpose([2,1,0]);
            elif data.ndim == 4: # multi channel image
                #data = data.transpose([1,2,0,3]);
                data = data.transpose([2,1,0,3]);
            else:
                raise RuntimeError('readData: dimension %d not supproted!' % data.ndim)
            
            return io.dataToRange(data, x = x, y = y, z = all);
        
        else: #optimize for z ranges
            ds = io.dataSizeFromDataRange(dsize, x = x, y = y, z = z);
            t = tiff.TiffFile(filename);
            p = t.pages[0];
            data = numpy.zeros(ds, dtype = p.dtype);
            rz = io.toDataRange(dsize[2], r = z);
            
            #print "test"
            #print rz;
            #print dsize            
            
            for i in range(rz[0], rz[1]):
                xydata = t.pages[i].asarray();
                #data[:,:,i-rz[0]] = io.dataToRange(xydata, x = x, y = y);
                data[:,:,i-rz[0]] = io.dataToRange(xydata.transpose([1,0]), x = x, y = y);
            
            return data
开发者ID:jennan,项目名称:ClearMap,代码行数:57,代码来源:TIF.py

示例3: dataSize

# 需要导入模块: from ClearMap import IO [as 别名]
# 或者: from ClearMap.IO import dataSizeFromDataRange [as 别名]
def dataSize(filename, **args):
    """Read data size from nrrd image
    
    Arguments:
        filename (str): file name as regular expression
        x,y,z (tuple): data range specifications
    
    Returns:
        tuple: data size
    """    
    
    header = readHeader(filename);
    dims = header['sizes'];
    #dims[0:2] = [dims[1], dims[0]];
    return io.dataSizeFromDataRange(dims, **args);
开发者ID:ChristophKirst,项目名称:ClearMap,代码行数:17,代码来源:NRRD.py

示例4: dataSize

# 需要导入模块: from ClearMap import IO [as 别名]
# 或者: from ClearMap.IO import dataSizeFromDataRange [as 别名]
def dataSize(filename, **args):
    """Returns size of data stored as a file list
    
    Arguments:
        filename (str): file name as regular expression
        x,y,z (tuple): data range specifications
    
    Returns:
        tuple: data size
    """

    fp, fl = readFileList(filename)
    nz = len(fl)

    d2 = io.dataSize(os.path.join(fp, fl[0]))
    if not len(d2) == 2:
        raise RuntimeError("FileList: importing multiple files of dim %d not supported!" % len(d2))

    dims = d2 + (nz,)
    return io.dataSizeFromDataRange(dims, **args)
开发者ID:ChristophKirst,项目名称:ClearMapUnstable,代码行数:22,代码来源:FileList.py

示例5: dataSize

# 需要导入模块: from ClearMap import IO [as 别名]
# 或者: from ClearMap.IO import dataSizeFromDataRange [as 别名]
def dataSize(filename, resolution = 0, channel = 0, timepoint = 0, **args):
    """Read data size of the imaris image data set
    
    Arguments:
        filename (str):  imaris file name
        resolution (int): resolution level
        channel (int): color channel
        timepoint (int): time point
    
    Returns:
        tuple: image data size
    """

    f = openFile(filename);
    
    ds = readDataSet(f, resolution = resolution, channel = channel, timepoint = timepoint);
    dims = list(ds.shape);
    dims = (dims[2], dims[1], dims[0]);
    
    return io.dataSizeFromDataRange(dims, **args);
开发者ID:ChristophKirst,项目名称:ClearMap,代码行数:22,代码来源:Imaris.py

示例6: dataSize

# 需要导入模块: from ClearMap import IO [as 别名]
# 或者: from ClearMap.IO import dataSizeFromDataRange [as 别名]
def dataSize(filename, **args):
    """Read data size from raw/mhd image
    
    Arguments:
        filename (str):  imaris file name
        x,y,z (tuple or all): range specifications
    
    Returns:
        int: raw image data size
    """  
    
    imr = vtk.vtkMetaImageReader()
    imr.SetFileName(filename);
    imr.Update()

    im = imr.GetOutput()
    dims = im.GetDimensions();
    #dims = list(dims);
    #dims[0:2] = [dims[1], dims[0]];
    #dims = tuple(dims);
    return io.dataSizeFromDataRange(dims, **args);
开发者ID:audrocks17,项目名称:ClearMap,代码行数:23,代码来源:RAW.py


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