Skip to content

Commit

Permalink
Issue #100 tidied up output so we can get results as we go
Browse files Browse the repository at this point in the history
  • Loading branch information
thompson318 committed Jul 12, 2022
1 parent be375ca commit cc0d074
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
8 changes: 4 additions & 4 deletions sksurgerybard/visualisation/bard_visualisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,11 @@ def luminance_change_left(self, y_pos):
return
actor_index = len(self._target_anatomy_actors) - 2
if actor_index >= 0:
target_colour = get_green(y_pos)
luminance, target_colour = get_green(y_pos)
self._target_anatomy_actors[
actor_index].GetProperty().SetColor(target_colour)
print(f"Changing luminance for actor {actor_index} to ",
f"{target_colour}")
f"{luminance}, RGB={target_colour}", flush=True)

def luminance_change_right(self, y_pos):
"""
Expand All @@ -265,11 +265,11 @@ def luminance_change_right(self, y_pos):
if len(self._target_anatomy_actors) < 1:
return
actor_index = len(self._target_anatomy_actors) - 1
target_colour = get_yellow(y_pos)
luminance, target_colour = get_yellow(y_pos)
self._target_anatomy_actors[
actor_index].GetProperty().SetColor(target_colour)
print(f"Changing luminance for actor {actor_index} to ",
f"{target_colour}")
f"{luminance}, RGB={target_colour}", flush=True)

def next_target(self):
"""
Expand Down
6 changes: 4 additions & 2 deletions sksurgerybard/visualisation/colours.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ def integer_colour_to_float(colour):

def get_green(y_pos):
"""Gets a green shade with luminace set by y_pos"""
return integer_colour_to_float(green.get(y_pos_to_luminance(y_pos)))
luminance = y_pos_to_luminance(y_pos)
return luminance, integer_colour_to_float(green.get(luminance))

def get_yellow(y_pos):
"""Gets a yellow shade with luminace set by y_pos"""
return integer_colour_to_float(yellow.get(y_pos_to_luminance(y_pos)))
luminance = y_pos_to_luminance(y_pos)
return luminance, integer_colour_to_float(yellow.get(luminance))
4 changes: 2 additions & 2 deletions tests/visualisation/test_colours.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def test_integer_colour_to_float():

def test_get_yellow():
"""Checks that get yellow returns the right value"""
assert cls.get_yellow(1.0) == [1.0, 1.0, 1.0]
assert cls.get_yellow(1.0)[1] == [1.0, 1.0, 1.0]

def test_get_green():
"""Checks that get green returns the right value"""
assert cls.get_green(1.0) == [1.0, 1.0, 1.0]
assert cls.get_green(1.0)[1] == [1.0, 1.0, 1.0]

0 comments on commit cc0d074

Please sign in to comment.