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


Python reader.read_tiff_stack函数代码示例

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


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

示例1: read_elettra_syrmep

def read_elettra_syrmep(fname, ind_tomo):
    """
    Read Elettra SYRMEP standard data format.

    Parameters
    ----------
    fname : str
        Path to data folder.

    ind_tomo : list of int
        Indices of the projection files to read.

    Returns
    -------
    ndarray
        3D tomographic data.

    ndarray
        3d flat field data.

    ndarray
        3D dark field data.
    """
    fname = os.path.abspath(fname)
    tomo_name = os.path.join(fname, 'tomo_0001.tif')
    flat_name = os.path.join(fname, 'flat_0001.tif')
    dark_name = os.path.join(fname, 'dark_0001.tif')
    ind_flat = range(1, 11)
    ind_dark = range(1, 11)
    tomo = tio.read_tiff_stack(tomo_name, ind=ind_tomo, digit=4)
    flat = tio.read_tiff_stack(flat_name, ind=ind_flat, digit=4)
    dark = tio.read_tiff_stack(dark_name, ind=ind_dark, digit=4)
    return tomo, flat, dark
开发者ID:ttgmichael,项目名称:tomopy,代码行数:33,代码来源:exchange.py

示例2: read_diamond_l12

def read_diamond_l12(fname, ind_tomo):
    """
    Read Diamond Light Source L12 (JEEP) standard data format.

    Parameters
    ----------
    fname : str
        Path to data folder.

    ind_tomo : list of int
        Indices of the projection files to read.

    Returns
    -------
    ndarray
        3D tomographic data.

    ndarray
        3d flat field data.
    """
    fname = os.path.abspath(fname)
    tomo_name = os.path.join(fname, 'im_001000.tif')
    flat_name = os.path.join(fname, 'flat_000000.tif')
    ind_flat = range(0, 1)
    tomo = tio.read_tiff_stack(tomo_name, ind=ind_tomo, digit=6)
    flat = tio.read_tiff_stack(flat_name, ind=ind_flat, digit=6)
    return tomo, flat
开发者ID:ttgmichael,项目名称:tomopy,代码行数:27,代码来源:exchange.py

示例3: read_petraIII_p05

def read_petraIII_p05(
        fname, ind_tomo, ind_flat, ind_dark, proj=None, sino=None):
    """
    Read Petra-III P05 standard data format.

    Parameters
    ----------
    fname : str
        Path to data folder.

    ind_tomo : list of int
        Indices of the projection files to read.

    ind_flat : list of int
        Indices of the flat field files to read.

    ind_dark : list of int
        Indices of the dark field files to read.

    proj : {sequence, int}, optional
        Specify projections to read. (start, end, step)

    sino : {sequence, int}, optional
        Specify sinograms to read. (start, end, step)

    Returns
    -------
    ndarray
        3D tomographic data.

    ndarray
        3d flat field data.

    ndarray
        3D dark field data.
    """
    fname = os.path.abspath(fname)
    tomo_name = os.path.join(
        fname, 'scan_0002', 'ccd', 'pco01', 'ccd_0000.tif')
    flat_name = os.path.join(
        fname, 'scan_0001', 'ccd', 'pco01', 'ccd_0000.tif')
    dark_name = os.path.join(
        fname, 'scan_0000', 'ccd', 'pco01', 'ccd_0000.tif')
    tomo = tio.read_tiff_stack(
        tomo_name, ind=ind_tomo, digit=4, slc=(sino, proj))
    flat = tio.read_tiff_stack(
        flat_name, ind=ind_flat, digit=4, slc=(sino, None))
    dark = tio.read_tiff_stack(
        dark_name, ind=ind_dark, digit=4, slc=(sino, None))
    return tomo, flat, dark
开发者ID:habi,项目名称:tomopy,代码行数:50,代码来源:exchange.py

示例4: read_sls_tomcat

