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 color of targets and center #279

Merged
merged 8 commits into from
Nov 19, 2024
Merged
8 changes: 6 additions & 2 deletions src/vstt/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,11 @@ def _do_target(
mouse_pos = tm.cursor.pos
stop_waiting_time = 0.0
stop_target_time = 0.0
tm.green_target_index = None
tm.green_target_index = (
tm.green_target_index
if tm.green_target_index == trial["num_targets"]
else None
)
ZoeJacky marked this conversation as resolved.
Show resolved Hide resolved
if trial["fixed_target_intervals"]:
num_completed_targets = len(trial_data.to_target_timestamps)
stop_waiting_time = (num_completed_targets + 1) * trial[
Expand Down Expand Up @@ -320,7 +324,7 @@ def _do_target(
tm.targets,
trial["show_inactive_targets"],
None,
tm,
tm.green_target_index,
)
if trial["show_target_labels"] and tm.target_labels is not None:
vis.update_target_label_colors(
Expand Down
2 changes: 1 addition & 1 deletion src/vstt/trial.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def default_trial() -> Trial:
"target_indices": "0 1 2 3 4 5 6 7",
"add_central_target": True,
"hide_target_when_reached": True,
"turn_target_to_green_when_reached": True,
"turn_target_to_green_when_reached": False,
"show_target_labels": False,
"target_labels": "0 1 2 3 4 5 6 7",
"fixed_target_intervals": False,
Expand Down
7 changes: 3 additions & 4 deletions src/vstt/vis.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from vstt.stats import get_closed_polygon
from vstt.stats import list_dest_stat_label_units
from vstt.stats import stats_dataframe
from vstt.task import TrialManager
from vstt.vtypes import DisplayOptions
from vstt.vtypes import Metadata

Expand Down Expand Up @@ -102,7 +101,7 @@ def update_target_colors(
targets: ElementArrayStim,
show_inactive_targets: bool,
index: int | None = None,
tm: TrialManager | None = None,
green_target_index: int | None = None,
) -> None:
inactive_rgb = 0.0
if show_inactive_targets:
Expand All @@ -111,9 +110,9 @@ def update_target_colors(
if index is not None:
# Set specified target to red
c[index] = [1, -1, -1]
if tm is not None and tm.green_target_index is not None:
if green_target_index is not None:
# Set specified target to green
c[tm.green_target_index] = [-1, 1, -1]
c[green_target_index] = [-1, 1, -1]
targets.setColors(c, colorSpace="rgb")


Expand Down
1 change: 1 addition & 0 deletions tests/test_trial.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def test_import_trial() -> None:
"add_central_target": True,
"show_target_labels": False,
"hide_target_when_reached": True,
"turn_target_to_green_when_reached": False,
"target_labels": "0 1 2 3 4 5",
"fixed_target_intervals": False,
"target_duration": 3,
Expand Down
Loading