def crop_center(arr):
    '\n    Finds max element in array and crops the array to be symetrical with regard to this point in each direction.\n    \n    Parameters\n    ----------\n    arr : ndarray\n        an array\n\n    Returns\n    -------\n    centered : ndarray\n        an array symetrical in all dimensions around the max element of input array\n    '
    shape = arr.shape
    center = np.unravel_index(np.argmax(arr, axis=None), shape)
    principium = []
    finis = []
    for i in range(len(shape)):
        half_shape = min(center[i], ((shape[i] - center[i]) - 1))
        principium.append((center[i] - half_shape))
        finis.append(((center[i] + half_shape) + 1))
    centered = arr[principium[0]:finis[0], principium[1]:finis[1], principium[2]:finis[2]]
    return centered
Finds max element in array and crops the array to be symetrical with regard to this point in each direction.

Parameters
----------
arr : ndarray
    an array

Returns
-------
centered : ndarray
    an array symetrical in all dimensions around the max element of input array
def crop_center(arr):
    '\n    Finds max element in array and crops the array to be symetrical with regard to this point in each direction.\n    \n    Parameters\n    ----------\n    arr : ndarray\n        an array\n\n    Returns\n    -------\n    centered : ndarray\n        an array symetrical in all dimensions around the max element of input array\n    '
    shape = arr.shape
    center = np.unravel_index(np.argmax(arr, axis=None), shape)
    principium = []
    finis = []
    for i in range(len(shape)):
        half_shape = min(center[i], ((shape[i] - center[i]) - 1))
        principium.append((center[i] - half_shape))
        finis.append(((center[i] + half_shape) + 1))
    centered = arr[principium[0]:finis[0], principium[1]:finis[1], principium[2]:finis[2]]
    return centered