def read_sls_tomcat(fname, ind_tomo=None):
    """
    Read SLS TOMCAT standard data format.

    Parameters
    ----------
    fname : str
        Path to file name without indices and extension.

    ind_tomo : list of int, optional
        Indices of the projection files to read.

    Returns
    -------
    ndarray
        3D tomographic data.

    ndarray
        3d flat field data.

    ndarray
        3D dark field data.
    """
    # File definitions.
    fname = os.path.abspath(fname)
    _fname = fname + '0001.tif'
    log_file = fname + '.log'

    # Read metadata from ALS log file.
    contents = open(log_file, 'r')
    for line in contents:
        ls = line.split()
        if len(ls) > 1:
            if ls[0] == 'Number' and ls[2] == 'projections':
                nproj = int(ls[4])
            elif ls[0] == 'Number' and ls[2] == 'flats':
                nflat = int(ls[4])
            elif ls[0] == 'Number' and ls[2] == 'darks':
                ndark = int(ls[4])
    contents.close()

    if ind_tomo is None:
        ind_tomo = range(ndark + nflat + 1, ndark + nflat + nproj)
    ind_flat = range(ndark + 1, ndark + nflat)
    ind_dark = range(1, ndark)
    tomo = tio.read_tiff_stack(_fname, ind=ind_tomo, digit=4)
    flat = tio.read_tiff_stack(_fname, ind=ind_flat, digit=4)
    dark = tio.read_tiff_stack(_fname, ind=ind_dark, digit=4)
    return tomo, flat, dark
开发者ID:ttgmichael,项目名称:tomopy,代码行数:49,代码来源:exchange.py

示例5: read_als_832

def read_als_832(fname, ind_tomo=None):
    """
    Read ALS 8.3.2 standard data format.

    Parameters
    ----------
    fname : str
        Path to file name without indices and extension.

    ind_tomo : list of int, optional
        Indices of the projection files to read.

    Returns
    -------
    ndarray
        3D tomographic data.

    ndarray
        3d flat field data.

    ndarray
        3D dark field data.
    """
    # File definitions.
    fname = os.path.abspath(fname)
    tomo_name = fname + '_0000_0000.tif'
    flat_name = fname + 'bak_0000.tif'
    dark_name = fname + 'drk_0000.tif'
    log_file = fname + '.sct'

    # Read metadata from ALS log file.
    contents = open(log_file, 'r')
    for line in contents:
        if '-nangles' in line:
            nproj = int(re.findall(r'\d+', line)[0])
        if '-num_bright_field' in line:
            nflat = int(re.findall(r'\d+', line)[0])
        if '-num_dark_fields' in line:
            ndark = int(re.findall(r'\d+', line)[0])
    contents.close()

    if ind_tomo is None:
        ind_tomo = range(0, nproj)
    ind_flat = range(0, nflat)
    ind_dark = range(0, ndark)
    tomo = tio.read_tiff_stack(tomo_name, ind=ind_tomo, digit=4)
    flat = tio.read_tiff_stack(flat_name, ind=ind_flat, digit=4)
    dark = tio.read_tiff_stack(dark_name, ind=ind_dark, digit=4)
    return tomo, flat, dark
开发者ID:AaronBM,项目名称:tomopy,代码行数:49,代码来源:exchange.py

示例6: read_elettra_syrmep

def read_elettra_syrmep(
        fname, ind_tomo, ind_flat, ind_dark, proj=None, sino=None):
    """
    Read Elettra SYRMEP standard data format.

    Parameters
    ----------
    fname : str
        Path to data folder.

    ind_tomo : list of int
        Indices of the projection files to read.

    ind_flat : list of int
        Indices of the flat field files to read.

    ind_dark : list of int
        Indices of the dark field files to read.

    proj : {sequence, int}, optional
        Specify projections to read. (start, end, step)

    sino : {sequence, int}, optional
        Specify sinograms to read. (start, end, step)

    Returns
    -------
    ndarray
        3D tomographic data.

    ndarray
        3d flat field data.

    ndarray
        3D dark field data.
    """
    fname = os.path.abspath(fname)
    tomo_name = os.path.join(fname, 'tomo_0001.tif')
    flat_name = os.path.join(fname, 'flat_1.tif')
    dark_name = os.path.join(fname, 'dark_1.tif')
    tomo = tio.read_tiff_stack(
        tomo_name, ind=ind_tomo, digit=4, slc=(sino, proj))
    flat = tio.read_tiff_stack(
        flat_name, ind=ind_flat, digit=1, slc=(sino, None))
    dark = tio.read_tiff_stack(
        dark_name, ind=ind_dark, digit=1, slc=(sino, None))
    return tomo, flat, dark
开发者ID:habi,项目名称:tomopy,代码行数:47,代码来源:exchange.py

示例7: read_anka_topotomo

