Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update hyperspectral calibration function #845

Merged
merged 6 commits into from
Dec 9, 2021

Conversation

nfahlgren
Copy link
Member

Describe your changes
In evaluating pcv.hyperspectral.calibrate to address #843, a couple issues were found.

First, the original function was written assuming that the shape of the input dark and white reference images was (1, x, z) since this matched the data we worked with. @JorgeGtz noted that reference data provided in #843 had the shape (100, x, z), which caused the "memory" errors. To normalize the process for reference images with different numbers of line scans, the function is updated to average the lines (axis=0) and convert all reference inputs to the shape (1, x, z), which can be broadcast over the raw data cube shape.

Second, we realized that the calibration was done in two stages that were not connected, resulting in incorrectly calibrated output. The function was updated/simplified to do the calibration in a single vectorized operation.

Third, because calibrated values can be negative or greater than 1, we added a step to clip the values to the range 0-1. We confirmed that the resulting calibrated data are very similar to data calibrated by the manufacturer.

Last, we updated the function to utilize the _debug module.

Type of update
Is this a: Bug fix

Associated issues
Closes #843

* Average dark and white references over axis 0
* Calculate calibration using vectorized operations
* Clip calibrated values to the range 0 - 1
@nfahlgren nfahlgren added the bugfix Bug fixes label Dec 9, 2021
@nfahlgren nfahlgren added this to the PlantCV v3.14.0 milestone Dec 9, 2021
@nfahlgren nfahlgren added this to In progress in PlantCV3 via automation Dec 9, 2021
@codecov
Copy link

codecov bot commented Dec 9, 2021

Codecov Report

Merging #845 (45b8d17) into master (f1c0981) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #845   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          142       142           
  Lines         6223      6207   -16     
=========================================
- Hits          6223      6207   -16     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
plantcv/plantcv/hyperspectral/calibrate.py 100.00% <100.00%> (ø)

@nfahlgren nfahlgren merged commit d06922d into master Dec 9, 2021
PlantCV3 automation moved this from In progress to Done Dec 9, 2021
@nfahlgren nfahlgren deleted the update-hyper-calibration branch December 9, 2021 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
PlantCV3
  
Done
Development

Successfully merging this pull request may close these issues.

Memory loss during calibration of Hyperspectral Image
2 participants