コード例 #1
0
def import_image(filename,
                 color_mode='color',
                 split_c=False, split_z=False, split_t=False):
    """Open an image file using the Bio-Formats importer.

    Parameters
    ----------
    filename : str
        The full path to the file to be imported through Bio-Formats.
    color_mode : str, optional
        The color mode to be used for the resulting ImagePlus, one of 'color',
        'composite', 'gray' and 'default'.
    split_c : bool, optional
        Whether to split the channels into separate ImagePlus objects.
    split_z : bool, optional
        Whether to split the z-slices into separate ImagePlus objects.
    split_t : bool, optional
        Whether to split the time points into separate ImagePlus objects.

    Returns
    -------
    ij.ImagePlus[]
        A list of ImagePlus objects resulting from the import.
    """
    options = ImporterOptions()
    mode = {
        'color' : ImporterOptions.COLOR_MODE_COLORIZED,
        'composite' : ImporterOptions.COLOR_MODE_COMPOSITE,
        'gray' : ImporterOptions.COLOR_MODE_GRAYSCALE,
        'default' : ImporterOptions.COLOR_MODE_DEFAULT,
    }
    options.setColorMode(mode[color_mode])
    options.setSplitChannels(split_c)
    options.setSplitFocalPlanes(split_z)
    options.setSplitTimepoints(split_t)
    options.setId(filename)
    log.info("Reading [%s]", filename)
    orig_imps = BF.openImagePlus(options)
    log.debug("Opened [%s] %s", filename, type(orig_imps))
    return orig_imps