def read_anka_topotomo(
        fname, ind_tomo, ind_flat, ind_dark, proj=None, sino=None):
    """
    Read ANKA TOMO-TOMO standard data format.

    Parameters
    ----------
    fname : str
        Path to data folder name without indices and extension.

    ind_tomo : list of int, optional
        Indices of the projection files to read.

    ind_flat : list of int, optional
        Indices of the flat field files to read.

    ind_dark : list of int, optional
        Indices of the dark field files to read.

    proj : {sequence, int}, optional
        Specify projections to read. (start, end, step)

    sino : {sequence, int}, optional
        Specify sinograms to read. (start, end, step)

    Returns
    -------
    ndarray
        3D tomographic data.

    ndarray
        3d flat field data.

    ndarray
        3D dark field data.
    """
    fname = os.path.abspath(fname)
    tomo_name = os.path.join(fname, 'radios', 'image_00000.tif')
    flat_name = os.path.join(fname, 'flats', 'image_00000.tif')
    dark_name = os.path.join(fname, 'darks', 'image_00000.tif')
    tomo = tio.read_tiff_stack(
        tomo_name, ind=ind_tomo, digit=5, slc=(sino, proj))
    flat = tio.read_tiff_stack(
        flat_name, ind=ind_flat, digit=5, slc=(sino, None))
    dark = tio.read_tiff_stack(
        dark_name, ind=ind_dark, digit=5, slc=(sino, None))
    return tomo, flat, dark
开发者ID:habi,项目名称:tomopy,代码行数:47,代码来源:exchange.py

示例8: read_petra3_p05

def read_petra3_p05(fname, ind_tomo, ind_flat, ind_dark):
    """
    Read Petra-III P05 standard data format.

    Parameters
    ----------
    fname : str
        Path to data folder.

    ind_tomo : list of int
        Indices of the projection files to read.

    ind_flat : list of int
        Indices of the flat field files to read.

    ind_dark : list of int
        Indices of the dark field files to read.

    Returns
    -------
    ndarray
        3D tomographic data.

    ndarray
        3d flat field data.

    ndarray
        3D dark field data.
    """
    fname = os.path.abspath(fname)
    tomo_name = os.path.join(
        fname, 'scan_0002', 'ccd', 'pco01', 'ccd_0000.tif')
    flat_name = os.path.join(
        fname, 'scan_0001', 'ccd', 'pco01', 'ccd_0000.tif')
    dark_name = os.path.join(
        fname, 'scan_0003', 'ccd', 'pco01', 'ccd_0000.tif')
    tomo = tio.read_tiff_stack(tomo_name, ind=ind_tomo, digit=4)
    flat = tio.read_tiff_stack(flat_name, ind=ind_flat, digit=4)
    dark = tio.read_tiff_stack(dark_name, ind=ind_dark, digit=4)
    return tomo, flat, dark
开发者ID:ttgmichael,项目名称:tomopy,代码行数:40,代码来源:exchange.py

示例9: read_aus_microct

def read_aus_microct(fname, ind_tomo, ind_flat, ind_dark):
    """
    Read Australian Synchrotron Micro Computed Tomography standard
    data format.

    Parameters
    ----------
    fname : str
        Path to data folder.

    ind_tomo : list of int
        Indices of the projection files to read.

    ind_flat : list of int
        Indices of the flat field files to read.

    ind_dark : list of int
        Indices of the dark field files to read.

    Returns
    -------
    ndarray
        3D tomographic data.

    ndarray
        3d flat field data.

    ndarray
        3D dark field data.
    """
    fname = os.path.abspath(fname)
    tomo_name = os.path.join(fname, 'SAMPLE_T_0000.tif')
    flat_name = os.path.join(fname, 'BG__BEFORE_00.tif')
    dark_name = os.path.join(fname, 'DF__BEFORE_00.tif')
    tomo = tio.read_tiff_stack(tomo_name, ind=ind_tomo, digit=4)
    flat = tio.read_tiff_stack(flat_name, ind=ind_flat, digit=2)
    dark = tio.read_tiff_stack(dark_name, ind=ind_dark, digit=2)
    return tomo, flat, dark
开发者ID:ttgmichael,项目名称:tomopy,代码行数:38,代码来源:exchange.py

示例10: read_anka_tomotopo

