plantcv icon indicating copy to clipboard operation
plantcv copied to clipboard

ROI Autogrid does not work with germination studies

Open Stylopidae1793 opened this issue 1 year ago • 2 comments

The ROI autogrid function throws errors at early timepoints in germination studies due to trays which do not have plants in them.

Stylopidae1793 avatar Jan 05 '24 15:01 Stylopidae1793

auto_grid relies on empirical data to set the grid, so if there are no plants there is no way to set the grid with this method

nfahlgren avatar Jan 05 '24 15:01 nfahlgren

Other possible solutions?

  • Canny edge detect the tray itself and be able to define grid of cells based on tray location
  • tape markers on corners (to help determine corners of the tray or actually marking rows & columns) and then be able to define grid
  • same idea but QR codes?

My thought to make a mask of the cells using the soil does not seem promising. Understandably, the pixel values of wet vs dry soil differ in basically all grayscale colorspaces and the tray design itself is prone to connectivity of cells, and I think this connectivity plus the extra noise is causing auto_grid to fail. image

---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)
Cell In[57], line 8
      6 sub_mask = pcv.image_subtract(gray_img1=thresh, gray_img2=roi_mask)
      7 filled = pcv.fill_holes(sub_mask)
----> 8 rois = pcv.roi.auto_grid(mask=filled, nrows=6, ncols=7, radius=100, img=img)

File ~/plantcv/plantcv/plantcv/roi/roi_methods.py:322, in auto_grid(mask, nrows, ncols, radius, img)
    320 if len(np.unique(mask)) != 2:
    321     fatal_error("Input binary mask is not binary!")
--> 322 coord, spacing = _calculate_grid(mask, nrows, ncols)
    323 if img is None:
    324     img = mask

File ~/plantcv/plantcv/plantcv/roi/roi_methods.py:194, in _calculate_grid(mask, nrows, ncols)
    192 for c in contours:
    193     m = cv2.moments(c)
--> 194     cmx, cmy = (float(m['m10'] / m['m00']), float(m['m01'] / m['m00']))
    195     centers.append((cmx, cmy))
    196 # cluster by x and y coordinates to get grid layout

ZeroDivisionError: float division by zero

HaleySchuhl avatar Jan 05 '24 22:01 HaleySchuhl