def load_bite_image(well, fview=1):
    well_imgs = [f for f in fnames if well in f and 'ch2' not in f]
    wellpos = [f for f in well_imgs if 'f0' + str(fview) + 'p' in f]
    imgseries = load_image_series(path=platedir, imgfiles=wellpos)
    imgseries = imgseries.reshape((8, 4, 2160, 2160))
    mipseries = np.amax(imgseries, axis=0)
    return mipseries
    outdir = 'figures/segfree/organoids'
    if not os.path.exists(outdir):
        os.makedirs(outdir)

    random.seed(1108)

    imglist = []
    titles = []
    for path in paths:
        fnames, all_wells = get_all_wells(path=path)
        # randomly sample 10 wells
        sel_wells = random.sample(all_wells, k=5)
        for w in sel_wells:
            print("Processing well: %s" % w)
            well_files = [f for f in fnames if w in f]
            imgstack = load_image_series(
                path=path, imgfiles=[w for w in well_files if 'P00001' in w])
            imgstack = imgstack.swapaxes(0, -1)
            imglist.append(imgstack)
            titles.append(re.search('(.+)(--W[0-9]+)', well_files[0]).group(1))

    # 3D profiling
    segf = SegfreeProfiler(tile_size=(20, 20),
                           n_block_types=20,
                           n_supblock_types=50)
    org_prof = segf.fit_transform(imglist)
    pickle.dump(segf, open("segf_organoids.pkl", "wb"))

    plt.plot(np.cumsum(segf.pca.explained_variance_ratio_), linewidth=3)
    sn.despine()
    plt.axhline(y=1, color='black', linestyle=':')
    plt.xlabel('Number of principal components')
    well = all_wells[wellnum]
    fnames = [f for f in os.listdir(imgdir) if '.tiff' in f]

    # load minimum lysosomal intensity (estmated background)
    thresh_df = pd.read_csv('data/coculture_metafiles/thresholds/' + plate +
                            '.csv')
    bg_thresh = np.min(thresh_df[['thresh_mono', 'thresh_co']].values)

    # apply gamma correction
    gamma = 0.3

    imgdata = []
    for fview in range(1, 4):
        wellpos = well + 'f' + str(fview).zfill(2)
        wfiles = [f for f in fnames if wellpos in f and '(2)' not in f]
        imgstack = load_image_series(
            path=imgdir, imgfiles=[w for w in wfiles if 'ch1' in w])
        hoechst = np.max(imgstack, axis=0)
        hoechst = hoechst**gamma

        imgstack = load_image_series(
            path=imgdir, imgfiles=[w for w in wfiles if 'ch2' in w])
        ly = np.max(imgstack, axis=0)
        ly = ly**gamma

        well_df = eval_df[eval_df['wellpos'] == wellpos]
        if well_df.shape[0]:
            rmax, cmax = hoechst.shape
            bbox = read_bbox(df=well_df,
                             rmax=rmax,
                             cmax=cmax,
                             columns=['ymin', 'xmin', 'ymax', 'xmax'],
    well_id = int(sys.argv[3])-1

    fnames = [f for f in os.listdir(platedir) if '.tiff' in f]
    all_wells = list(set([re.search('r[0-9]+c[0-9]+',f).group(0) for f in fnames]))
    all_wells.sort()
    
    well = all_wells[well_id]
    well_imgs = [f for f in fnames if well in f and 'ch2' not in f]

    gamma = 0.5
    pad = 5
    
    imgdata = []
    for i in range(1,5):
        wellpos = [f for f in well_imgs if 'f0' + str(i)+ 'p' in f]
        imgseries = load_image_series(path=platedir, imgfiles=wellpos)
        imgseries = imgseries.reshape((8, 4, 2160,2160))
        mipseries = np.amax(imgseries, axis=0)
        hoechst = mipseries[0]
        
        img_th = threshold_img(hoechst**gamma, method='otsu', binary=False)
        img_s = shape_index(img_th)
        img_enh = nantonum(img_s, pad=-1)
        # run blob detection on the shape-index enhanced image
        blobs = blob_log(img_enh,
                         min_sigma=10,
                         max_sigma=14,
                         threshold=0.05)
        if len(blobs):
            bbox = np.stack([np.array([bl[1] - bl[2] - pad,
                               bl[1] + bl[2] + pad,