def read_anka_tomotopo(fname, ind_tomo, ind_flat, ind_dark):
    """
    Read ANKA TOMO-TOMO standard data format.

    Parameters
    ----------
    fname : str
        Path to data folder name without indices and extension.

    ind_tomo : list of int, optional
        Indices of the projection files to read.

    ind_flat : list of int, optional
        Indices of the flat field files to read.

    ind_dark : list of int, optional
        Indices of the dark field files to read.

    Returns
    -------
    ndarray
        3D tomographic data.

    ndarray
        3d flat field data.

    ndarray
        3D dark field data.
    """
    fname = os.path.abspath(fname)
    tomo_name = os.path.join(fname, 'radios', 'image_00000.tif')
    flat_name = os.path.join(fname, 'flats', 'image_00000.tif')
    dark_name = os.path.join(fname, 'darks', 'image_00000.tif')
    tomo = tio.read_tiff_stack(tomo_name, ind=ind_tomo, digit=5)
    flat = tio.read_tiff_stack(flat_name, ind=ind_flat, digit=5)
    dark = tio.read_tiff_stack(dark_name, ind=ind_dark, digit=5)
    return tomo, flat, dark
开发者ID:ttgmichael,项目名称:tomopy,代码行数:37,代码来源:exchange.py

示例11: read_als_832

def read_als_832(fname, ind_tomo=None, normalized=False):
    """
    Read ALS 8.3.2 standard data format.

    Parameters
    ----------
    fname : str
        Path to file name without indices and extension.

    ind_tomo : list of int, optional
        Indices of the projection files to read.

    normalized : boolean
	If False, darks and flats will not be read. This should
        only be used for cases where tomo is already normalized. 
        8.3.2 has a plugin that normalization is preferred to be 
        done with prior to tomopy reconstruction.

    Returns
    -------
    ndarray
        3D tomographic data.

    ndarray
        3d flat field data.

    ndarray
        3D dark field data.
    """

    # File definitions.
    fname = os.path.abspath(fname)

    if not normalized:
        fname = fname.split('output')[0]+fname.split('/')[len(fname.split('/'))-1]
        tomo_name = fname + '_0000_0000.tif'
        flat_name = fname + 'bak_0000.tif'
        dark_name = fname + 'drk_0000.tif'
        log_file = fname + '.sct'
    else:
        if "output" not in fname:
            raise Exception('Please provide the normalized output directory as input') 
        tomo_name = fname + '_0.tif'
        fname = fname.split('output')[0]+fname.split('/')[len(fname.split('/'))-1]
        log_file = fname + '.sct'

    # Read metadata from ALS log file.
    contents = open(log_file, 'r')
    for line in contents:
        if '-nangles' in line:
            nproj = int(re.findall(r'\d+', line)[0])
        if '-num_bright_field' in line:
            nflat = int(re.findall(r'\d+', line)[0])
        if '-i0cycle' in line:
            inter_bright = int(re.findall(r'\d+', line)[1])
        if '-num_dark_fields' in line:
            ndark = int(re.findall(r'\d+', line)[0])
    contents.close()
    if ind_tomo is None:
        ind_tomo = range(0, nproj)
    if not normalized:
        ind_flat = range(0, nflat)
        if inter_bright > 0:
            ind_flat = range(0, nproj, inter_bright)
            flat_name = fname + 'bak_0000_0000.tif'
        ind_dark = range(0, ndark)
    # Read image data from tiff stack.
    tomo = tio.read_tiff_stack(tomo_name, ind=ind_tomo, digit=4)
    if not normalized:
        """ Adheres to 8.3.2 flat/dark naming conventions: 
            ----Flats----
            root_namebak_xxxx_yyyy
            For datasets that take flat at the start and end of its scan,
            xxxx is in incrementals of one, and yyyy is either 0000 or the last projection.
            For datasets that take flat while they scan (when the beam fluctuates during scans),
            xxxx is always 0000, and yyyy is in intervals given by log file. 
        """
            
        if inter_bright == 0:
            a = [0,nproj-1]
            list_flat = tio._list_file_stack(flat_name, ind_flat, digit=4)
            for x in ind_flat:
                body = os.path.splitext(list_flat[x])[0] + "_"
                ext = os.path.splitext(list_flat[x])[1]
                for y,z in enumerate(a):
                    y = body + '{0:0={1}d}'.format(z, 4) + ext
                    if z == 0: list_flat[x] = y
                    else: list_flat.append(y)
            list_flat = sorted(list_flat)
            for m, image in enumerate(list_flat):
                _arr = tio.read_tiff(image)
                if m == 0:
                    dx = len(ind_flat*2)
                    dy, dz = _arr.shape
                    flat = np.zeros((dx, dy, dz))
                flat[m] = _arr
            flat = tio._slice_array(flat, None)
        else:
            flat = tio.read_tiff_stack(flat_name, ind=ind_flat, digit=4)

