CellProfiler / CellProfiler-plugins

Community-contributed and experimental CellProfiler modules.
http://plugins.cellprofiler.org/
54 stars 65 forks source link

CalculateMoments run error #207

Open ErinWeisbart opened 1 year ago

ErinWeisbart commented 1 year ago

TypeError: 'numpy.float64' object cannot be interpreted as an integer

wllgrnt commented 7 months ago

This is happening for us too, in the below code on line 53 of calculatemoments.py:

def get_object_moment(pixels, func):
    labs = np.unique(pixels)
    moms = np.zeros([np.max(labs) + 1, 1])
    for l in labs:
        if l != 0:
            px = pixels[np.where(pixels == l)]
            moms[l] = func(px)
    return moms

pixels is an array of floats 0-1, so np.max(labs) is a float and the np.zeros falls over.