Skip to content

Commit

Permalink
Merge pull request #666 from danforthcenter/remaining_analysis_fxn_la…
Browse files Browse the repository at this point in the history
…bel_updates

Remaining analysis fxn label updates
  • Loading branch information
nfahlgren authored Feb 13, 2021
2 parents b9a3a92 + 6bb9450 commit 794af42
Show file tree
Hide file tree
Showing 80 changed files with 7,047 additions and 457 deletions.
11 changes: 6 additions & 5 deletions docs/acute_vertex.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Perform a heuristic search for sharp angles given an object contour and user specified parameters. The acute (sharp)
angles are often associated with object tip points. Outputs a python list of points that meet criteria specified in parameters.

**plantcv.acute_vertex**(*img, obj, window, thresh, sep*)
**plantcv.acute_vertex**(*img, obj, window, thresh, sep, label="default"*)

**returns** list of points that meet specified criteria, image with points selected

Expand All @@ -13,6 +13,7 @@ angles are often associated with object tip points. Outputs a python list of poi
- window - The pre and post point distances on which to calculate angle of focal point (a value of 30 worked well for a sample image) on which to calculate the angle
- thresh - Threshold to set for acuteness; keep points with an angle more acute than the threshold (a value of 15 worked well for sample image)
- sep - The number of contour points to search within for the most acute value
- label - Optional label parameter, modifies the variable name of observations recorded. (default `label="default"`)
- **Context:**
- Used to identify tip points based upon the angle between focal pixel and reference points on contour.
- **Output data stored:** Data ('tip_coordinates') automatically gets stored to the [`Outputs` class](outputs.md) when this function is ran.
Expand All @@ -32,11 +33,11 @@ pcv.params.debug = "print"

# Identify acute vertices (tip points) of an object
# Results in set of point values that may indicate tip points
list_of_acute_points, points_img = pcv.acute_vertex(img, obj, 30, 15, 100)
`
list_of_acute_points, points_img = pcv.acute_vertex(img=img, obj=obj, window=30, thresh=15, sep=100, label="default")

# Access data stored out from acute_vertex
vertices = pcv.outputs.observations['tip_coordinates']['value']
`
vertices = pcv.outputs.observations['default']['tip_coordinates']['value']

```

**Image of points selected**
Expand Down
7 changes: 4 additions & 3 deletions docs/analyze_NIR_intensity.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This function calculates the intensity of each pixel associated with the plant and writes
the values out to the [Outputs class](outputs.md). Can also return/plot/print out a histogram plot of pixel intensity.

**plantcv.analyze_nir_intensity**(*gray_img, mask, bins=256, histplot=False*)
**plantcv.analyze_nir_intensity**(*gray_img, mask, bins=256, histplot=False, label="default"*)

**returns** Histogram image (when histplot is `True`, otherwise returns `None` object)

Expand All @@ -12,6 +12,7 @@ the values out to the [Outputs class](outputs.md). Can also return/plot/print ou
- mask - Binary mask made from selected contours
- bins - Number of NIR intensity value groups (default bins = 256)
- histplot - If True plots histogram of intensity values (default histplot = False)
- label - Optional label parameter, modifies the variable name of observations recorded. (default `label="default"`)
- **Context:**
- Near Infrared pixel frequencies within a masked area of an image.
- **Example use:**
Expand All @@ -33,10 +34,10 @@ from plantcv import plantcv as pcv
pcv.params.debug = "print"

# Caclulates the proportion of pixels that fall into a signal bin and writes the values to a file. Also provides a histogram of this data
analysis_image = pcv.analyze_nir_intensity(gray_img, mask, 256, histplot=True)
analysis_image = pcv.analyze_nir_intensity(gray_img, mask, 256, histplot=True, label="default")

# Access data stored out from analyze_nir_intensity
nir_frequencies = pcv.outputs.observations['nir_frequencies']['value']
nir_frequencies = pcv.outputs.observations['default']['nir_frequencies']['value']

```