#.........这里部分代码省略.........
开发者ID:ttgmichael,项目名称:tomopy,代码行数:101,代码来源:exchange.py

示例12: read_sls_tomcat

def read_sls_tomcat(fname, ind_tomo=None, proj=None, sino=None):
    """
    Read SLS TOMCAT standard data format.

    Parameters
    ----------
    fname : str
        Path to file name without indices and extension.

    ind_tomo : list of int, optional
        Indices of the projection files to read.

    proj : {sequence, int}, optional
        Specify projections to read. (start, end, step)

    sino : {sequence, int}, optional
        Specify sinograms to read. (start, end, step)

    Returns
    -------
    ndarray
        3D tomographic data.

    ndarray
        3d flat field data.

    ndarray
        3D dark field data.
    """
    # File definitions.
    fname = os.path.abspath(fname)
    _fname = fname + '0001.tif'
    log_file = fname + '.log'

    # Read metadata from SLS log file.
    contents = open(log_file, 'r')
    for line in contents:
        ls = line.split()
        if len(ls) > 1:
            if ls[0] == 'Number' and ls[2] == 'projections':
                nproj = int(ls[4])
            elif ls[0] == 'Number' and ls[2] == 'flats':
                nflat = int(ls[4])
            elif ls[0] == 'Number' and ls[2] == 'darks':
                ndark = int(ls[4])
    contents.close()

    dark_start = 1
    dark_end = ndark + 1
    flat_start = dark_end
    flat_end = flat_start + nflat
    proj_start = flat_end
    proj_end = proj_start + nproj

    if ind_tomo is None:
        ind_tomo = range(proj_start, proj_end)
    ind_flat = range(flat_start, flat_end)
    ind_dark = range(dark_start, dark_end)
    tomo = tio.read_tiff_stack(_fname, ind=ind_tomo, digit=4, slc=(sino, proj))
    flat = tio.read_tiff_stack(_fname, ind=ind_flat, digit=4, slc=(sino, None))
    dark = tio.read_tiff_stack(_fname, ind=ind_dark, digit=4, slc=(sino, None))

    return tomo, flat, dark
开发者ID:habi,项目名称:tomopy,代码行数:63,代码来源:exchange.py

示例13: read_aps_1id

def read_aps_1id(fname, ind_tomo=None, proj=None, sino=None):
    """
    Read APS 1-ID standard data format.

    Parameters
    ----------
    fname : str
        Path to file name without indices and extension.

    ind_tomo : list of int, optional
        Indices of the projection files to read.

    proj : {sequence, int}, optional
        Specify projections to read. (start, end, step)

    sino : {sequence, int}, optional
        Specify sinograms to read. (start, end, step)

    Returns
    -------
    ndarray
        3D tomographic data.

    ndarray
        3d flat field data.

    ndarray
        3D dark field data.
    """
    # File definitions.
    fname = os.path.abspath(fname)
    _fname = fname + '000001.tif'
    log_file = os.path.dirname(fname) + os.path.sep + 'TomoStillScan.dat'

    # Read APS 1-ID log file data
    contents = open(log_file, 'r')
    for line in contents:
        ls = line.split()
        if len(ls) > 1:
            if ls[0] == "Tomography" and ls[1] == "scan":
                prj_start = int(ls[6])
            elif ls[0] == "Number" and ls[2] == "scan":
                nprj = int(ls[4])
            elif ls[0] == "Dark" and ls[1] == "field":
                dark_start = int(ls[6])
            elif ls[0] == "Number" and ls[2] == "dark":
                ndark = int(ls[5])
            elif ls[0] == "White" and ls[1] == "field":
                flat_start = int(ls[6])
            elif ls[0] == "Number" and ls[2] == "white":
                nflat = int(ls[5])
    contents.close()

    if ind_tomo is None:
        ind_tomo = range(prj_start, prj_start + nprj)
    ind_flat = range(flat_start, flat_start + nflat)
    ind_dark = range(dark_start, dark_start + ndark)
    tomo = tio.read_tiff_stack(_fname, ind=ind_tomo, digit=6, slc=(sino, proj))
    flat = tio.read_tiff_stack(_fname, ind=ind_flat, digit=6, slc=(sino, None))
    dark = tio.read_tiff_stack(_fname, ind=ind_dark, digit=6, slc=(sino, None))
    return tomo, flat, dark
开发者ID:habi,项目名称:tomopy,代码行数:61,代码来源:exchange.py


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