Closed nfahlgren closed 1 year ago
In my opinion if there is no plant but the user supplied an ROI then analyze_* should return 0 instead of NA since that is a valid size. That's what I would expect anyway.
From: Noah Fahlgren notifications@github.com Sent: Saturday, March 6, 2021 15:40 To: danforthcenter/plantcv plantcv@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [danforthcenter/plantcv] Update PlantCV to output NA values when no plant/object is detected (#711)
Is your feature request related to a problem? Please describe. @kmurphy61https://urldefense.com/v3/__https:/github.com/kmurphy61__;!!JmPEgBY0HMszNaDT!_znXoYOrQSdZbLgDdtjfLOD0l8l0-cnreWzVvHaE39WFVIiTm8GsRYsyMd63od_CPonAZw$ described the issue well in #710https://urldefense.com/v3/__https:/github.com/danforthcenter/plantcv/discussions/710__;!!JmPEgBY0HMszNaDT!_znXoYOrQSdZbLgDdtjfLOD0l8l0-cnreWzVvHaE39WFVIiTm8GsRYsyMd63od-tX0EexA$. Currently, when no plant or object is detected, PlantCV will not output measurements, even with missing values, for that plant or image. Unless the user adds a logical check, parts of a typical PlantCV workflow will actually trigger a fatal error and stop the workflow. In a multi-plant or other multi-object workflow, this could prevent data collection for the entire image, even if only one plant were missing.
Describe the solution you'd like pcv.object_composition currently evaluates whether the length of the input contours is greater than zero, and if the length is zero (no plant detected), it returns two None values. But these None values are different data types from what is normally returned, a list of contours and a numpy.ndarray for a mask. The first change we could make is to return an empty list and and mask so that the data types match what is expected downstream.
Next, the pcv.analyze_* functions would need to be updated to output "NA" values when no plant is detected.
Functions to update:
Others? The morphology subpackage functions might be complicated @HaleySchuhlhttps://urldefense.com/v3/__https:/github.com/HaleySchuhl__;!!JmPEgBY0HMszNaDT!_znXoYOrQSdZbLgDdtjfLOD0l8l0-cnreWzVvHaE39WFVIiTm8GsRYsyMd63od-kd8Fwfw$?
Describe alternatives you've considered I think this is the most straightforward route, but definitely feel free to propose alternatives.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/danforthcenter/plantcv/issues/711__;!!JmPEgBY0HMszNaDT!_znXoYOrQSdZbLgDdtjfLOD0l8l0-cnreWzVvHaE39WFVIiTm8GsRYsyMd63od9p-j1MEQ$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/ABY5SZNNSDBOGXW7U7Q66RTTCK4OFANCNFSM4YXHHB7Q__;!!JmPEgBY0HMszNaDT!_znXoYOrQSdZbLgDdtjfLOD0l8l0-cnreWzVvHaE39WFVIiTm8GsRYsyMd63od-jYRN_TA$.
True, that makes sense. It would solve an issue with the datatype as well, where "NA" is a string but otherwise the data type is an int, float, etc.
Implemented in the branch release-4.0
for all analysis functions.
Is your feature request related to a problem? Please describe. @kmurphy61 described the issue well in #710. Currently, when no plant or object is detected, PlantCV will not output measurements, even with missing values, for that plant or image. Unless the user adds a logical check, parts of a typical PlantCV workflow will actually trigger a fatal error and stop the workflow. In a multi-plant or other multi-object workflow, this could prevent data collection for the entire image, even if only one plant were missing.
Describe the solution you'd like
pcv.object_composition
currently evaluates whether the length of the input contours is greater than zero, and if the length is zero (no plant detected), it returns twoNone
values. But theseNone
values are different data types from what is normally returned, alist
of contours and anumpy.ndarray
for a mask. The first change we could make is to return an emptylist
and and mask so that the data types match what is expected downstream.Next, the
pcv.analyze_*
functions would need to be updated to output "NA" values when no plant is detected.Functions to update:
pcv.object_composition
pcv.analyze_bound_horizontal
pcv.analyze_bound_vertical
pcv.analyze_color
pcv.analyze_nir_intensity
pcv.analyze_object
pcv.analyze_thermal_values
pcv.hyperspectral.analyze_index
pcv.hyperspectral.analyze_spectral
pcv.photosynthesis.analyze_fvfm
Others? The morphology subpackage functions might be complicated @HaleySchuhl?
Describe alternatives you've considered I think this is the most straightforward route, but definitely feel free to propose alternatives.