Expand Down
7 changes: 4 additions & 3 deletions docs/analyze_bound_horizontal.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Set boundary line with boundary tool, this allows the user to find the extent-y
above and below as well as the area above and below the boundary line. This tool functions
best if the pot size/position of the plant remains relatively constant.

**plantcv.analyze_bound_horizontal**(*img, obj, mask, line_position*)
**plantcv.analyze_bound_horizontal**(*img, obj, mask, line_position, label="default"*)

**returns** image with boundary data

Expand All @@ -13,6 +13,7 @@ best if the pot size/position of the plant remains relatively constant.
- obj - single or grouped contour object
- mask - binary mask of selected contours
- line_position - position of boundary line (a value of 0 would draw the line through the top of the image)
- label - Optional label parameter, modifies the variable name of observations recorded. (default `label="default"`)
- **Context:**
- Used to define a boundary line for the image, to find the height above and below as well as area above and below a boundary line.
- **Example use:**
Expand All @@ -30,10 +31,10 @@ from plantcv import plantcv as pcv
pcv.params.debug = "print"

# Set Boundary Line
boundary_image = pcv.analyze_bound_horizontal(img=img, obj=obj, mask=bin_mask, line_position=300)
boundary_image = pcv.analyze_bound_horizontal(img=img, obj=obj, mask=bin_mask, line_position=300, label="default")

# Access data stored out from analyze_bound_horizontal
percent_area_below_reference = pcv.outputs.observations['percent_area_below_reference']['value']
percent_area_below_reference = pcv.outputs.observations['default']['percent_area_below_reference']['value']

```

Expand Down
7 changes: 4 additions & 3 deletions docs/analyze_bound_vertical.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Set boundary line with boundary tool, this allows the user to find the extent-x
to the right and to the left as well as the area to the right and to the left of the set boundary line. This tool functions
best if the pot size/position of the plant remains relatively constant.

**plantcv.analyze_bound_vertical**(*img, obj, mask, line_position*)
**plantcv.analyze_bound_vertical**(*img, obj, mask, line_position, label="default"*)

**returns** image with boundary data

Expand All @@ -13,6 +13,7 @@ best if the pot size/position of the plant remains relatively constant.
- obj - single or grouped contour object
- mask - binary mask of selected contours
- line_position - position of boundary line (a value of 0 would draw the line through the left of the image)
- label - Optional label parameter, modifies the variable name of observations recorded. (default `label="default"`)
- **Context:**
- Used to define a boundary line for the image, to find the width to the right and to the left as well as area to the right and to the left of a boundary line.
- **Example use:**
Expand All @@ -30,10 +31,10 @@ from plantcv import plantcv as pcv
pcv.params.debug = "print"

# Set Boundary Line
boundary_image = pcv.analyze_bound_vertical(img=img, obj=obj, mask=bin_mask, line_position=1000)
boundary_image = pcv.analyze_bound_vertical(img=img, obj=obj, mask=bin_mask, line_position=1000, label="default")

# Access data stored out from analyze_bound_vertical
area_right_reference = pcv.outputs.observations['area_right_reference']['value']
area_right_reference = pcv.outputs.observations['default']['area_right_reference']['value']

```

Expand Down
7 changes: 4 additions & 3 deletions docs/analyze_color.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

Extract color data of objects and produce pseudocolored images, can extract data for RGB (Red, Green, Blue), HSV (Hue, Saturation, Value) and LAB (Lightness, Green-Magenta, Blue Yellow) channels.

**plantcv.analyze_color**(*rgb_img, mask, hist_plot_type=None*)
**plantcv.analyze_color**(*rgb_img, mask, hist_plot_type=None, label="default"*)

**returns** Histogram image (if hist_plot_type is not `None`, otherwise returns `None` object)

