Exemplo n.º 1
0
def readDataFiles(filename, x=all, y=all, z=all, **args):
    """Read data from individual images assuming they are the z slices

    Arguments:
        filename (str): file name as regular expression
        x,y,z (tuple): data range specifications
    
    Returns:
        array: image data
    """

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

    #read first image to get data size and type
    rz = io.toDataRange(nz, r=z)
    sz = io.toDataSize(nz, r=z)
    fn = os.path.join(fpath, fl[rz[0]])
    img = io.readData(fn, x=x, y=y)
    nxy = img.shape
    data = numpy.zeros(nxy + (sz, ), dtype=img.dtype)
    data[:, :, 0] = img

    for i in range(rz[0] + 1, rz[1]):
        fn = os.path.join(fpath, fl[i])
        data[:, :, i - rz[0]] = io.readData(fn, x=x, y=y)

    return data
Exemplo n.º 2
0
def readDataFiles(filename, x=all, y=all, z=all, **args):
    """Read data from individual images assuming they are the z slices

    Arguments:
        filename (str): file name as regular expression
        x,y,z (tuple): data range specifications
    
    Returns:
        array: image data
    """

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

    # read first image to get data size and type
    rz = io.toDataRange(nz, r=z)
    sz = io.toDataSize(nz, r=z)
    fn = os.path.join(fpath, fl[rz[0]])
    img = io.readData(fn, x=x, y=y)
    nxy = img.shape
    data = numpy.zeros(nxy + (sz,), dtype=img.dtype)
    data[:, :, 0] = img

    for i in range(rz[0] + 1, rz[1]):
        fn = os.path.join(fpath, fl[i])
        data[:, :, i - rz[0]] = io.readData(fn, x=x, y=y)

    return data
Exemplo n.º 3
0
def dataZSize(filename, z = all, **args):
    """Returns z size of data in tif file
    
    Arguments:
        filename (str): file name as regular expression
        z (tuple): z data range specification
    
    Returns:
        int: z data size
    """
    
    t = tiff.TiffFile(filename);
    
    d2 = t.pages[0].shape;
    if len(d2) == 3:
      return io.toDataSize(d2[0], r = z);
    
    d3 = len(t.pages);
    if d3 > 1:
        return io.toDataSize(d3, r = z);
    else:
        return None;
Exemplo n.º 4
0
def dataZSize(filename, z = all, **args):
    """Returns z size of data in tif file
    
    Arguments:
        filename (str): file name as regular expression
        z (tuple): z data range specification
    
    Returns:
        int: z data size
    """
    
    t = tiff.TiffFile(filename);
    
    d2 = t.pages[0].shape;
    if len(d2) == 3:
      return io.toDataSize(d2[0], r = z);
    
    d3 = len(t.pages);
    if d3 > 1:
        return io.toDataSize(d3, r = z);
    else:
        return None;
Exemplo n.º 5
0
def dataZSize(filename, z=all, **args):
    """Returns size of data stored as a file list
    
    Arguments:
        filename (str): file name as regular expression
        z (tuple): z data range specification
    
    Returns:
        int: z data size
    """

    fp, fl = readFileList(filename)
    nz = len(fl)
    return io.toDataSize(nz, r=z)
Exemplo n.º 6
0
def dataZSize(filename, z=all, **args):
    """Returns size of data stored as a file list
    
    Arguments:
        filename (str): file name as regular expression
        z (tuple): z data range specification
    
    Returns:
        int: z data size
    """

    fp, fl = readFileList(filename)
    nz = len(fl)
    return io.toDataSize(nz, r=z)
Exemplo n.º 7
0
def dataZSize(filename, z = all, **args):
    """Read data z size from nrrd image
        
    Arguments:
        filename (str): file name as regular expression
        z (tuple): z data range specification
    
    Returns:
        int: z data size
    """
    
    header = readHeader(filename);
    dims = header['sizes'];
    
    if len(dims) > 2:
        return io.toDataSize(dims[2], r = z);
    else:
        return None;
Exemplo n.º 8
0
def dataZSize(filename, z=all, **args):
    """Read data z size from nrrd image
        
    Arguments:
        filename (str): file name as regular expression
        z (tuple): z data range specification
    
    Returns:
        int: z data size
    """

    header = readHeader(filename)
    dims = header['sizes']

    if len(dims) > 2:
        return io.toDataSize(dims[2], r=z)
    else:
        return None
Exemplo n.º 9
0
def dataZSize(filename, z = all, **args):
    """Read z data size from raw/mhd image
        
    Arguments:
        filename (str):  imaris file name
        z (tuple or all): range specification
    
    Returns:
        int: raw image z data size
    """  
    
    imr = vtk.vtkMetaImageReader()
    imr.SetFileName(filename);
    imr.Update()

    im = imr.GetOutput()
    dims = im.GetDimensions()
    
    if len(dims) > 2:
        return io.toDataSize(dims[2], r = z);
    else:
        return None;
Exemplo n.º 10
0
def dataZSize(filename, z=all, **args):
    """Read z data size from raw/mhd image
        
    Arguments:
        filename (str):  imaris file name
        z (tuple or all): range specification
    
    Returns:
        int: raw image z data size
    """

    imr = vtk.vtkMetaImageReader()
    imr.SetFileName(filename)
    imr.Update()

    im = imr.GetOutput()
    dims = im.GetDimensions()

    if len(dims) > 2:
        return io.toDataSize(dims[2], r=z)
    else:
        return None