def ReconstructSpatialLFPatch(LFpatch, model, inputs, is_training, session, args, stride=60, border=(3, 3)):
    """
    Spatial reconstruct for a LF patch.

    :param LFpatch:     input LF patch
    :param model:       network
    :param inputs:      inputs of the network
    :param is_training: scala tensor to indicate whether need training
    :param session:     tensorflow session
    :param args:        arguments
    :param stride:      stride for reconstruction
    :param border:      shaved border of the final reconstructed LF patch

    :return:            reconstructed LF patch (border shaved)
    """
    recons_indices = get_indices(LFpatch, rs=args.gamma_S, patchsize=args.patchSize, stride=stride)
    inPatches, _ = LF_split_patches(LFpatch, patchsize=args.patchSize, stride=stride)
    reconPatches = []
    for i in tqdm(range(len(inPatches))):
        in_patch = inPatches[i]
        recon_patch = session.run(model.Recons, feed_dict={inputs: in_patch, is_training: False})
        reconPatches.append(recon_patch)

    reconsPatch_shaved = shaved_LF_reconstruct(reconPatches, recons_indices, border=border)

    reconsPatch_shaved[reconsPatch_shaved > 1.] = 1.
    reconsPatch_shaved[reconsPatch_shaved < 0.] = 0.
    return reconsPatch_shaved
def get_indices(data, rs=4, patchsize=96, stride=30):
    """
    Calculate the indices for the splited LF patches.

    :param data:      input LF data
    :param rs:        upsampling factor
    :param patchsize: split size
    :param stride:    stride for spliting

    :return:          indices for all splited LF patches
    """
    b, h, w, s, t, c = data.shape
    recons_template = np.zeros([b, h*rs, w*rs, s, t, c])
    _, indices = LF_split_patches(recons_template, patchsize=patchsize, stride=stride)
    return indices