def resample_image_set(resampler, images_array, targets_array, x_reshape = False, y_reshape = False):
    """Perform resampling on a given numpy array of images and targets (classes), return resampled array's

    Parameters
    ----------
    resampler: object
        resampler from imblearn.under_sampling or imblearn.over_sampling
        implementing fit_resample. Can be accessed via imresample.resample_strategies.
    
    images_array: {array-like, sparse matrix}, shape (n_samples, n_images)
            Data array.
    
    targets_array: array-like, shape (n_samples,)
            Target array.
    
    x_reshape: boolean, optional (default=False)
        dictates whether reshaping of images array from 4 dimensions to 2 dimensions should occur
        (for imblearn resampler images array must be <=2 dimensions)
    
    y_reshape: boolean, optional (default=False)
        dictates whether reshaping of targets array should take place
        shape must be (n_samples,)

     Returns
        -------
        X_resampled : {ndarray, sparse matrix}, shape (n_samples_new, n_images_new)
            The array containing the resampled data.

        y_resampled : ndarray, shape (n_samples_new,)
            The corresponding label of `X_resampled`
    """


    if x_reshape:
        images_array = images_array.reshape(images_array.shape[0], images_array.shape[1]*images_array.shape[2]*images_array.shape[3])
    if y_reshape:
        targets_array = targets_array.reshape(-1,1)

    return resampler.fit_resample(images_array, targets_array)