I am trying to use scipy.ndimage.generic_filter1d for the first time, but it's not going well. Here's what I'm trying
import numpy as np
from scipy.ndimage import generic_filter1d
def test(x):
return x.sum()
im_cube = np.zeros((100,100,100))
calc = generic_filter1d(im_cube, test, filter_size=5, axis=2)
But I get this error:
TypeError: test() takes 1 positional argument but 2 were given
I'm using scipy 1.4.1 What am I doing wrong?
For the function, I also tried np.mean but then I got this:
TypeError: only integer scalar arrays can be converted to a scalar index