How to use the tifffile.TIFFfile function in tifffile

To help you get started, we’ve selected a few tifffile examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fedebarabas / tormenta / tormenta / analysis / calibration.py View on Github external
def beamProfile(ask, folder=None, shape=(512, 512), th=None):

    stacks, folder = loadStacks(ask, folder)

    n = len(stacks)
    profile = np.zeros(shape)
    norm = 0
    for filename in stacks:
        print(os.path.split(filename)[1])
        if filename.endswith('.hdf5'):
            stack = Stack(filename=filename)
            meanFrame = stack.imageData.mean(0)
            stack.close()
        else:
            tfile = tiff.TIFFfile(filename)
            meanFrame = tfile.asarray()
            tfile.close()

        # Normalization
        meanInt = meanFrame.mean()
        profile += meanFrame / meanInt
        norm += meanInt

    norm /= n

    # 2D fitting of profile
    try:
        profileFit = twoDSymmGaussian(profile)
        popt, epopt = profileFit.popt, profileFit.epopt
    except RuntimeError as err:
        print("Fitting error: {0}".format(err))
github CellProfiler / CellProfiler-Analyst / src / imagereader.py View on Github external
def ReadBitmapViaTIFFfile(data):
    import tifffile
    from cStringIO import StringIO
    im = tifffile.TIFFfile(StringIO(data))
    imdata = im.asarray(squeeze=True)
    if imdata.dtype == np.uint16:
        if np.max(imdata) < 4096:
            imdata = imdata.astype(np.float32) / 4095.
        else:
            imdata = imdata.astype(np.float32) / 65535.
            
        if imdata.ndim == 3:
            # check if channels are identical:
            #   if so return only the first
            #   if not, separate the channels into a list
            if (np.any(imdata[0] != imdata[1]) or
                np.any(imdata[0] != imdata[2])):
                imdata = [imdata[0], imdata[1], imdata[2]]
            else:
                imdata = imdata[0]