-
Notifications
You must be signed in to change notification settings - Fork 0
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
add spatial error and unit test cases #255
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
86e4b7e
update the number of successful targets and trials
0269177
add gnome-screenshot to linux CI system dependencies
lkeegan 544e4bb
simplify logic and remove duplication in function _spatial_error()
dbcc7f6
Merge branch 'main' into spatial_error
b1a7920
Merge remote-tracking branch 'origin/spatial_error' into spatial_error
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ def list_dest_stat_label_units() -> List[Tuple[str, List[Tuple[str, str, str]]]] | |
("distance", "Distance", ""), | ||
("rmse", "RMSE", ""), | ||
("success", "Success", ""), | ||
("spatial_error", "Spatial", ""), | ||
]: | ||
stats.append((f"to_{destination}_{base_stat}", label, unit)) | ||
list_dest_stats.append((destination, stats)) | ||
|
@@ -46,11 +47,13 @@ def _get_trial_data_columns() -> List[str]: | |
"condition_index", | ||
"target_index", | ||
"target_pos", | ||
"target_radius", | ||
"to_target_timestamps", | ||
"to_target_mouse_positions", | ||
"to_target_success", | ||
"to_target_num_timestamps_before_visible", | ||
"center_pos", | ||
"center_radius", | ||
"to_center_timestamps", | ||
"to_center_mouse_positions", | ||
"to_center_success", | ||
|
@@ -81,6 +84,9 @@ def _get_target_data( | |
) -> List: | ||
data = trial_handler.data | ||
condition_index = trial_handler.sequenceIndices[index] | ||
conditions = trial_handler.trialList[condition_index] | ||
target_radius = conditions["target_size"] | ||
central_target_radius = conditions["central_target_size"] | ||
target_index = data["target_indices"][index][i_target] | ||
target_pos = np.array(data["target_pos"][index][i_target]) | ||
center_pos = np.array([0.0, 0.0]) | ||
|
@@ -114,11 +120,13 @@ def _get_target_data( | |
condition_index, | ||
target_index, | ||
target_pos, | ||
target_radius, | ||
to_target_timestamps, | ||
to_target_mouse_positions, | ||
to_target_success, | ||
to_target_num_timestamps_before_visible, | ||
center_pos, | ||
central_target_radius, | ||
to_center_timestamps, | ||
to_center_mouse_positions, | ||
to_center_success, | ||
|
@@ -167,6 +175,14 @@ def stats_dataframe(trial_handler: TrialHandlerExt) -> pd.DataFrame: | |
), | ||
axis=1, | ||
) | ||
df[f"to_{destination}_spatial_error"] = df.apply( | ||
lambda x: _spatial_error( | ||
x[f"to_{destination}_mouse_positions"], | ||
x[f"{destination}_pos"], | ||
x[f"{destination}_radius"], | ||
), | ||
axis=1, | ||
) | ||
df["area"] = df.apply( | ||
lambda x: _area(x["to_target_mouse_positions"], x["to_center_mouse_positions"]), | ||
axis=1, | ||
|
@@ -558,3 +574,16 @@ def get_acceleration( | |
second_order_derivative = get_derivative(first_order_derivative, mouse_times[:-1]) | ||
acceleration = LA.norm(second_order_derivative, axis=0) | ||
return acceleration | ||
|
||
|
||
def _spatial_error( | ||
mouse_position: np.ndarray, target: np.ndarray, target_radius: float | ||
) -> float: | ||
if mouse_position.size >= 1: | ||
end_point = mouse_position[-1] | ||
else: | ||
return 0 | ||
if xydist(end_point, target) >= target_radius: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To simplfy the logic & avoid duplication maybe something like this would be cleaner?:
|
||
return xydist(end_point, target) - target_radius | ||
else: | ||
return 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.