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

Write hyperspectral data #889

Merged
merged 16 commits into from
Jun 16, 2022
Merged

Write hyperspectral data #889

merged 16 commits into from
Jun 16, 2022

Conversation

JorgeGtz
Copy link
Contributor

Describe your changes
Add the functionality to write ENVI-format hyperspectral images.

Type of update
Is this a:

  • New feature or feature enhancement

Associated issues

Additional context

@JorgeGtz JorgeGtz changed the base branch from master to 4.x May 10, 2022 18:25
@codecov
Copy link

codecov bot commented May 10, 2022

Codecov Report

Merging #889 (a3c8f8f) into 4.x (6319617) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##               4.x      #889   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          158       159    +1     
  Lines         6697      6725   +28     
=========================================
+ Hits          6697      6725   +28     
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/__init__.py 100.00% <100.00%> (ø)
plantcv/plantcv/hyperspectral/write_data.py 100.00% <100.00%> (ø)

@JorgeGtz JorgeGtz added new feature New feature ideas and solutions ready to review labels May 11, 2022
@JorgeGtz JorgeGtz added this to Pull Requests in PlantCV4 via automation May 11, 2022
@JorgeGtz JorgeGtz added this to the PlantCV v4.x milestone May 11, 2022
@JorgeGtz JorgeGtz removed this from Pull Requests in PlantCV4 May 11, 2022
@JorgeGtz JorgeGtz added this to Pull Requests in PlantCV4 via automation May 11, 2022
@HaleySchuhl
Copy link
Contributor

This might be somewhat nit-picky, but I think that the parameters should be in the reverse order to match the style of other pcv writing functions that generally have the img data first, followed by the filename.

docs/write_data.md Outdated Show resolved Hide resolved
docs/write_data.md Outdated Show resolved Hide resolved

# Read written hyperspectral image
array_data = read_data(filename=filename)
assert np.shape(array_data.array_data) == (lines, samples, bands)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would going beyond checking if the dimensions are the same to see if some of the values are the same be helpful? Or is just checking that they're the same shape usually sufficient

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a good question. We could check some values or also verify that it's the exact array. I think it depends on what can go wrong. Since the array is vectorized and written as a binary array, in order to have the correct dimensions the data type and the interleave format should be correct.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok cool, would just a simple assert np.array_equal(array_data.array_data, rand_spectral_array) be good or do you think that would take up more time than it's worth?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think both ways are good options


# Read written hyperspectral image
array_data = read_data(filename=filename)
assert np.shape(array_data.array_data) == (lines, samples, bands)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would going beyond checking if the dimensions are the same to see if some of the values are the same be helpful? Or is just checking that they're the same shape usually sufficient

docs/write_data.md Outdated Show resolved Hide resolved
docs/write_data.md Outdated Show resolved Hide resolved
plantcv/plantcv/hyperspectral/write_data.py Outdated Show resolved Hide resolved
tests/plantcv/hyperspectral/test_write_data.py Outdated Show resolved Hide resolved

# Read written hyperspectral image
array_data = read_data(filename=filename)
assert np.shape(array_data.array_data) == (lines, samples, bands)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok cool, would just a simple assert np.array_equal(array_data.array_data, rand_spectral_array) be good or do you think that would take up more time than it's worth?

Copy link
Contributor

@jdavidpeery jdavidpeery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good then

@HaleySchuhl HaleySchuhl merged commit bf4e52b into 4.x Jun 16, 2022
PlantCV4 automation moved this from Pull Requests to Done Jun 16, 2022
@HaleySchuhl HaleySchuhl deleted the write-hyperspectral-data branch June 16, 2022 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature ideas and solutions ready to review
Projects
PlantCV4
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants