Replies: 2 comments 1 reply
-
Hi @kmurphy61, Agreed, it makes sense to return NA data for missing plants/empty ROI rather than returning no data. I'm going to first post a potential short-term workaround that might help in this situation. Then I will post what steps I think we would need to take to update PlantCV. So in a multi-plant workflow, you would be identifying plant contours and then either defining a region of interest for each pot or clustering the contours into groups, which are ideally plants. For example: # Find plant contours
obj, obj_str = pcv.find_objects(img=img, mask=bin_img)
# Define a grid of ROIs
rois, roi_str = pcv.roi.multi(img=img, coord=(400, 200), radius=150, spacing=(450, 475), nrows=4, ncols=5) At this step we have to loop over the ROIs to 1) select plant contours that overlap each individual ROI, 2) combine the filtered contours into a single plant object, 3) measure plant shape, size, etc. With the recent update to PlantCV in v3.11, we can apply a sample label to each plant and I have been using a plant ID based on the ROI ID (top-left = 0, incremented by 1 from left to right and from top-left to bottom-right) to label each set of measurements. For example: # I make a copy of the original image for visualization purposes
shape_img = img.copy()
# Loop over the ROIs
for i, roi in enumerate(rois):
# Find the contours for the ith plant in the ith ROI
plant_cnt, plant_str, plant_mask, plant_area = pcv.roi_objects(img=img, roi_contour=roi, roi_hierarchy=roi_str[i], object_contour=obj, obj_hierarchy=obj_str)
# PlantCV will break here if the filtered contours are empty, so no measurements will be recorded
if plant_area > 0:
# Combine contours into a single object
plant, mask = pcv.object_composition(img=img, contours=plant_cnt, hierarchy=plant_str)
# Measure the plant shape/size
shape_img = pcv.analyze_object(img=shape_img, obj=plant, mask=mask, label="plant" + str(i))
pcv.plot_image(shape_img) There will only be measurements for plants that were detected, but the IDs are still numbered in a way that accounts for all pots. |
Beta Was this translation helpful? Give feedback.
-
In a PlantCV workflow, the breakpoint that currently prevents us from storing NAs for cases when no plant is detected is the combination of how we deal with an empty contour list in I think to fix the issue we should update Then we would need to make some updates to the |
Beta Was this translation helpful? Give feedback.
-
When processing multi-plant images, PlantCV does not generate info for an ROI that has no plant in it. During downstream processing, I use a metadata file that provides plant labels based on position in the tray, and is thus sorted by the order that PlantCV is detecting a plant. When there is an empty ROI, can PlantCV return an NA or 0 values but still generate a line, so that when the metadata is aligned downstream there is not a misalignment because of an empty ROI?
Example image below, empty pots in the flat should return as "NA" or the plant label (genotype, treatment, etc.) will be mis-aligned to the pot position.
Thank you! - Katie
Beta Was this translation helpful? Give feedback.
All reactions