- **Parameters:**
- rgb_img - RGB image data
- mask - binary mask of selected contours
- hist_plot_type - None (default), 'all', 'rgb', 'lab', or 'hsv'. This can limit the data saved out. Hue data is still saved out when set to None.
- label - Optional label parameter, modifies the variable name of observations recorded. (default `label="default"`)
- **Context:**
- Used to extract color data from RGB, LAB, and HSV color channels.
- Generates histogram of color channel data.
Expand All @@ -35,10 +36,10 @@ pcv.params.debug = "print"

# Analyze Color

analysis_image = pcv.analyze_color(rgb_img=rgb_img, mask=mask, hist_plot_type='all')
analysis_image = pcv.analyze_color(rgb_img=rgb_img, mask=mask, hist_plot_type='all', label="default")

# Access data stored out from analyze_color
hue_circular_mean = pcv.outputs.observations['hue_circular_mean']['value']
hue_circular_mean = pcv.outputs.observations['default']['hue_circular_mean']['value']

```

Expand Down
7 changes: 4 additions & 3 deletions docs/analyze_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This function calculates the spectral index statistics and writes the values as observations out to the
[Outputs class](outputs.md).

**plantcv.hyperspectral.analyze_index**(*index_array, mask, histplot=False, bins=100, min_bin=0, max_bin=1*)
**plantcv.hyperspectral.analyze_index**(*index_array, mask, histplot=False, bins=100, min_bin=0, max_bin=1, label="default"*)

**returns** None

Expand All @@ -14,7 +14,8 @@ This function calculates the spectral index statistics and writes the values as
- bins - Optional, number of classes to divide spectrum into (default bins=100)
- min_bin - Optional, minimum bin label. Default of 0 will be used for the smallest bin label while calculating pixel frequency data unless otherwise defined.
`min_bin="auto"` will set minimum bin to the smallest observed pixel value within the masked index provided.
- max_bin - Optional, maximum bin label. Default of 1 will be used for the maximum bin label unless otherwise defined. `max_bin="auto"` will set maximum bin to the largest observed pixel value within the masked index provided.
- max_bin - Optional, maximum bin label. Default of 1 will be used for the maximum bin label unless otherwise defined. `max_bin="auto"` will set maximum bin to the largest observed pixel value within the masked index provided.
- label - Optional label parameter, modifies the variable name of observations recorded

- **Context:**
- Calculates data about mean, median, and standard deviation of an input index within a masked region.
Expand All @@ -30,7 +31,7 @@ This function calculates the spectral index statistics and writes the values as

from plantcv import plantcv as pcv

pcv.hyperspectral.analyze_index(index_array=ndvi_index, mask=leaf_mask, histplot=True, bins=100, min_bin=0, max_bin="auto")
pcv.hyperspectral.analyze_index(index_array=ndvi_index, mask=leaf_mask, histplot=True, bins=100, min_bin=0, max_bin="auto", label="default")

```

Expand Down
9 changes: 5 additions & 4 deletions docs/analyze_shape.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@

Shape analysis outputs numeric properties for an input object (contour or grouped contours), works best on grouped contours.

**plantcv.analyze_object**(*img, obj, mask*)
**plantcv.analyze_object**(*img, obj, mask, label="default"*)

**returns** analysis_image

- **Parameters:**
- img - RGB or grayscale image data for plotting.
- obj - Single or grouped contour object.
- mask - Binary image to use as mask for moments analysis.
- label - Optional label parameter, modifies the variable name of observations recorded. (default `label="default"`)
- **Context:**
- Used to output shape characteristics of an image, including height, object area, convex hull, convex hull area,
perimeter, extent x, extent y, longest axis, centroid x coordinate, centroid y coordinate, in bounds QC (if object
touches edge of image, image is flagged).
- **Example use:**
- [Use In VIS Tutorial](vis_tutorial.md)
- [Use In NIR Tutorial](nir_tutorial.md)
- [Use In PSII Tutorial](psII_tutorial.md)
- [Use In PSII Tutorial](psII_tutorial.md)
- **Output data stored:** Data ('area', 'convex_hull_area', 'solidity', 'perimeter', 'width', 'height', 'longest_path', 'center_of_mass,
'convex_hull_vertices', 'object_in_frame', 'ellipse_center', 'ellipse_major_axis', 'ellipse_minor_axis', 'ellipse_angle', 'ellipse_eccentricity')
automatically gets stored to the [`Outputs` class](outputs.md) when this function is ran.
Expand All @@ -38,13 +39,13 @@ pcv.params.debug = "print"

