Skip to content

Commit

Permalink
release the mouese after it reached the target
Browse files Browse the repository at this point in the history
  • Loading branch information
ZoeLi0525 committed Nov 5, 2024
1 parent 77634f4 commit c5f69f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 27 deletions.
26 changes: 4 additions & 22 deletions src/vstt/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def __init__(self, win: Window, trial: vstt.vtypes.Trial):
self.first_target_of_condition_shown = False
self.most_recent_target_display_time = 0.0
self.final_target_display_time_previous_trial = 0.0
self.green_target_index: int | None = None

def cursor_path_add_vertex(
self, vertex: tuple[float, float], clear_existing: bool = False
Expand Down Expand Up @@ -281,7 +282,7 @@ def _do_target(
mouse_pos = tm.cursor.pos
stop_waiting_time = 0.0
stop_target_time = 0.0
green_target_index = None
tm.green_target_index = None
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 @@ -319,7 +320,7 @@ def _do_target(
tm.targets,
trial["show_inactive_targets"],
None,
green_target_index,
tm,
)
if trial["show_target_labels"] and tm.target_labels is not None:
vis.update_target_label_colors(
Expand Down Expand Up @@ -415,26 +416,7 @@ def _do_target(
)
# When the target is reached, turn the color to green
if success and trial["turn_target_to_green_when_reached"]:
green_target_index = target_index
# vis.update_target_colors(
# tm.targets,
# trial["hide_target_when_reached"],
# target_index,
# trial["turn_target_to_green_when_reached"],
# green_target_index,
# )
# should_continue_highlighting = True
# while should_continue_highlighting:
# vis.draw_and_flip(self.win, tm.drawables, self.kb)
# should_continue_highlighting = (
# dist_correct <= target_size
# and tm.clock.getTime() + minimum_window_for_flip < stop_target_time
# )
# if success:
# vis.update_target_colors(tm.targets, trial["hide_target_when_reached"], target_index,trial["turn_target_to_green_when_reached"])
# # Adjust the number to control how long the green color stays visible
# for _ in range(30):
# vis.draw_and_flip(self.win, tm.drawables, self.kb)
tm.green_target_index = target_index
if is_central_target:
trial_data.to_center_success.append(success)
else:
Expand Down
9 changes: 4 additions & 5 deletions src/vstt/vis.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
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 @@ -101,8 +102,7 @@ def update_target_colors(
targets: ElementArrayStim,
show_inactive_targets: bool,
index: int | None = None,
# turn_target_to_green_when_reached: bool = False,
green_target_index: int | None = None,
tm: TrialManager | None = None,
) -> None:
inactive_rgb = 0.0
if show_inactive_targets:
Expand All @@ -111,10 +111,9 @@ def update_target_colors(
if index is not None:
# Set specified target to red
c[index] = [1, -1, -1]
if green_target_index is not None:
if tm is not None and tm.green_target_index is not None:
# Set specified target to green
c[green_target_index] = [-1, 1, -1]

c[tm.green_target_index] = [-1, 1, -1]
targets.setColors(c, colorSpace="rgb")


Expand Down

0 comments on commit c5f69f9

Please sign in to comment.