allen-cell-animated / volume-viewer

https://allen-cell-animated.github.io/volume-viewer/
Other
92 stars 7 forks source link

Fix/handle same min-max values in lutGenerator_minMax #33

Closed schoinh closed 3 years ago

schoinh commented 3 years ago

This should fix the bug we're currently seeing in CFE / website-3d-cell-viewer: website-3d-cell-viewer crashes when trying to view volume settings for contour channels

Cause of bug:

NaN values getting passed in as control points. The NaN values were coming from divisions by zero that were happening in the case where the min and max values passed into the min-max lookup table generator (lutGenerator_minMax in Histogram.ts) were equal. The direct lookup table generation was handling the case where min = max (b === e) but the code that generates control points was not handling that case.

Solution:

Add more assertions to tests to check that no NaN values are generated, and modify control point generation logic to deal with min and max values being equal (avoid division by zero and create a step function with an almost vertical slope)

Other changes:

@toloudis and I worked on this together.

Pull request recommendations:

Thanks for contributing!