# Characterize object shapes

shape_image = pcv.analyze_object(img, objects, mask)
shape_image = pcv.analyze_object(img=img, obj=objects, mask=mask, label="default")

# Save returned images with more specific naming
pcv.print_image(shape_image, '/home/malia/setaria_shape_img.png')

# Access data stored out from analyze_object
plant_solidity = pcv.outputs.observations['solidity']['value']
plant_solidity = pcv.outputs.observations['default']['solidity']['value']

```

Expand Down
7 changes: 4 additions & 3 deletions docs/analyze_spectral.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
This function calculates the reflectance frequencies associated with a hyperspectral datacube and writes
the values out as observations to get saved out. Can also print out a histogram of average reflectance intensity.

**plantcv.hyperspectral.analyze_spectral**(*array, mask, histplot=False*)
**plantcv.hyperspectral.analyze_spectral**(*array, mask, histplot=False, label="default"*)

**returns** reflectance histogram (if `histplot=True`, otherwise returns None object)

- **Parameters:**
- array - A hyperspectral datacube object, an instance of the `Spectral_data` class (read in with [pcv.readimage](read_image.md) with `mode='envi'`)
- mask - Binary mask made from selected contours
- histplot - If True plots histogram of reflectance intensity values (default histplot = False)
- label - Optional label parameter, modifies the variable name of observations recorded. (default `label="default"`)
- **Example use:**
- Below
- **Output data stored:** Data ('max_reflectance', 'min_reflectance', 'median_reflectance', 'spectral_std', 'spectral_frequencies', 'global_mean_reflectance', 'global_median_reflectance', 'global_spectral_std') automatically gets stored to the
Expand All @@ -27,10 +28,10 @@ from plantcv import plantcv as pcv
pcv.params.debug = "print"

# Calculates reflectance frequencies and writes the values as observations. Also provides a histogram of this data
spectral_hist = pcv.hyperspectral.analyze_spectral(array=spectral_data, mask=mask, histplot=True)
spectral_hist = pcv.hyperspectral.analyze_spectral(array=spectral_data, mask=mask, histplot=True, label="default")

# Access data stored
reflectance_range = max(pcv.outputs.observations['max_reflectance']['value']) - min(pcv.outputs.observations['min_reflectance']['value'])
reflectance_range = max(pcv.outputs.observations['default']['max_reflectance']['value']) - min(pcv.outputs.observations['default']['min_reflectance']['value'])

```

Expand Down
14 changes: 8 additions & 6 deletions docs/analyze_stem.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
Primary, or stem, objects identified during workflows that examine the [morphology](morphology_tutorial.md) of
plants or plant organs can have specific characteristics measured about the stem segments of a skeleton.

**plantcv.morphology.analyze_stem**(*rgb_img, stem_objects*)
**plantcv.morphology.analyze_stem**(*rgb_img, stem_objects, label="default"*)

**returns** labeled_img

- **Parameters:**
- rgb_img - RGB image data for plotting.
- rgb_img - RGB image data for plotting.
- stem_objects - List of stem segments (output from [segment_sort](segment_sort.md) function)
- label - Optional label parameter, modifies the variable name of observations recorded
- **Context:**
- Used to output stem morphological characteristics, including height, angle, and length.
- **Example use:**
Expand All @@ -31,11 +32,12 @@ from plantcv import plantcv as pcv

pcv.params.debug = "print"

stem_debug_img1 = pcv.morphology.analyze_stem(rgb_img=img1, stem_objects=stem_objects1)
stem_debug_img2 = pcv.morphology.analyze_stem(rgb_img=img2, stem_objects=stem_objects2)

stem_debug_img1 = pcv.morphology.analyze_stem(rgb_img=img1, stem_objects=stem_objects1, label="default")
# Access data stored out from analyze_object
stem_angle = pcv.outputs.observations['stem_angle']['value']
stem_angle = pcv.outputs.observations['default']['stem_angle']['value']

stem_debug_img2 = pcv.morphology.analyze_stem(rgb_img=img2, stem_objects=stem_objects2, label="rep1")
stem_angle = pcv.outputs.observations['rep1']['stem_angle']['value']

```

Expand Down
7 changes: 4 additions & 3 deletions docs/analyze_thermal_values.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
This function calculates the intensity of each pixel associated with the temperature and writes
the values out to a file. Can optionally create a histogram of pixel intensity.

**plantcv.analyze_thermal_values**(*thermal_array, mask, histplot=False*)
**plantcv.analyze_thermal_values**(*thermal_array, mask, histplot=False, label="default""default"*)

**returns** thermal histogram (if `histplot=True`, otherwise returns None object)

- **Parameters:**
- thermal_array - Numpy array of thermal image data (most likely read in with [pcv.readimage](read_image.md) with `mode='csv'`)
- mask - Binary mask made from selected contours
- histplot - If True plots histogram of intensity values (default histplot = False)
- label - Optional label parameter, modifies the variable name of observations recorded. (default `label="default"`)
- **Context:**
- Data about image temperature within a masked region.
- **Example use:**
Expand All @@ -33,10 +34,10 @@ from plantcv import plantcv as pcv
pcv.params.debug = "print"

# Caclulates the proportion of pixels that fall into a signal bin and writes the values to a file. Also provides a histogram of this data
thermal_hist = pcv.analyze_thermal_values(thermal_img, mask, histplot=True)
thermal_hist = pcv.analyze_thermal_values(thermal_array=thermal_img, maks=mask, histplot=True, label="default")

# Access data stored out from analyze_thermal_values
temp_range = pcv.outputs.observations['max_temp']['value'] - pcv.outputs.observations['min_temp']['value']
temp_range = pcv.outputs.observations['default']['max_temp']['value'] - pcv.outputs.observations['default']['min_temp']['value']

```

Expand Down
7 changes: 4 additions & 3 deletions docs/check_cycles.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

Check for cycles within a skeletonized image.

**plantcv.morphology.check_cycles**(*skel_img*)
**plantcv.morphology.check_cycles**(*skel_img, label="default"*)

**returns** debugging cycle image

- **Parameters:**
- skel_img - Skeleton image (output from [plantcv.morphology.skeletonize](skeletonize.md))
- label - Optional label parameter, modifies the variable name of observations recorded. (default `label="default"`)
- **Context:**
- Identifies cycles in a skeleton image.
- **Output data stored:** Data ('num_cycles') automatically gets stored to the [`Outputs` class](outputs.md) when this function is ran.
Expand All @@ -29,10 +30,10 @@ pcv.params.debug = "print"
# The cycle_img created for debugging purposes allows for line thickness
# adjustments with the global line thickness parameter. Try setting
# pcv.params.line_thickness = 8 for thicker lines (default 5)
cycle_img = pcv.morphology.check_cycles(skel_img=skeleton)
cycle_img = pcv.morphology.check_cycles(skel_img=skeleton, label="default")

# Access data stored out from check_cycles
num_cycles = pcv.outputs.observations['num_cycles']['value']
num_cycles = pcv.outputs.observations['default']['num_cycles']['value']

```

Expand Down
Loading

0 comments on commit 794af42

Please sign in to comment.