def CreateHyperspectralImageRectangular(embedding, array_size, coordinates, scale=True):
    """Fill a hyperspectral image from n-dimensional embedding of high-dimensional
    imaging data by rescaling each channel from 0-1 (optional). All coordinates
    in the image not listed in coordinates object will be masked
    and set to 0 (background). This function assumes that the data you want
    to reconstruct can be automatically reshaped into a rectangular array.

    Parameters
    ----------
    embedding: Pandas DataFrame
        Indicates embedding coordinates from UMAP or another method.

    array_size: tuple
        Indicates size of image.

    coordinates: 1-indexed list of tuples
        Indicates pixel coordinates of image.

    scale: Bool (Default: True)
        Rescale pixel intensities on the range of 0-1.

    Returns
    -------
    im: array
        Reconstructed image.
    """

    # get the embedding shape
    number_channels = embedding.shape[1]
    # Create zeros array to fill with number channels equal to embedding dimension
    im = embedding.values.reshape((array_size[0], array_size[1], number_channels))

    # Check to see if scaling the pixel values 0 to 1
    if scale:
        # Scale the data 0-1 for hyperspectral image construction
        for dim in range(im.shape[2]):
            # min-max scaler
            im[:, :, dim] = (im[:, :, dim] - im[:, :, dim].min()) / (
                im[:, :, dim].max() - im[:, :, dim].min()
            )

    # Return the hyperspectral image
    return im