Skip to content

Commit

Permalink
fix(test): test fixes after shader and limit changes
Browse files Browse the repository at this point in the history
  • Loading branch information
seankmartin committed Oct 9, 2024
1 parent 2dfe36f commit 7923a2a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions tests/test_contrast_limits.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ def test_percentile_contrast_limits():
data = np.arange(100).reshape(10, 5, 2)

calculator = ContrastLimitCalculator(data)
limits = calculator.contrast_limits_from_percentiles(5.0, 95.0)
limits = calculator.compute_contrast_limit(5.0, 95.0)
assert np.allclose(limits, (5.0, 94.0), atol=0.1)

limits = calculator.contrast_limits_from_percentiles(0.0, 100.0)
limits = calculator.compute_contrast_limit(0.0, 100.0)
assert limits == (0.0, 99.0)

# Test with a 3D numpy array with Z as the first axis, and remove some slices
new_data = np.full((30, 5, 2), 500)
new_data[10:20] = data

calculator.volume = new_data
limits = calculator.contrast_limits_from_percentiles(0.0, 100.0)
limits = calculator.compute_contrast_limit(0.0, 100.0)
assert limits == (0.0, 500.0)

calculator.set_volume_and_z_limits(new_data, z_radius=5)
limits = calculator.contrast_limits_from_percentiles(0.0, 100.0)
limits = calculator.compute_contrast_limit(0.0, 100.0)
assert limits == (0.0, 99.0)


Expand Down
6 changes: 3 additions & 3 deletions tests/test_shader.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ def test_get_default_image_vr_shader():
contrast_name = "contrast"
threedee_contrast_name = "contrast3D"
expected_shader = """
#uicontrol invlerp contrast(clamp=false)
#uicontrol invlerp contrast
#uicontrol bool invert_contrast checkbox
#uicontrol invlerp contrast3D(clamp=false)
#uicontrol bool invert_contrast3D checkbox
#uicontrol bool hide_white_outside_range_3D checkbox
#uicontrol bool hide_values_outside_limits_3D checkbox
float get_contrast() {
float value = invert_contrast ? 1.0 - contrast() : contrast();
return value;
}
float get_contrast3D() {
float value = invert_contrast3D ? 1.0 - contrast3D() : contrast3D();
value = (hide_white_outside_range_3D && value > 1.0) ? 0.0 : clamp(value, 0.0, 1.0);
value = (hide_values_outside_limits_3D && value > 1.0) ? 0.0 : clamp(value, 0.0, 1.0);
return value;
}
Expand Down

0 comments on commit 7923a2a

Please # to comment.